mm: Add batch size for free page reporting
Subsystems (2)
RFC PATCH v2 2/4 mm: Add batch size for free page reporting
Use the page order as the only threshold for page reporting is not flexible and has some flaws.
When the system's memory becomes very fragmented, there will be a lot of low order free pages but very few high order pages, limit the mini order as pageblock_order will prevent most of free pages from being reclaimed by host for the case of page reclmain through the virtio-balllon driver.
Scan a long free list is not cheap, it's better to wake up the page reporting worker when there are more pages, wake it up for a sigle page may not worth.
This patch add a batch size as another threshold to control the waking up of reporting worker.
Cc Alexander Duyck <[email protected]>
Cc Mel Gorman <[email protected]>
Cc Andrea Arcangeli <[email protected]>
Cc Dan Williams <[email protected]>
Cc Dave Hansen <[email protected]>
Cc David Hildenbrand <[email protected]>
Cc Michal Hocko <[email protected]>
Cc Andrew Morton <[email protected]>
Cc Alex Williamson <[email protected]>
Cc Michael S. Tsirkin <[email protected]>
Signed-off-by Liang Li <[email protected]>
--- mm/page_reporting.c | 2 ++ mm/page_reporting.h | 12 ++++++++++-- 2 files changed, 12 insertions(+), 2 deletions(-)
mm/page_reporting.c +2 -0
@@ -14,6 +14,8 @@#define PAGE_REPORTING_DELAY (2 * HZ)#define MAX_SCAN_NUM 1024 +unsigned long page_report_batch_size__read_mostly =4 *1024 *1024UL ; +static struct page_reporting_dev_info __rcu *pr_dev_info__read_mostly ;enum {
mm/page_reporting.h +10 -2
@@ -12,6 +12,8 @@#define PAGE_REPORTING_MIN_ORDER pageblock_order +extern unsigned long page_report_batch_size; +#ifdef CONFIG_PAGE_REPORTING DECLARE_STATIC_KEY_FALSE (page_reporting_enabled);void __page_reporting_notify (void );
@@ -33,6 +35,8 @@ static inline bool page_reported(struct page *page)*/ static inline void page_reporting_notify_free (unsigned int order) { +static long batch_size; +/* Called from hot path in __free_one_page() */ if (!static_branch_unlikely (&page_reporting_enabled))return ;
@@ -41,8 +45,12 @@ static inline void page_reporting_notify_free(unsigned int order)if (order <PAGE_REPORTING_MIN_ORDER )return ; -/* This will add a few cycles, but should be called infrequently */ - __page_reporting_notify(); + batch_size += (1 << order) <<PAGE_SHIFT ; +if (batch_size >= page_report_batch_size) { + batch_size =0 ; +/* This add a few cycles, but should be called infrequently */ +__page_reporting_notify (); + } }#else /* CONFIG_PAGE_REPORTING */ #define page_reported (_page) false
Signature · 1 line
2.18.2