diff options
-rw-r--r-- | include/linux/mm.h | 11 | ||||
-rw-r--r-- | mm/page_alloc.c | 4 |
2 files changed, 11 insertions, 4 deletions
diff --git a/include/linux/mm.h b/include/linux/mm.h index 679300c050f5..ff83798e1c27 100644 --- a/include/linux/mm.h +++ b/include/linux/mm.h | |||
@@ -402,16 +402,23 @@ static inline void init_page_count(struct page *page) | |||
402 | /* | 402 | /* |
403 | * PageBuddy() indicate that the page is free and in the buddy system | 403 | * PageBuddy() indicate that the page is free and in the buddy system |
404 | * (see mm/page_alloc.c). | 404 | * (see mm/page_alloc.c). |
405 | * | ||
406 | * PAGE_BUDDY_MAPCOUNT_VALUE must be <= -2 but better not too close to | ||
407 | * -2 so that an underflow of the page_mapcount() won't be mistaken | ||
408 | * for a genuine PAGE_BUDDY_MAPCOUNT_VALUE. -128 can be created very | ||
409 | * efficiently by most CPU architectures. | ||
405 | */ | 410 | */ |
411 | #define PAGE_BUDDY_MAPCOUNT_VALUE (-128) | ||
412 | |||
406 | static inline int PageBuddy(struct page *page) | 413 | static inline int PageBuddy(struct page *page) |
407 | { | 414 | { |
408 | return atomic_read(&page->_mapcount) == -2; | 415 | return atomic_read(&page->_mapcount) == PAGE_BUDDY_MAPCOUNT_VALUE; |
409 | } | 416 | } |
410 | 417 | ||
411 | static inline void __SetPageBuddy(struct page *page) | 418 | static inline void __SetPageBuddy(struct page *page) |
412 | { | 419 | { |
413 | VM_BUG_ON(atomic_read(&page->_mapcount) != -1); | 420 | VM_BUG_ON(atomic_read(&page->_mapcount) != -1); |
414 | atomic_set(&page->_mapcount, -2); | 421 | atomic_set(&page->_mapcount, PAGE_BUDDY_MAPCOUNT_VALUE); |
415 | } | 422 | } |
416 | 423 | ||
417 | static inline void __ClearPageBuddy(struct page *page) | 424 | static inline void __ClearPageBuddy(struct page *page) |
diff --git a/mm/page_alloc.c b/mm/page_alloc.c index bd7625676a64..7945247b1e53 100644 --- a/mm/page_alloc.c +++ b/mm/page_alloc.c | |||
@@ -286,7 +286,7 @@ static void bad_page(struct page *page) | |||
286 | 286 | ||
287 | /* Don't complain about poisoned pages */ | 287 | /* Don't complain about poisoned pages */ |
288 | if (PageHWPoison(page)) { | 288 | if (PageHWPoison(page)) { |
289 | __ClearPageBuddy(page); | 289 | reset_page_mapcount(page); /* remove PageBuddy */ |
290 | return; | 290 | return; |
291 | } | 291 | } |
292 | 292 | ||
@@ -317,7 +317,7 @@ static void bad_page(struct page *page) | |||
317 | dump_stack(); | 317 | dump_stack(); |
318 | out: | 318 | out: |
319 | /* Leave bad fields for debug, except PageBuddy could make trouble */ | 319 | /* Leave bad fields for debug, except PageBuddy could make trouble */ |
320 | __ClearPageBuddy(page); | 320 | reset_page_mapcount(page); /* remove PageBuddy */ |
321 | add_taint(TAINT_BAD_PAGE); | 321 | add_taint(TAINT_BAD_PAGE); |
322 | } | 322 | } |
323 | 323 | ||