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