From: Joshua Hahn <joshua.hahnjy@gmail.com>
To: "Vlastimil Babka (SUSE)" <vbabka@kernel.org>
Cc: Andrew Morton <akpm@linux-foundation.org>,
David Hildenbrand <david@kernel.org>,
Lorenzo Stoakes <ljs@kernel.org>,
"Liam R. Howlett" <liam@infradead.org>,
Mike Rapoport <rppt@kernel.org>,
Suren Baghdasaryan <surenb@google.com>,
Michal Hocko <mhocko@suse.com>,
Brendan Jackman <brendan.jackman@linux.dev>,
Johannes Weiner <hannes@cmpxchg.org>, Zi Yan <ziy@nvidia.com>,
Qi Zheng <qi.zheng@linux.dev>,
Shakeel Butt <shakeel.butt@linux.dev>,
Dev Jain <dev.jain@arm.com>,
linux-mm@kvack.org, linux-kernel@vger.kernel.org,
kernel-team@meta.com
Subject: Re: [PATCH v3 2/2] mm/vmscan: consolidate promo vs. high watermark checks
Date: Mon, 23 Nov 2026 09:49:05 -0800 [thread overview]
Message-ID: <awR8ZuldFtf93uNF@devbig011.atn3.facebook.com> (raw)
In-Reply-To: <84ba8739-1f1c-4838-b607-e6181fe55002@kernel.org>
On Mon, Nov 23, 2026 at 02:44:31PM +0100, Vlastimil Babka (SUSE) wrote:
> On 11/19/26 00:05, Joshua Hahn wrote:
> > 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 a helper function. While at it, remove the
> > include for <linux/sched/sysctl.h> in mm/page_alloc.c now that the
> > dependency on sysctl_numa_balancing_mode has been abstracted into
> > vmscan code.
> >
> > No functional changes intended.
> >
> > Reviewed-by: SJ Park <sj@kernel.org>
> > Reviewed-by: Chris Down <chris@chrisdown.name>
> > Reviewed-by: Zi Yan <ziy@nvidia.com>
> > Reviewed-by: Gregory Price <gourry@gourry.net>
> > Reviewed-by: Dev Jain <dev.jain@arm.com>
> > Tested-by: Chris Down <chris@chrisdown.name>
> > Signed-off-by: Joshua Hahn <joshua.hahnjy@gmail.com>
> > ---
> > mm/internal.h | 1 +
> > mm/page_alloc.c | 6 +-----
> > mm/vmscan.c | 22 +++++++++++++---------
> > 3 files changed, 15 insertions(+), 14 deletions(-)
> >
> > diff --git a/mm/internal.h b/mm/internal.h
> > index 566cbd2dce485..8beb5b263ca1f 100644
> > --- a/mm/internal.h
> > +++ b/mm/internal.h
> > @@ -68,6 +68,7 @@ unsigned long try_to_free_pages(struct zonelist *zonelist, int order,
> > gfp_t gfp_mask, const nodemask_t *mask);
> > unsigned long lruvec_lru_size(struct lruvec *lruvec, enum lru_list lru,
> > int zone_idx);
> > +unsigned long kswapd_wmark_pages(const struct zone *zone);
>
> Can we inline it? Seems wasteful to make the allocation fastpath call to
> vmscan.o just for this.
Hi Vlastimil, thanks for taking a look! Yeah, sounds reasonable to me.
> I'd probably put it in mm/page_alloc.h as we're trying to split out the
> monolithing mm/internal.h
> It shouldn't be a problem to include include/linux/sched/sysctl.h there for
> sysctl_numa_balancing_mode, hopefully.
Doesn't seem like it will be an issue. Let me send out a new version for
this with both changes then. Have a great day!
Joshua
> Thanks.
>
> >
> > #define MEMCG_RECLAIM_MAY_SWAP (1 << 1)
> > #define MEMCG_RECLAIM_PROACTIVE (1 << 2)
> > 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 <linux/mmu_notifier.h>
> > #include <linux/migrate.h>
> > #include <linux/sched/mm.h>
> > -#include <linux/sched/sysctl.h>
> > #include <linux/page_owner.h>
> > #include <linux/page_table_check.h>
> > #include <linux/memcontrol.h>
> > @@ -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/vmscan.c b/mm/vmscan.c
> > index 9959ca158ce83..9af50783fc824 100644
> > --- a/mm/vmscan.c
> > +++ b/mm/vmscan.c
> > @@ -478,6 +478,17 @@ unsigned long lruvec_lru_size(struct lruvec *lruvec, enum lru_list lru, int zone
> > return size;
> > }
> >
> > +/*
> > + * The watermark kswapd reclaims zones up to. With NUMA balancing memory
> > + * tiering, kswapd keeps room above the high watermark for promotions.
> > + */
> > +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);
> > +}
> > +
> > static unsigned long drop_slab_node(int nid)
> > {
> > unsigned long freed = 0;
> > @@ -5212,7 +5223,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 +5234,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 +7138,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
>
prev parent reply other threads:[~2026-11-23 17:49 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-18 23:05 [PATCH v3 0/2] mm/page_alloc: get_page_from_freelist cleanups Joshua Hahn
2026-11-18 23:05 ` [PATCH v3 1/2] mm/page_alloc: move the kswapd node skip check into a helper Joshua Hahn
2026-11-18 23:05 ` [PATCH v3 2/2] mm/vmscan: consolidate promo vs. high watermark checks Joshua Hahn
2026-11-23 13:44 ` Vlastimil Babka (SUSE)
2026-11-23 17:49 ` Joshua Hahn [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=awR8ZuldFtf93uNF@devbig011.atn3.facebook.com \
--to=joshua.hahnjy@gmail.com \
--cc=akpm@linux-foundation.org \
--cc=brendan.jackman@linux.dev \
--cc=david@kernel.org \
--cc=dev.jain@arm.com \
--cc=hannes@cmpxchg.org \
--cc=kernel-team@meta.com \
--cc=liam@infradead.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mm@kvack.org \
--cc=ljs@kernel.org \
--cc=mhocko@suse.com \
--cc=qi.zheng@linux.dev \
--cc=rppt@kernel.org \
--cc=shakeel.butt@linux.dev \
--cc=surenb@google.com \
--cc=vbabka@kernel.org \
--cc=ziy@nvidia.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®