Re: [PATCH v3] mm/page_alloc: only skip kswapd nodes below their kswapd watermark
From: Joshua Hahn
Date: Fri Nov 13 2026 - 13:10:00 EST
On Fri, Nov 13, 2026 at 1:18 AM Vlastimil Babka (SUSE)
<vbabka@xxxxxxxxxx> wrote:
>
> On 11/12/26 22:47, Joshua Hahn wrote:
> > Commit 19c5fb83f2a4 ("mm: page_alloc: avoid kswapd thrashing due to
> > NUMA restrictions") makes get_page_from_freelist() skip any node with
> > kswapd running to avoid piling on already-pressured nodes.
> >
> > This assumes that kswapd was woken to create free space, although kswapd
> > can be woken up for other reasons, like higher order allocation
> > failures. Thus, fragmented nodes with failed high order allocations will
> > always wake up kswapd and direct order-0 allocations to the fallback
> > path, even when there is free space.
> >
> > This behavior was observed on 2-NUMA Meta production workloads where
> > faults would pile on already pressured remote nodes while stranding
> > memory on the relatively empty local node, causing unnecessary pressure.
> >
> > Only skip nodes with kswapd running if the node is under the relevant
> > low-memory watermark.
> >
> > On a 2-NUMA VM with a 60G node0 and a 20G node1, with THP enabled=always
> > and defrag=defer, I ran a process that prefers allocating on node0.
> > With a fragmented node0:
> > - Before the patch, 66% of faults were served from node0
> > - After the patch, 100% of faults were served from node0
> >
> > Fixes: 19c5fb83f2a4 ("mm: page_alloc: avoid kswapd thrashing due to NUMA restrictions")
> > Suggested-by: Daniel Hodges <hodgesd@xxxxxxxx>
> > Reviewed-by: Jose A. Perez de Azpillaga <azpijr@xxxxxxxxx>
> > Reviewed-by: Johannes Weiner <hannes@xxxxxxxxxxx>
> > Reviewed-by: Lorenzo Stoakes (ARM) <ljs@xxxxxxxxxx>
> > Acked-by: Gregory Price (Meta) <gourry@xxxxxxxxxx>
> > Acked-by: Zi Yan <ziy@xxxxxxxxxx>
> > Signed-off-by: Joshua Hahn <joshua.hahnjy@xxxxxxxxx>
> > ---
> > v2 --> v3:
> > - Shortening cover letter, suggested by Gregory and Johannes
> > - Collect signatures
> >
> > v1 --> v2:
> > - Added a Fixes tag and separated this from the other cleanup patches
> > - Check zone_watermark_fast with no flag to match the call in
> > pgdat_balanced().
> > - Calculates mark outside the zone_watermark_fast check to match the
> > style for the other zone checks.
> > - Wordsmithing commit message to explain the unaddressed gap.
> > - Yes, this is ugly. I have another series to clean this code up but
> > I wanted this to be a feature-minimal patch so that it could be
> > easily backported. Things will be much prettier once those are landed.
>
> Easily backported, but there's no Cc stable. So I'm adding it as it seems
> useful enough for LTS kernels. But at the same time not urgent for rcX hotfix.
Ah sorry about that Vlastimil, yes, there should be a Cc stable. Thank
you for your help!
Joshua
> Applied to page_alloc/for-next, thanks.
: -)