xref: /linux/mm/page_reporting.h (revision 762f99f4f3cb41a775b5157dd761217beba65873)
136e66c55SAlexander Duyck /* SPDX-License-Identifier: GPL-2.0 */
236e66c55SAlexander Duyck #ifndef _MM_PAGE_REPORTING_H
336e66c55SAlexander Duyck #define _MM_PAGE_REPORTING_H
436e66c55SAlexander Duyck 
536e66c55SAlexander Duyck #include <linux/mmzone.h>
636e66c55SAlexander Duyck #include <linux/pageblock-flags.h>
736e66c55SAlexander Duyck #include <linux/page-isolation.h>
836e66c55SAlexander Duyck #include <linux/jump_label.h>
936e66c55SAlexander Duyck #include <linux/slab.h>
10ca5999fdSMike Rapoport #include <linux/pgtable.h>
1136e66c55SAlexander Duyck #include <linux/scatterlist.h>
1236e66c55SAlexander Duyck 
1336e66c55SAlexander Duyck #ifdef CONFIG_PAGE_REPORTING
1436e66c55SAlexander Duyck DECLARE_STATIC_KEY_FALSE(page_reporting_enabled);
15*f58780a8SGavin Shan extern unsigned int page_reporting_order;
1636e66c55SAlexander Duyck void __page_reporting_notify(void);
1736e66c55SAlexander Duyck 
page_reported(struct page * page)1836e66c55SAlexander Duyck static inline bool page_reported(struct page *page)
1936e66c55SAlexander Duyck {
2036e66c55SAlexander Duyck 	return static_branch_unlikely(&page_reporting_enabled) &&
2136e66c55SAlexander Duyck 	       PageReported(page);
2236e66c55SAlexander Duyck }
2336e66c55SAlexander Duyck 
2436e66c55SAlexander Duyck /**
2536e66c55SAlexander Duyck  * page_reporting_notify_free - Free page notification to start page processing
2636e66c55SAlexander Duyck  *
2736e66c55SAlexander Duyck  * This function is meant to act as a screener for __page_reporting_notify
2836e66c55SAlexander Duyck  * which will determine if a give zone has crossed over the high-water mark
2936e66c55SAlexander Duyck  * that will justify us beginning page treatment. If we have crossed that
3036e66c55SAlexander Duyck  * threshold then it will start the process of pulling some pages and
3136e66c55SAlexander Duyck  * placing them in the batch list for treatment.
3236e66c55SAlexander Duyck  */
page_reporting_notify_free(unsigned int order)3336e66c55SAlexander Duyck static inline void page_reporting_notify_free(unsigned int order)
3436e66c55SAlexander Duyck {
3536e66c55SAlexander Duyck 	/* Called from hot path in __free_one_page() */
3636e66c55SAlexander Duyck 	if (!static_branch_unlikely(&page_reporting_enabled))
3736e66c55SAlexander Duyck 		return;
3836e66c55SAlexander Duyck 
3936e66c55SAlexander Duyck 	/* Determine if we have crossed reporting threshold */
40*f58780a8SGavin Shan 	if (order < page_reporting_order)
4136e66c55SAlexander Duyck 		return;
4236e66c55SAlexander Duyck 
4336e66c55SAlexander Duyck 	/* This will add a few cycles, but should be called infrequently */
4436e66c55SAlexander Duyck 	__page_reporting_notify();
4536e66c55SAlexander Duyck }
4636e66c55SAlexander Duyck #else /* CONFIG_PAGE_REPORTING */
4736e66c55SAlexander Duyck #define page_reported(_page)	false
4836e66c55SAlexander Duyck 
page_reporting_notify_free(unsigned int order)4936e66c55SAlexander Duyck static inline void page_reporting_notify_free(unsigned int order)
5036e66c55SAlexander Duyck {
5136e66c55SAlexander Duyck }
5236e66c55SAlexander Duyck #endif /* CONFIG_PAGE_REPORTING */
5336e66c55SAlexander Duyck #endif /*_MM_PAGE_REPORTING_H */
54