There are three sites which all check the watermark that kswapd reclaims zones up to, which is the promo watermark when NUMA balancing memory tiering is enabled, and the high watermark otherwise. Consolidate the pattern into an inline helper and move the dependency on the sysctl.h header into page_alloc.h. No functional changes intended. Reviewed-by: SJ Park Reviewed-by: Chris Down Reviewed-by: Zi Yan Reviewed-by: Gregory Price Reviewed-by: Dev Jain Tested-by: Chris Down Signed-off-by: Joshua Hahn --- mm/page_alloc.c | 6 +----- mm/page_alloc.h | 12 ++++++++++++ mm/vmscan.c | 11 ++--------- 3 files changed, 15 insertions(+), 14 deletions(-) diff --git a/mm/page_alloc.c b/mm/page_alloc.c index e7a7863e381ab..31a670eb4832c 100644 --- a/mm/page_alloc.c +++ b/mm/page_alloc.c @@ -45,7 +45,6 @@ #include #include #include -#include #include #include #include @@ -3805,10 +3804,7 @@ should_skip_kswapd_zone(struct zone *zone, unsigned int order, if (waitqueue_active(&zone->zone_pgdat->kswapd_wait)) return false; - if (sysctl_numa_balancing_mode & NUMA_BALANCING_MEMORY_TIERING) - mark = promo_wmark_pages(zone); - else - mark = high_wmark_pages(zone); + mark = kswapd_wmark_pages(zone); return !zone_watermark_fast(zone, order, mark, ac->highest_zoneidx, 0, gfp_mask); } diff --git a/mm/page_alloc.h b/mm/page_alloc.h index e238ee91ed245..4fed0342a99f2 100644 --- a/mm/page_alloc.h +++ b/mm/page_alloc.h @@ -9,6 +9,7 @@ #include #include #include +#include #include #define ALLOC_DEFAULT 0 @@ -304,6 +305,17 @@ static inline int gfp_migratetype(const gfp_t gfp_flags) #undef GFP_MOVABLE_MASK #undef GFP_MOVABLE_SHIFT +/* + * The watermark kswapd reclaims zones up to. With NUMA balancing memory + * tiering, kswapd keeps room above the high watermark for promotions. + */ +static inline unsigned long kswapd_wmark_pages(const struct zone *zone) +{ + if (sysctl_numa_balancing_mode & NUMA_BALANCING_MEMORY_TIERING) + return promo_wmark_pages(zone); + return high_wmark_pages(zone); +} + bool decay_pcp_high(struct zone *zone, struct per_cpu_pages *pcp); void drain_zone_pages(struct zone *zone, struct per_cpu_pages *pcp); void drain_all_pages(struct zone *zone); diff --git a/mm/vmscan.c b/mm/vmscan.c index 9959ca158ce83..158b888ab370d 100644 --- a/mm/vmscan.c +++ b/mm/vmscan.c @@ -5212,7 +5212,6 @@ static long get_nr_to_scan(struct lruvec *lruvec, struct scan_control *sc, static bool should_abort_scan(struct lruvec *lruvec, struct scan_control *sc) { int i; - enum zone_watermarks mark; if (unlikely(sc->proactive && signal_pending(current))) return true; @@ -5224,12 +5223,9 @@ static bool should_abort_scan(struct lruvec *lruvec, struct scan_control *sc) if (!current_is_kswapd() || sc->order) return false; - mark = sysctl_numa_balancing_mode & NUMA_BALANCING_MEMORY_TIERING ? - WMARK_PROMO : WMARK_HIGH; - for (i = 0; i <= sc->reclaim_idx; i++) { struct zone *zone = lruvec_pgdat(lruvec)->node_zones + i; - unsigned long size = wmark_pages(zone, mark) + MIN_LRU_BATCH; + unsigned long size = kswapd_wmark_pages(zone) + MIN_LRU_BATCH; if (managed_zone(zone) && !zone_watermark_ok(zone, 0, size, sc->reclaim_idx, 0)) return false; @@ -7131,10 +7127,7 @@ static bool pgdat_balanced(pg_data_t *pgdat, int order, int highest_zoneidx) enum zone_stat_item item; unsigned long free_pages; - if (sysctl_numa_balancing_mode & NUMA_BALANCING_MEMORY_TIERING) - mark = promo_wmark_pages(zone); - else - mark = high_wmark_pages(zone); + mark = kswapd_wmark_pages(zone); /* * In defrag_mode, watermarks must be met in whole -- 2.53.1-Meta