From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from out30-130.freemail.mail.aliyun.com (out30-130.freemail.mail.aliyun.com [115.124.30.130]) (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 5FE303CF672 for ; Wed, 25 Mar 2026 11:55:24 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=115.124.30.130 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1774439727; cv=none; b=sIvCxoNsiTk5BZihp5zRAcmj9hb/5cgeznfdF04654WPHc4viRu4IWVB43SoKKOoY8Jmmzk0rzzLjtCsBYW4sbXfgVfJO6Qn72Ilat0SgvpowXRat9/EM1rHjzikReE6CXhGKns/itzovEqc/xYUUSv9zslEhr19zg0OFt7s1UE= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1774439727; c=relaxed/simple; bh=i7hsVXiIlEBmoBoSSTaQG9wSM3efX1S4fyu/hVvtaKo=; h=Message-ID:Date:MIME-Version:Subject:To:Cc:References:From: In-Reply-To:Content-Type; b=tODL30o4ltJEronFDYj3721yHdeffYXMhbNhfjDYVOrG0VLJN3wxyCdn9LmLqlsq7fSEdy7JMe8Z5XbbzkOStlqrghx+oQvQuQPAOvvq0/O3/kSDflIbnHZmhEtwEwvgBCTnolJJ4KrfzSVDUcps8YtHygGXxjbBtl8Y2p+D5vw= 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=o4VdGHqw; arc=none smtp.client-ip=115.124.30.130 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="o4VdGHqw" DKIM-Signature:v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.alibaba.com; s=default; t=1774439717; h=Message-ID:Date:MIME-Version:Subject:To:From:Content-Type; bh=NFydIvyPqRQVlTUEuEBJ9uTkhy12OC6V5ZYB4S4SRps=; b=o4VdGHqwX49K4mkw8fTDLASQmoIYzx4cSlD9DC3C55kPhcyIVxeUBj85cHK+ccruw+YqkAD6Jckksv2e/qGh1bcBAMcl4LxZsb39SiiI3/449bN95tI3cTPsxkV2f9LntrT9XBG1xsmWMJTUskiyq1/tJxHy6P13MsM00HlfraU= X-Alimail-AntiSpam:AC=PASS;BC=-1|-1;BR=01201311R161e4;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=14;SR=0;TI=SMTPD_---0X.hciev_1774439716; Received: from 30.42.98.36(mailfrom:baolin.wang@linux.alibaba.com fp:SMTPD_---0X.hciev_1774439716 cluster:ay36) by smtp.aliyun-inc.com; Wed, 25 Mar 2026 19:55:17 +0800 Message-ID: <67144c1a-1b63-4def-9471-59173cc4153e@linux.alibaba.com> Date: Wed, 25 Mar 2026 19:55:16 +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: [RFC PATCH] mm: vmscan: fix dirty folios throttling on cgroup v1 for MGLRU 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, baohua@kernel.org, kasong@tencent.com, linux-mm@kvack.org, linux-kernel@vger.kernel.org, "Lorenzo Stoakes (Oracle)" References: From: Baolin Wang In-Reply-To: Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit CC Lorenzo. (Sorry, Lorenzo. I switched to use your new email address, but forgot to CC you.) On 3/25/26 7:50 PM, 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 > > Signed-off-by: Baolin Wang > --- > mm/vmscan.c | 13 ++++++++++++- > 1 file changed, 12 insertions(+), 1 deletion(-) > > diff --git a/mm/vmscan.c b/mm/vmscan.c > index 33287ba4a500..a9648269fae8 100644 > --- a/mm/vmscan.c > +++ b/mm/vmscan.c > @@ -5036,9 +5036,20 @@ 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()). > + */ > + if (!writeback_throttling_sane(sc)) > + reclaim_throttle(pgdat, VMSCAN_THROTTLE_WRITEBACK); > + } > + > /* whether this lruvec should be rotated */ > return nr_to_scan < 0; > }