diff options
Diffstat (limited to 'mm/page_alloc.c')
-rw-r--r-- | mm/page_alloc.c | 38 |
1 files changed, 35 insertions, 3 deletions
diff --git a/mm/page_alloc.c b/mm/page_alloc.c index b64666cf5865..e0a39d328ca1 100644 --- a/mm/page_alloc.c +++ b/mm/page_alloc.c | |||
@@ -56,7 +56,7 @@ | |||
56 | #include <linux/prefetch.h> | 56 | #include <linux/prefetch.h> |
57 | #include <linux/mm_inline.h> | 57 | #include <linux/mm_inline.h> |
58 | #include <linux/migrate.h> | 58 | #include <linux/migrate.h> |
59 | #include <linux/page-debug-flags.h> | 59 | #include <linux/page_ext.h> |
60 | #include <linux/hugetlb.h> | 60 | #include <linux/hugetlb.h> |
61 | #include <linux/sched/rt.h> | 61 | #include <linux/sched/rt.h> |
62 | 62 | ||
@@ -425,6 +425,22 @@ static inline void prep_zero_page(struct page *page, unsigned int order, | |||
425 | 425 | ||
426 | #ifdef CONFIG_DEBUG_PAGEALLOC | 426 | #ifdef CONFIG_DEBUG_PAGEALLOC |
427 | unsigned int _debug_guardpage_minorder; | 427 | unsigned int _debug_guardpage_minorder; |
428 | bool _debug_guardpage_enabled __read_mostly; | ||
429 | |||
430 | static bool need_debug_guardpage(void) | ||
431 | { | ||
432 | return true; | ||
433 | } | ||
434 | |||
435 | static void init_debug_guardpage(void) | ||
436 | { | ||
437 | _debug_guardpage_enabled = true; | ||
438 | } | ||
439 | |||
440 | struct page_ext_operations debug_guardpage_ops = { | ||
441 | .need = need_debug_guardpage, | ||
442 | .init = init_debug_guardpage, | ||
443 | }; | ||
428 | 444 | ||
429 | static int __init debug_guardpage_minorder_setup(char *buf) | 445 | static int __init debug_guardpage_minorder_setup(char *buf) |
430 | { | 446 | { |
@@ -443,7 +459,14 @@ __setup("debug_guardpage_minorder=", debug_guardpage_minorder_setup); | |||
443 | static inline void set_page_guard(struct zone *zone, struct page *page, | 459 | static inline void set_page_guard(struct zone *zone, struct page *page, |
444 | unsigned int order, int migratetype) | 460 | unsigned int order, int migratetype) |
445 | { | 461 | { |
446 | __set_bit(PAGE_DEBUG_FLAG_GUARD, &page->debug_flags); | 462 | struct page_ext *page_ext; |
463 | |||
464 | if (!debug_guardpage_enabled()) | ||
465 | return; | ||
466 | |||
467 | page_ext = lookup_page_ext(page); | ||
468 | __set_bit(PAGE_EXT_DEBUG_GUARD, &page_ext->flags); | ||
469 | |||
447 | INIT_LIST_HEAD(&page->lru); | 470 | INIT_LIST_HEAD(&page->lru); |
448 | set_page_private(page, order); | 471 | set_page_private(page, order); |
449 | /* Guard pages are not available for any usage */ | 472 | /* Guard pages are not available for any usage */ |
@@ -453,12 +476,20 @@ static inline void set_page_guard(struct zone *zone, struct page *page, | |||
453 | static inline void clear_page_guard(struct zone *zone, struct page *page, | 476 | static inline void clear_page_guard(struct zone *zone, struct page *page, |
454 | unsigned int order, int migratetype) | 477 | unsigned int order, int migratetype) |
455 | { | 478 | { |
456 | __clear_bit(PAGE_DEBUG_FLAG_GUARD, &page->debug_flags); | 479 | struct page_ext *page_ext; |
480 | |||
481 | if (!debug_guardpage_enabled()) | ||
482 | return; | ||
483 | |||
484 | page_ext = lookup_page_ext(page); | ||
485 | __clear_bit(PAGE_EXT_DEBUG_GUARD, &page_ext->flags); | ||
486 | |||
457 | set_page_private(page, 0); | 487 | set_page_private(page, 0); |
458 | if (!is_migrate_isolate(migratetype)) | 488 | if (!is_migrate_isolate(migratetype)) |
459 | __mod_zone_freepage_state(zone, (1 << order), migratetype); | 489 | __mod_zone_freepage_state(zone, (1 << order), migratetype); |
460 | } | 490 | } |
461 | #else | 491 | #else |
492 | struct page_ext_operations debug_guardpage_ops = { NULL, }; | ||
462 | static inline void set_page_guard(struct zone *zone, struct page *page, | 493 | static inline void set_page_guard(struct zone *zone, struct page *page, |
463 | unsigned int order, int migratetype) {} | 494 | unsigned int order, int migratetype) {} |
464 | static inline void clear_page_guard(struct zone *zone, struct page *page, | 495 | static inline void clear_page_guard(struct zone *zone, struct page *page, |
@@ -869,6 +900,7 @@ static inline void expand(struct zone *zone, struct page *page, | |||
869 | VM_BUG_ON_PAGE(bad_range(zone, &page[size]), &page[size]); | 900 | VM_BUG_ON_PAGE(bad_range(zone, &page[size]), &page[size]); |
870 | 901 | ||
871 | if (IS_ENABLED(CONFIG_DEBUG_PAGEALLOC) && | 902 | if (IS_ENABLED(CONFIG_DEBUG_PAGEALLOC) && |
903 | debug_guardpage_enabled() && | ||
872 | high < debug_guardpage_minorder()) { | 904 | high < debug_guardpage_minorder()) { |
873 | /* | 905 | /* |
874 | * Mark as guard pages (or page), that will allow to | 906 | * Mark as guard pages (or page), that will allow to |