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_PAGE_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
)
37 if (order
>= debug_guardpage_minorder())
41 INIT_LIST_HEAD(&page
->buddy_list
);
42 set_page_private(page
, order
);
47 void __clear_page_guard(struct zone
*zone
, struct page
*page
, unsigned int order
)
49 __ClearPageGuard(page
);
50 set_page_private(page
, 0);