Commit d2a1a1f0 authored by Yu Zhao's avatar Yu Zhao Committed by Linus Torvalds

mm: use unsigned long constant for page flags

struct page->flags is unsigned long, so when shifting bits we should use
UL suffix to match it.

Found this problem after I added 64-bit CPU specific page flags and
failed to compile the kernel:

  mm/page_alloc.c: In function '__free_one_page':
  mm/page_alloc.c:672:2: error: integer overflow in expression [-Werror=overflow]

Link: http://lkml.kernel.org/r/1461971723-16187-1-git-send-email-yuzhao@google.comSigned-off-by: default avatarYu Zhao <yuzhao@google.com>
Cc: "Kirill A . Shutemov" <kirill.shutemov@linux.intel.com>
Cc: Michal Hocko <mhocko@suse.com>
Cc: Naoya Horiguchi <n-horiguchi@ah.jp.nec.com>
Cc: Jerome Marchand <jmarchan@redhat.com>
Cc: Denys Vlasenko <dvlasenk@redhat.com>
Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
parent 2a138dc7
...@@ -479,7 +479,7 @@ static inline void ClearPageCompound(struct page *page) ...@@ -479,7 +479,7 @@ static inline void ClearPageCompound(struct page *page)
} }
#endif #endif
#define PG_head_mask ((1L << PG_head)) #define PG_head_mask ((1UL << PG_head))
#ifdef CONFIG_HUGETLB_PAGE #ifdef CONFIG_HUGETLB_PAGE
int PageHuge(struct page *page); int PageHuge(struct page *page);
...@@ -670,7 +670,7 @@ static inline void ClearPageSlabPfmemalloc(struct page *page) ...@@ -670,7 +670,7 @@ static inline void ClearPageSlabPfmemalloc(struct page *page)
} }
#ifdef CONFIG_MMU #ifdef CONFIG_MMU
#define __PG_MLOCKED (1 << PG_mlocked) #define __PG_MLOCKED (1UL << PG_mlocked)
#else #else
#define __PG_MLOCKED 0 #define __PG_MLOCKED 0
#endif #endif
...@@ -680,11 +680,11 @@ static inline void ClearPageSlabPfmemalloc(struct page *page) ...@@ -680,11 +680,11 @@ static inline void ClearPageSlabPfmemalloc(struct page *page)
* these flags set. It they are, there is a problem. * these flags set. It they are, there is a problem.
*/ */
#define PAGE_FLAGS_CHECK_AT_FREE \ #define PAGE_FLAGS_CHECK_AT_FREE \
(1 << PG_lru | 1 << PG_locked | \ (1UL << PG_lru | 1UL << PG_locked | \
1 << PG_private | 1 << PG_private_2 | \ 1UL << PG_private | 1UL << PG_private_2 | \
1 << PG_writeback | 1 << PG_reserved | \ 1UL << PG_writeback | 1UL << PG_reserved | \
1 << PG_slab | 1 << PG_swapcache | 1 << PG_active | \ 1UL << PG_slab | 1UL << PG_swapcache | 1UL << PG_active | \
1 << PG_unevictable | __PG_MLOCKED) 1UL << PG_unevictable | __PG_MLOCKED)
/* /*
* Flags checked when a page is prepped for return by the page allocator. * Flags checked when a page is prepped for return by the page allocator.
...@@ -695,10 +695,10 @@ static inline void ClearPageSlabPfmemalloc(struct page *page) ...@@ -695,10 +695,10 @@ static inline void ClearPageSlabPfmemalloc(struct page *page)
* alloc-free cycle to prevent from reusing the page. * alloc-free cycle to prevent from reusing the page.
*/ */
#define PAGE_FLAGS_CHECK_AT_PREP \ #define PAGE_FLAGS_CHECK_AT_PREP \
(((1 << NR_PAGEFLAGS) - 1) & ~__PG_HWPOISON) (((1UL << NR_PAGEFLAGS) - 1) & ~__PG_HWPOISON)
#define PAGE_FLAGS_PRIVATE \ #define PAGE_FLAGS_PRIVATE \
(1 << PG_private | 1 << PG_private_2) (1UL << PG_private | 1UL << PG_private_2)
/** /**
* page_has_private - Determine if page has private stuff * page_has_private - Determine if page has private stuff
* @page: The page to be checked * @page: The page to be checked
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment