Re: [PATCH v2 4/4] mm: page_alloc: fix non-movable reclaim storm in defrag_mode
From: Andrew Morton
Date: Wed Jul 22 2026 - 19:22:34 EST
On Wed, 22 Jul 2026 10:56:47 -0400 Johannes Weiner <hannes@xxxxxxxxxxx> wrote:
> As we deployed defrag_mode into Meta production, pressure spikes and
> excessive swapping were observed on some workloads. Tracing confirmed
> that this is unmovable/reclaimable requests spinning in the allocator
> and direct reclaim, causing excessive amounts of swap.
>
> The initial plan for defrag_mode was to rely on kswapd/kcompactd to
> produce blocks, and if those are overwhelmed under high pressure, let
> the allocator fall back (__rmqueue_steal()) after its retry loops.
> However, that retrying results in more reclaim on some of these
> workloads than we'd hoped, sometimes excessively so, spurred on by the
> !costly order conditions in should_reclaim_retry().
>
> The storms are dependent on the request type. Reclaim will inevitably
> make room in existing movable blocks, since that's where the LRU pages
> live. So if movable requests retry on reclaim, they make progress.
>
> When non-movable requests spin in reclaim that isn't productive. They
> cannot use the individually freed pages, and the process is unlikely
> to accidentally free whole blocks to meet the ALLOC_NOFRAGMENT bar.
> They spin and overreclaim excessively, which tanks performance and
> triggers userspace guards like swap exhaustion or pressure based OOM.
>
> To fix this, send non-movable requests, regardless of order, into
> pageblock reclaim/compaction. This way, they help move things along to
> meet the ALLOC_NOFRAGMENT bar. After this patch, the reclaim storms
> and excess OOM rates are no longer observed in production.
>
> The longer-term plan is still to have all requests, including the
> movable ones, help make blocks to spread the cost of defragmenting
> more evenly and fairly; combined with proper watermarking to reduce
> allocation latencies in the common case. However, doing this naively
> unearths scaling and concurrency limitations in compaction that need
> to be addressed first. Promoting just non-movables for now is the
> minimally viable bug fix for the above issue.
>
> Fixes: e3aa7df331bc ("mm: page_alloc: defrag_mode")
> Cc: <stable@xxxxxxxxxxxxxxx>
> Signed-off-by: Johannes Weiner <hannes@xxxxxxxxxxx>
This cc:stable fix doesn't apply to current mainline because the
preceding non-cc:stable patches get in the way.
This means that the -stable maintainers will have to ask you to redo
the fix to make it backportable. And you'll then be preparing a patch
which hasn't had standalone testing in mainline. All very cumbersome.
So is it practical to make the fix come first, as a cc:stable hotfix so
we can upstream the other patches in the next merge window?
(An alternative would be to put cc:stable on all four patches. That's
a bit abusive but we do it rarely).
Either way, I'll get these into mm.git for testing while we await
review on [4/4], thanks.