Re: [PATCH v2] mm/page_alloc: only skip kswapd nodes below their kswapd watermark

From: Gregory Price (Meta)

Date: Thu Nov 12 2026 - 01:21:03 EST


On 2026-11-10 14:44 -0800, Joshua Hahn wrote:
> Commit 19c5fb83f2a4 ("mm: page_alloc: avoid kswapd thrashing due to
> NUMA restrictions") makes get_page_from_freelist() skip any node with an
> active kswapd on the first pass through the zonelist, so unrestricted
> allocations don't immediately consume the memory kswapd is freeing.
>
> But kswapd is also woken for high-order requests. With THP defrag set to
> defer, each THP fault that fails on a fragmented node wakes kswapd at
> PMD order. kswapd reclaims a batch, wakes kcompactd, and sleeps until
> the next failed fault, so it stays awake much of the time even on a node
> with plenty of free order-0 memory. This means those order-0 allocations
> get directed elsewhere.
>
> This was observed on some Meta production workloads running on 2-NUMA
> systems, where processes with a preference for node0 allocations
> continuously allocated order-0 pages on node1, despite node0 having
> hundreds of GB of free memory.
>
> Only skip a zone with an active kswapd if it is also below kswapd's
> target watermark.
>

I feel this commit message could have been simplified further.
Brevity is the soul of wit.

patch (details) skips any node with kswapd running - assuming that
this means memory is low, but kswapd is woken for other reasons (e.g.
order-N allocation failures).

This results in fallback allocations under X conditions, which leads
to xyz performance isues.

Only skip nodes with kswap running if the node is under the relevant
low-memory watermark.

(test details)


Otherwise this looks good to me. Looking forward to the watermark
cleanup afterwards - i agree the change here is a bit ugly, but
probably preferable for the backport.

Acked-by: Gregory Price (Meta) <gourry@xxxxxxxxxx>

--
~Gregory