]> git.proxmox.com Git - mirror_ubuntu-focal-kernel.git/blobdiff - mm/page_alloc.c
mm/debug-pagealloc: prepare boottime configurable on/off
[mirror_ubuntu-focal-kernel.git] / mm / page_alloc.c
index b64666cf5865f597dcd6f0b5417d5aef9a0242c7..e0a39d328ca1881db18147640099cad79fb5d522 100644 (file)
@@ -56,7 +56,7 @@
 #include <linux/prefetch.h>
 #include <linux/mm_inline.h>
 #include <linux/migrate.h>
-#include <linux/page-debug-flags.h>
+#include <linux/page_ext.h>
 #include <linux/hugetlb.h>
 #include <linux/sched/rt.h>
 
@@ -425,6 +425,22 @@ static inline void prep_zero_page(struct page *page, unsigned int order,
 
 #ifdef CONFIG_DEBUG_PAGEALLOC
 unsigned int _debug_guardpage_minorder;
+bool _debug_guardpage_enabled __read_mostly;
+
+static bool need_debug_guardpage(void)
+{
+       return true;
+}
+
+static void init_debug_guardpage(void)
+{
+       _debug_guardpage_enabled = true;
+}
+
+struct page_ext_operations debug_guardpage_ops = {
+       .need = need_debug_guardpage,
+       .init = init_debug_guardpage,
+};
 
 static int __init debug_guardpage_minorder_setup(char *buf)
 {
@@ -443,7 +459,14 @@ __setup("debug_guardpage_minorder=", debug_guardpage_minorder_setup);
 static inline void set_page_guard(struct zone *zone, struct page *page,
                                unsigned int order, int migratetype)
 {
-       __set_bit(PAGE_DEBUG_FLAG_GUARD, &page->debug_flags);
+       struct page_ext *page_ext;
+
+       if (!debug_guardpage_enabled())
+               return;
+
+       page_ext = lookup_page_ext(page);
+       __set_bit(PAGE_EXT_DEBUG_GUARD, &page_ext->flags);
+
        INIT_LIST_HEAD(&page->lru);
        set_page_private(page, order);
        /* Guard pages are not available for any usage */
@@ -453,12 +476,20 @@ static inline void set_page_guard(struct zone *zone, struct page *page,
 static inline void clear_page_guard(struct zone *zone, struct page *page,
                                unsigned int order, int migratetype)
 {
-       __clear_bit(PAGE_DEBUG_FLAG_GUARD, &page->debug_flags);
+       struct page_ext *page_ext;
+
+       if (!debug_guardpage_enabled())
+               return;
+
+       page_ext = lookup_page_ext(page);
+       __clear_bit(PAGE_EXT_DEBUG_GUARD, &page_ext->flags);
+
        set_page_private(page, 0);
        if (!is_migrate_isolate(migratetype))
                __mod_zone_freepage_state(zone, (1 << order), migratetype);
 }
 #else
+struct page_ext_operations debug_guardpage_ops = { NULL, };
 static inline void set_page_guard(struct zone *zone, struct page *page,
                                unsigned int order, int migratetype) {}
 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,
                VM_BUG_ON_PAGE(bad_range(zone, &page[size]), &page[size]);
 
                if (IS_ENABLED(CONFIG_DEBUG_PAGEALLOC) &&
+                       debug_guardpage_enabled() &&
                        high < debug_guardpage_minorder()) {
                        /*
                         * Mark as guard pages (or page), that will allow to