Re: [PATCH v2] mm/mglru: skip oom killing for order != 0 allocs in kswapd
From: Barry Song
Date: Wed Dec 02 2026 - 23:38:11 EST
On Thu, Dec 3, 2026 at 7:07 AM Chris Down <chris@xxxxxxxxxxxxxx> wrote:
>
> Hi Barry, Bingfang,
>
> Barry Song writes:
> >I'm not really convinced this is the correct fix. It seems to work
> >around an issue with min_ttl for higher-order allocations, but it
> >doesn't appear to address the root cause.
>
> Hmm... the over-reclaim for high-order wakeups does need fixing, but I
> think the OOM kills are a separate regression and should be fixed on their
> own. Before 30d77b7eef01 ("mm/mglru: fix ineffective protection
> calculation"), lru_gen_age_node() returned early for any non-zero
> sc->order, with a comment saying that this was to exclude
> compaction-induced reclaim.
Hi Chris,
Thanks for your comments. My point is that rapid aging is driven by
over-reclaim when we already have plenty of free memory but still
cannot satisfy an order-9 allocation.
Once we fix the over-reclaim issue, we should no longer see such
aggressive aging that leaves all generations across all memcgs
extremely young, which in turn leads to the reported OOM.
>
> That commit needed the memcg walk to always run for
> mem_cgroup_calculate_protection(), so the early return was dropped and the
> order check went with it. Its changelog only talks about the DEF_PRIORITY
> part, so it looks like the order check was lost by accident.
> should_abort_scan() still has the same check with the same comment.
Meanwhile, if fixing over-reclaim takes longer, I'm perfectly fine
with addressing the OOM issue first if it is more urgent.
Perhaps we could use the following patch as an interim fix?
diff --git a/mm/vmscan.c b/mm/vmscan.c
index 91b301c9e6fe..5d325c20e9e1 100644
--- a/mm/vmscan.c
+++ b/mm/vmscan.c
@@ -4569,6 +4569,15 @@ static void lru_gen_age_node(struct pglist_data
*pgdat, struct scan_control *sc)
reclaimable = lruvec_is_reclaimable(lruvec,
sc, min_ttl);
} while ((memcg = mem_cgroup_iter(NULL, memcg, NULL)));
+ /*
+ * Higher-order allocations can cause excessive reclaim and rapid
+ * aging when memory is fragmented, leaving all generations younger
+ * than min_ttl despite having plenty of free memory. Avoid
+ * premature OOM kills in this case.
+ */
+ if (sc->order >= PAGE_ALLOC_COSTLY_ORDER)
+ return;
+
/*
* The main goal is to OOM kill if every generation from all memcgs is
* younger than min_ttl. However, another possibility is all memcgs are
Thanks,
Barry