From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from out30-111.freemail.mail.aliyun.com (out30-111.freemail.mail.aliyun.com [115.124.30.111]) (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 0E0BA329395 for ; Thu, 2 Apr 2026 02:51:47 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=115.124.30.111 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1775098311; cv=none; b=pposiPNu9gk3rOlRnSSX2LjNCKEopRZjHSvCCPpuxL5TqcFp3fCbn8t4+aPA6cM6kAKBSl0aJgWG7vPV0MRSy0hmaMP0EotkUqaAvWBW2czZKF8BOgL+IkJMKBnr67wQDgUvuqDPphU8qyb+WehEeVR1o/G1d9UdGKBi8Ttw6OI= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1775098311; c=relaxed/simple; bh=IVGugMbmZBr3c0sR6IXFPaRxrIBR2C5p5R7fasZxOCw=; h=Message-ID:Date:MIME-Version:Subject:To:Cc:References:From: In-Reply-To:Content-Type; b=u/Icjx6C2nArC8sfP1aziuVnmvs+blBG4v4uulIpoDqIM9D6xYGtNUnqN1DnlHQPA9W1XLZdr8Jyd5fEM9xAG3K4lXBQ7vVkM21HEDks0jD7ZBDxkz9eYvWaMnJwL+fma0NDFmyj3odjhKVQe6DqIHvOZojZEXJqp382w/HuL78= 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=RPGZDBq2; arc=none smtp.client-ip=115.124.30.111 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="RPGZDBq2" DKIM-Signature:v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.alibaba.com; s=default; t=1775098305; h=Message-ID:Date:MIME-Version:Subject:To:From:Content-Type; bh=O6TOWg+Xh5sI9yRDwt9IDvK3x1ZitgasY/GSlaC7Tuw=; b=RPGZDBq2qdefQLpg+OZxgegxatDEKtKZ6bcgd7CBIbUza67fMPhr7J36K9F0wNh+nSKN4j8d9S7xNeLPpz4idkU5FpDv/DG+abiqWrdEh5Z7NNwX9hhtKeKsSAmneOu0GPpCgkx7U+oqiDCjuVMQPjm7huWDQph0wfzpxZvsFBc= X-Alimail-AntiSpam:AC=PASS;BC=-1|-1;BR=01201311R201e4;CH=green;DM=||false|;DS=||;FP=0|-1|-1|-1|0|-1|-1|-1;HT=maildocker-contentspam033045133197;MF=baolin.wang@linux.alibaba.com;NM=1;PH=DS;RN=16;SR=0;TI=SMTPD_---0X0FcMEl_1775098302; Received: from 30.74.144.121(mailfrom:baolin.wang@linux.alibaba.com fp:SMTPD_---0X0FcMEl_1775098302 cluster:ay36) by smtp.aliyun-inc.com; Thu, 02 Apr 2026 10:51:43 +0800 Message-ID: <0498d924-d76a-4d82-8767-e6297442967a@linux.alibaba.com> Date: Thu, 2 Apr 2026 10:51:37 +0800 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH] mm: vmscan: fix dirty folios throttling on cgroup v1 for MGLRU To: Kairui Song , Shakeel Butt Cc: akpm@linux-foundation.org, hannes@cmpxchg.org, david@kernel.org, mhocko@kernel.org, zhengqi.arch@bytedance.com, axelrasmussen@google.com, yuanchu@google.com, weixugc@google.com, ljs@kernel.org, baohua@kernel.org, kasong@tencent.com, linux-mm@kvack.org, linux-kernel@vger.kernel.org, Jingxiang Zeng References: <3445af0f09e8ca945492e052e82594f8c4f2e2f6.1774606060.git.baolin.wang@linux.alibaba.com> From: Baolin Wang In-Reply-To: Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit On 4/2/26 10:44 AM, Kairui Song wrote: > On Wed, Apr 01, 2026 at 01:32:40PM +0800, Shakeel Butt 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. >>> >>> The following test program can easily reproduce the OOM issue. With this patch >>> 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=/dev/zero of=/mnt/data.bin bs=1M count=800 >>> >>> Fixes: ac35a4902374 ("mm: multi-gen LRU: minimal implementation") >>> Reviewed-by: Barry Song >>> Reviewed-by: Kairui Song >>> Signed-off-by: Baolin Wang >>> --- >>> 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 *lruvec, 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 == sc->nr.file_taken) >>> + if (sc->nr.unqueued_dirty && sc->nr.unqueued_dirty == sc->nr.file_taken) { >>> + struct pglist_data *pgdat = lruvec_pgdat(lruvec); >>> + >>> wakeup_flusher_threads(WB_REASON_VMSCAN); >>> >>> + /* >>> + * 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); >> >> This seems fine but note that this throttling is not really the same as the >> throttling happening for traditional LRU. In traditional LRU, the kernel may >> throttle much more due to throttling check happening at each batch within >> shrink_inactive_list() while here the check is happening after full scan for the >> given memcg's lruvec. So, throttling can be much more aggressive for traditional >> LRU. > > Right, I think Baolin's fix is great, but to improve the whole trottling > mechanism we need some rework for MGLRU, currently I posted another > series for this. Agree. As both Shakeel and Johannes mentioned, I think we still need to unify the throttling in shrink_node(). That said, Kairui’s series is much improved over before and I haven’t observed any premature OOM issues so far from my testing. >> This is v1 only and I don't care much but what is stopping you from moving away >> from v1? > > For example memsw? > > https://lore.kernel.org/linux-mm/q2x4drxpjbxcxgns6bjp446ynsxgl32ckcljqcol7posds4nit@3n3tjq35anvb/ > > I remember Jingxiang's plan is to improve the page counter first. Additionally, we still have some existing users on cgroup v1, and they will need some time to migrate to cgroup v2.