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