1*4882a593Smuzhiyun /* SPDX-License-Identifier: GPL-2.0 */ 2*4882a593Smuzhiyun #ifndef _MM_PAGE_REPORTING_H 3*4882a593Smuzhiyun #define _MM_PAGE_REPORTING_H 4*4882a593Smuzhiyun 5*4882a593Smuzhiyun #include <linux/mmzone.h> 6*4882a593Smuzhiyun #include <linux/pageblock-flags.h> 7*4882a593Smuzhiyun #include <linux/page-isolation.h> 8*4882a593Smuzhiyun #include <linux/jump_label.h> 9*4882a593Smuzhiyun #include <linux/slab.h> 10*4882a593Smuzhiyun #include <linux/pgtable.h> 11*4882a593Smuzhiyun #include <linux/scatterlist.h> 12*4882a593Smuzhiyun 13*4882a593Smuzhiyun #define PAGE_REPORTING_MIN_ORDER pageblock_order 14*4882a593Smuzhiyun 15*4882a593Smuzhiyun #ifdef CONFIG_PAGE_REPORTING 16*4882a593Smuzhiyun DECLARE_STATIC_KEY_FALSE(page_reporting_enabled); 17*4882a593Smuzhiyun void __page_reporting_notify(void); 18*4882a593Smuzhiyun page_reported(struct page * page)19*4882a593Smuzhiyunstatic inline bool page_reported(struct page *page) 20*4882a593Smuzhiyun { 21*4882a593Smuzhiyun return static_branch_unlikely(&page_reporting_enabled) && 22*4882a593Smuzhiyun PageReported(page); 23*4882a593Smuzhiyun } 24*4882a593Smuzhiyun 25*4882a593Smuzhiyun /** 26*4882a593Smuzhiyun * page_reporting_notify_free - Free page notification to start page processing 27*4882a593Smuzhiyun * 28*4882a593Smuzhiyun * This function is meant to act as a screener for __page_reporting_notify 29*4882a593Smuzhiyun * which will determine if a give zone has crossed over the high-water mark 30*4882a593Smuzhiyun * that will justify us beginning page treatment. If we have crossed that 31*4882a593Smuzhiyun * threshold then it will start the process of pulling some pages and 32*4882a593Smuzhiyun * placing them in the batch list for treatment. 33*4882a593Smuzhiyun */ page_reporting_notify_free(unsigned int order)34*4882a593Smuzhiyunstatic inline void page_reporting_notify_free(unsigned int order) 35*4882a593Smuzhiyun { 36*4882a593Smuzhiyun /* Called from hot path in __free_one_page() */ 37*4882a593Smuzhiyun if (!static_branch_unlikely(&page_reporting_enabled)) 38*4882a593Smuzhiyun return; 39*4882a593Smuzhiyun 40*4882a593Smuzhiyun /* Determine if we have crossed reporting threshold */ 41*4882a593Smuzhiyun if (order < PAGE_REPORTING_MIN_ORDER) 42*4882a593Smuzhiyun return; 43*4882a593Smuzhiyun 44*4882a593Smuzhiyun /* This will add a few cycles, but should be called infrequently */ 45*4882a593Smuzhiyun __page_reporting_notify(); 46*4882a593Smuzhiyun } 47*4882a593Smuzhiyun #else /* CONFIG_PAGE_REPORTING */ 48*4882a593Smuzhiyun #define page_reported(_page) false 49*4882a593Smuzhiyun page_reporting_notify_free(unsigned int order)50*4882a593Smuzhiyunstatic inline void page_reporting_notify_free(unsigned int order) 51*4882a593Smuzhiyun { 52*4882a593Smuzhiyun } 53*4882a593Smuzhiyun #endif /* CONFIG_PAGE_REPORTING */ 54*4882a593Smuzhiyun #endif /*_MM_PAGE_REPORTING_H */ 55