Re: [PATCH] mm: vmscan: fix dirty folios throttling on cgroup v1 for MGLRU
From: Kairui Song
Date: Fri Mar 27 2026 - 14:00:16 EST
On Fri, Mar 27, 2026 at 12:41:06PM +0800, Johannes Weiner wrote:
> On Fri, Mar 27, 2026 at 06:21:08PM +0800, Baolin Wang wrote:
> > The balance_dirty_pages() won't do the dirty folios throttling on cgroupv1.
> > See commit 9badce000e2c ("cgroup, writeback: don't enable cgroup writeback
> > on traditional hierarchies").
> >
> > Moreover, after commit 6b0dfabb3555 ("fs: Remove aops->writepage"), we no
> > longer attempt to write back filesystem folios through reclaim.
> >
> > On large memory systems, the flusher may not be able to write back quickly
> > enough. Consequently, MGLRU will encounter many folios that are already
> > under writeback. Since we cannot reclaim these dirty folios, the system
> > may run out of memory and trigger the OOM killer.
> >
> > Hence, for cgroup v1, let's throttle reclaim after waking up the flusher,
> > which is similar to commit 81a70c21d917 ("mm/cgroup/reclaim: fix dirty
> > pages throttling on cgroup v1"), to avoid unnecessary OOM.
>
> This fix for cgroup1 makes sense to me. For cgroup2, MGLRU shares the
> shrink_node() reclaim throttling.
>
Ahem, I think that throttling is actually broken and so I'm fixing
that, I shared a patch yesterday for that as I saw Baolin is fixing V1:
https://lore.kernel.org/linux-mm/acPOn07xah2eh0WU@KASONG-MC4/
Still need about ~3 LOC change after the patch above since I also
need to clean up MGLRU's force reset of PG_reclaim, will post it
tomorrow as part of the V2 of MGLRU's dirty folio handling rework [1].
That series will improve the batch and dirty handling so fixing that
is much easier and cleaner by sharing same routine. Before that
series it could get very messy and cause over aggressive throttling.
Will post tomorrow as my stress test suite is still running
today, it seems all green so far but just in case.
I initially want to post that after that series but Ridong
suggested to just fix that too, and it actually helps to
deduplicate the code, the change is also small.
And right, MGLRU had some issues with dirty flush previously,
Jingxiang and I fixed it:
https://lore.kernel.org/linux-mm/20241026115714.1437435-1-jingxiangzeng.cas@xxxxxxxxx/
But premature OOM is still an problem, not only about dirty
or writeback, but also somehow related to how aging and
protection works. That new series also fixes quite a lot of these,
e.g. the OOM reproducer in cover letter.
https://lore.kernel.org/linux-mm/20260318-mglru-reclaim-v1-0-2c46f9eb0508@xxxxxxxxxxx/
Still not perfect but no worry as we will solve all of them
(hopefully very soon):
https://lore.kernel.org/linux-mm/CAMgjq7BoekNjg-Ra3C8M7=8=75su38w=HD782T5E_cxyeCeH_g@xxxxxxxxxxxxxx/
My local reproduce using dm_delay and dd can trigger OOM without
the fix I posted above, and no more problem after that.
I guess storage nowadays storage might just be too fast and it
rarely congest the whole memory so no one reported this yet. Of
course it is a real issue. We did see a few suspicious OOM,
rare but might be related.