1 // SPDX-License-Identifier: GPL-2.0
3 #include <linux/page-isolation.h>
5 unsigned int _debug_guardpage_minorder;
7 bool _debug_pagealloc_enabled_early __read_mostly
8 = IS_ENABLED(CONFIG_DEBUG_PAGEALLOC_ENABLE_DEFAULT);
9 EXPORT_SYMBOL(_debug_pagealloc_enabled_early);
10 DEFINE_STATIC_KEY_FALSE(_debug_pagealloc_enabled);
11 EXPORT_SYMBOL(_debug_pagealloc_enabled);
13 DEFINE_STATIC_KEY_FALSE(_debug_guardpage_enabled);
15 static int __init early_debug_pagealloc(char *buf)
17 return kstrtobool(buf, &_debug_pagealloc_enabled_early);
19 early_param("debug_pagealloc", early_debug_pagealloc);
21 static int __init debug_guardpage_minorder_setup(char *buf)
25 if (kstrtoul(buf, 10, &res) < 0 || res > MAX_ORDER / 2) {
26 pr_err("Bad debug_guardpage_minorder value\n");
29 _debug_guardpage_minorder = res;
30 pr_info("Setting debug_guardpage_minorder to %lu\n", res);
33 early_param("debug_guardpage_minorder", debug_guardpage_minorder_setup);
35 bool __set_page_guard(struct zone *zone, struct page *page, unsigned int order,
38 if (order >= debug_guardpage_minorder())
42 INIT_LIST_HEAD(&page->buddy_list);
43 set_page_private(page, order);
44 /* Guard pages are not available for any usage */
45 if (!is_migrate_isolate(migratetype))
46 __mod_zone_freepage_state(zone, -(1 << order), migratetype);
51 void __clear_page_guard(struct zone *zone, struct page *page, unsigned int order,
54 __ClearPageGuard(page);
56 set_page_private(page, 0);
57 if (!is_migrate_isolate(migratetype))
58 __mod_zone_freepage_state(zone, (1 << order), migratetype);