From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-pj1-f47.google.com (mail-pj1-f47.google.com [209.85.216.47]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id B548E23EA80 for ; Wed, 25 Mar 2026 13:36:00 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.216.47 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1774445762; cv=none; b=sFF5sAey1nmPwv2eJlN0iuVDIOJb1k5Ja4aXcNtGUSIAIDH2SOO3RkkDvbIB94/4Ujf0csWDW+ZA/9mvFnoUtBxxvDI/VVmOnyJaymtH+wO1EeiR5pS3cMCpYWR+2wP5pLhEmvvikZYHXLTHj/JAIHH8hPKFKJDpHPNLxqlYBac= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1774445762; c=relaxed/simple; bh=y8/HJHcTAinSwCyqQr/j+Riu2rF40uvQDMhTZ1nYqCA=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=sGZlnu402BChrFQ5wwGGMC2IZ9oSx98Pq0ks5telvIC7h63lFHMXV+e7iIGZsTY392p4lszs9iH99c5i70H9zgEC4/yWY80Ioq35Tr8eY1xdx6eglm6F5i5JlmAEgJDSdlLWcceIcazkVYgnWSIRiI3UkoKD798a9QK4ZJiHelk= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=D5lNxxJl; arc=none smtp.client-ip=209.85.216.47 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="D5lNxxJl" Received: by mail-pj1-f47.google.com with SMTP id 98e67ed59e1d1-35b98def50bso4651433a91.0 for ; Wed, 25 Mar 2026 06:36:00 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1774445760; x=1775050560; darn=vger.kernel.org; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:from:to:cc:subject:date:message-id:reply-to; bh=eThIFmdDZ6GA/TY9CLE+OYHs4lQLBCugx54z8nziAIY=; b=D5lNxxJlYrlsnJrWCA7CJcHJhhE5fBa71G9Wz2SukcqcPz5BRaprXl/MQEFRfmiomH GxdrIM9BOaRuX2U80DpYKySCaZFRyGCt0fzjGliGk+4MQP1Pyo8Gy0xsYw7Slo3lHPn3 jjCP4Y9XbWT8jZBmSnAEavr1TM6JuPdzNIk/5NvDZJWP5s7bEjH8IwEqDBKvDozuM6Gt r4kNZPc3fzxpyIQvvxlJ88K4WExnIkWyGe2QfkPYQcKQHsNnPGzEaCxQAGZem4beiM8w Klz9yTURJcKoIJ4AVFh9xjbQEy2xSU8KKJ66k5LIHYEScwvjSRbjShJd+4GA2FedX4AT XGLQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1774445760; x=1775050560; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:x-gm-gg:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=eThIFmdDZ6GA/TY9CLE+OYHs4lQLBCugx54z8nziAIY=; b=UItlPUaokNmgT8+jBJ5YgyvnxXqxQqBvnNbVqaSFm/v8nyuY3MZrvKxo326NDh9gqF QL6SoWkcP+3oZ2bLC3JAa6dngojfSlvSQ/pys72Ni7kqf43kiIepSC5pDSRbqykhax0n icuSMAzpdaWhax51u1Z8qZXPbJpxMwhLWVPkZXqIRCX07qEzoY2wsyM3boLshgxybLnE OhIVPDtlROaD84Io7Y6CuHNIjKQXHIw8+xA2wsUItKU7Vr5CdINNdz2EvzefoOO+y4FN Mo9jgRbefzTcPlQM4F2wEAh8rM6VC9Xz01XuLQb5M4SMAwVWe+QhXTOEDWFeziKqHCVf PQeA== X-Forwarded-Encrypted: i=1; AJvYcCXxkgGEPHu1SJjGlyLbntSJRcZ/ypRMqqzjLwZjqgj4gxbS8VPmMjYpLiI/hraaSHiLKMBgFZkX4EZWRns=@vger.kernel.org X-Gm-Message-State: AOJu0YyBGdEu6KPfVb40gSECxfDqsWJWMLiOq7s4qjPHq9u0S6r5H18B XRchJdKZ1JMyE1y9qxJC/ydB2NvftnYbAPDR2DIYvodhGz6pCDHl/C76 X-Gm-Gg: ATEYQzz69eN3i6OEpNVFG1qbS/D8k0WrOf87cJrOjrKIMft0rmVyPqG7CWf7fjZbv9/ eCl73nYzuqTjrYiM9aZQxZfmrCAf1IhN1PWY13L9y82yBHat1LQZbZ3dA526k4t74rQHbC5HESD T0fcLvI+mx0nvSf3DDPuBkdF8AOTFaiNxkUi6THwNmtRMO8QMMpbOO9qKGgJiF7JCjv6Wcinrqt OwEzeF6yRdkmBEUKOcDDiSrn3eyi9DRmGNcidODtox3ybxW8nFlIdjyYtPdyzpptXv/3gUzBV2R gThiJ3srqf6H75s+BcdLeQ0/+HOCFNq+xQBGDPnvMuf2DR3ZRwU0mZn+E4iQZ+o4ssMzKvDtGyY hqqr1a8DExyQYnoHqbr7LryH4mhKg/lLJsA53HKx1GEialgdFMiVTyYxKaZnr9q5+nvJ94YFQe1 SOKEeghi7G/wfo/6sJL/TXXGVImy0j6DikzFo4FBmzSsTCQczlpeAYgeZNz4cAB7qKJcye+w== X-Received: by 2002:a17:90b:3890:b0:359:8c89:96d3 with SMTP id 98e67ed59e1d1-35c0dcea990mr3617911a91.15.1774445760047; Wed, 25 Mar 2026 06:36:00 -0700 (PDT) Received: from KASONG-MC4 ([101.32.222.185]) by smtp.gmail.com with ESMTPSA id 98e67ed59e1d1-35c03044d04sm7798070a91.0.2026.03.25.06.35.55 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 25 Mar 2026 06:35:59 -0700 (PDT) Date: Wed, 25 Mar 2026 21:35:52 +0800 From: Kairui Song To: Baolin Wang Cc: akpm@linux-foundation.org, hannes@cmpxchg.org, 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)" Subject: Re: [RFC PATCH] mm: vmscan: fix dirty folios throttling on cgroup v1 for MGLRU Message-ID: References: Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: On Wed, Mar 25, 2026 at 09:20:55PM +0800, Baolin Wang wrote: > Hi Kairui, > > On 3/25/26 8:07 PM, Kairui Song wrote: > > On Wed, Mar 25, 2026 at 07:50:40PM +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 > > > > > > 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; > > > } > > > > Hi Baolin > > > > Interesting I want to fix this too, after or with: > > https://lore.kernel.org/linux-mm/20260318-mglru-reclaim-v1-0-2c46f9eb0508@tencent.com/ > > Thanks for taking a look. > > > > > With current fix you posted, MGLRU's dirty throttling is still > > a bit different from active / inactive LRU. In fact MGLRU > > treat dirty folios quite differently causing many other issues too, > > e.g. it's much more likely for dirty folios to stuck at the tail > > for MGLRU so simply apply the throttling could cause too > > aggressive throttling. Or batch is too large to trigger the > > throttling. > > Thanks for sharing this. Hi Baolin, > > > So I'm planning to add below patch to V2 of that series (also this > > is suggested by Ridong), how do you think? There are several > > other throttling things to be fixed too, more than just the > > V1 support. I can have your suggested-by too. > > But I still think this fix deserves its own commit, because this is indeed > fixing a real issue that I ran into. Even if the throttling isn't perfect > for cgroup v1, it aligns with the legacy-LRU behavior and is essential to > avoid premature OOMs firstly. MGLRU dirty folio handling improvement can be > done as a separate optimization in your series. > > Anyway, let's also wait for more feedback from others. > Sure, fixing this first is fine to me, just saying that you may still see unexpected throttling or ineffective throttling with this. This is no conflict between these two approach. I can rebase that series on top of yours, and that series would help to solve the rest of issues.