From nobody Thu Apr 2 17:16:38 2026 Received: from out30-99.freemail.mail.aliyun.com (out30-99.freemail.mail.aliyun.com [115.124.30.99]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 1ED7A3A8735 for ; Fri, 27 Mar 2026 10:21:27 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=115.124.30.99 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1774606890; cv=none; b=pzcEG8I8h/TtYDps4E74pSms5mePgfflGNrTyc2ha9sFtk6yYesMSJg2Clqsenc2WxMs0NrloQXJq6DUmhJqcK3dhl33ROyqus8evEPScXNVU1DDpw3EQbnIIXepPHCMjXhr27mxqEHYXNsveeNkuHIh/EbSnKLjsC12p1bg7zA= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1774606890; c=relaxed/simple; bh=DHOJgWDSUBrxxJ1PfxnbxYR5rmU3prMbdU3jGsIvtr4=; h=From:To:Cc:Subject:Date:Message-ID:MIME-Version; b=AMHMBn+d74zVAv2igf02AqIX1wlcx/GRAxeDcoKMSaKnHk72Lk2aaphj7hcXrem0TKnQUjuvyb0XETJ5yiH+745qyhuq2cOy2ru6mtek+W2EfQTBahPBLV4KBDBTke3L1Mey1svPHsI7SP1V+WXFxLmU4yWlJsmblkttac7yGPU= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.alibaba.com; spf=pass smtp.mailfrom=linux.alibaba.com; dkim=pass (1024-bit key) header.d=linux.alibaba.com header.i=@linux.alibaba.com header.b=Cqyab5jH; arc=none smtp.client-ip=115.124.30.99 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.alibaba.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linux.alibaba.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linux.alibaba.com header.i=@linux.alibaba.com header.b="Cqyab5jH" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.alibaba.com; s=default; t=1774606880; h=From:To:Subject:Date:Message-ID:MIME-Version; bh=xmgOZAwp4EbDVXy8Q0wvm1dBxaFD04bCGkZNNWdOHBA=; b=Cqyab5jHF4yunYZRBHgQiBFeglcj6NdmnpYcF/Jb5GWnaNyJ4pFAfZ4r1Ppnany8NCP4O81UpJ8o3oaIeY1v3H5aLilrNZmFrRE+ztvDosqVAqvoN71LuAYxhV0qlV2j4FyYeOENTmcaPZvGIbVw24w8/2l7+SBmbRgaCwC4dFI= X-Alimail-AntiSpam: AC=PASS;BC=-1|-1;BR=01201311R991e4;CH=green;DM=||false|;DS=||;FP=0|-1|-1|-1|0|-1|-1|-1;HT=maildocker-contentspam033037009110;MF=baolin.wang@linux.alibaba.com;NM=1;PH=DS;RN=15;SR=0;TI=SMTPD_---0X.nz5ds_1774606878; Received: from localhost(mailfrom:baolin.wang@linux.alibaba.com fp:SMTPD_---0X.nz5ds_1774606878 cluster:ay36) by smtp.aliyun-inc.com; Fri, 27 Mar 2026 18:21:19 +0800 From: Baolin Wang To: akpm@linux-foundation.org, hannes@cmpxchg.org Cc: david@kernel.org, mhocko@kernel.org, zhengqi.arch@bytedance.com, shakeel.butt@linux.dev, axelrasmussen@google.com, yuanchu@google.com, weixugc@google.com, ljs@kernel.org, baohua@kernel.org, kasong@tencent.com, baolin.wang@linux.alibaba.com, linux-mm@kvack.org, linux-kernel@vger.kernel.org Subject: [PATCH] mm: vmscan: fix dirty folios throttling on cgroup v1 for MGLRU Date: Fri, 27 Mar 2026 18:21:08 +0800 Message-ID: <3445af0f09e8ca945492e052e82594f8c4f2e2f6.1774606060.git.baolin.wang@linux.alibaba.com> X-Mailer: git-send-email 2.47.3 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" 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. The following test program can easily reproduce the OOM issue. With this pa= tch applied, the test passes successfully. $mkdir /sys/fs/cgroup/memory/test $echo 256M > /sys/fs/cgroup/memory/test/memory.limit_in_bytes $echo $$ > /sys/fs/cgroup/memory/test/cgroup.procs $dd if=3D/dev/zero of=3D/mnt/data.bin bs=3D1M count=3D800 Fixes: ac35a4902374 ("mm: multi-gen LRU: minimal implementation") Reviewed-by: Barry Song Reviewed-by: Kairui Song Signed-off-by: Baolin Wang Acked-by: Johannes Weiner Acked-by: Shakeel Butt --- Changes from RFC: - Add the Fixes tag. - Add reviewed tag from Barry and Kairui. Thanks. --- mm/vmscan.c | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/mm/vmscan.c b/mm/vmscan.c index 46657d2cef42..b5fdad1444af 100644 --- a/mm/vmscan.c +++ b/mm/vmscan.c @@ -5036,9 +5036,24 @@ static bool try_to_shrink_lruvec(struct lruvec *lruv= ec, struct scan_control *sc) * If too many file cache in the coldest generation can't be evicted * due to being dirty, wake up the flusher. */ - if (sc->nr.unqueued_dirty && sc->nr.unqueued_dirty =3D=3D sc->nr.file_tak= en) + if (sc->nr.unqueued_dirty && sc->nr.unqueued_dirty =3D=3D sc->nr.file_tak= en) { + struct pglist_data *pgdat =3D lruvec_pgdat(lruvec); + wakeup_flusher_threads(WB_REASON_VMSCAN); =20 + /* + * For cgroupv1 dirty throttling is achieved by waking up + * the kernel flusher here and later waiting on folios + * which are in writeback to finish (see shrink_folio_list()). + * + * Flusher may not be able to issue writeback quickly + * enough for cgroupv1 writeback throttling to work + * on a large system. + */ + if (!writeback_throttling_sane(sc)) + reclaim_throttle(pgdat, VMSCAN_THROTTLE_WRITEBACK); + } + /* whether this lruvec should be rotated */ return nr_to_scan < 0; } --=20 2.47.3