From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-pf1-f182.google.com (mail-pf1-f182.google.com [209.85.210.182]) (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 EDE0D2367DF for ; Thu, 2 Apr 2026 02:44:26 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.210.182 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1775097868; cv=none; b=FqOKis079tWgKvXrSCkKgiKAP71BGM5wGRCjTTvi/2bHCqgmVYotCGzqkYTuHWvuAIch8wSWM7ST4oK06RXZCRCUYwDuCW3YH3StvPq3NAgK6ANBfEHWr2WgDimCE8SJLUe1PfWHRdZQCAkPRCLg1GA6txvl0xGF+5SYQwe/fos= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1775097868; c=relaxed/simple; bh=3y4Xwae04f2L5sjNUZrOKaLmi5E27Jd3weMM/Gdz5CY=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=dEmEwifHIL4rIRiyE0nssbHktG6uL7XIoyOMdKsU8pmSkqiCyJg+cG9WfIg07MqystV5j/VSwv2n6FPCItITp3VGKeKpAbNTws+X3zS97WQiP2SYDbz3eZbjTEsWrRBaiqTmwoSuTHU/eElD188SHyS5b/pY5GDCKAgnFl/lG/k= 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=HHf51P8B; arc=none smtp.client-ip=209.85.210.182 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="HHf51P8B" Received: by mail-pf1-f182.google.com with SMTP id d2e1a72fcca58-827270d50d4so354344b3a.3 for ; Wed, 01 Apr 2026 19:44:26 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1775097866; x=1775702666; 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=ac06C/bkaz63cj4mi6CGIZnecILBcucCVZHeS3ed2uE=; b=HHf51P8BOaj6I4nf4SRNRoYr+l5cbrmE4GctDtP7ZuGrPpsTxC9vSGyfgNWTEnlZ80 B3Ufi+itYtsNQAXjpbqJ/DcBq7K0FKhBQV4u6sr3py0dX6zCi8KXryZVksTWr4QlRys1 Kzp41DuyTZVDTFLuXLYNSIYXUu5TrijGmvmG7YPh6BNvdygd2Y0MlyOddJbflK/QPN4F 9TRV37lVeG5V53ekTm3DeEUEUMiCGV4yRmTbY1Kw1qwko35b3id9aEwHDEj7UCy7eYxz maKA8xLg3wkTxTGkj6pw5Ffx0TyEI8SGC+if4JwIhdxS04hK4EhmOWHut7cfVW09tOhS JqqA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1775097866; x=1775702666; 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=ac06C/bkaz63cj4mi6CGIZnecILBcucCVZHeS3ed2uE=; b=BeKyibecxloGGn2AbvCIhMKf6fyV2kP21GdpHSvAIKxb5FfeenQ6lW1XFh7Vegv3tc qrpWG2Zz8veRuPNehr7uz8RM4ZC3hOV7MmsL9yMkOy/C80hNyUhpduP9wuazgRiz0fjn X5IVYTjZ+Tou7kkBCl2R4d4pUQduJ5n+7LCISSl0gTWjR8KOPJ1259AOWKqpUwAhWxRR P1tAXb/c8F9+h7LaslFBMB7gZmxZsVL/tRrVi+MCQmFgjW3jXaQLq+jyKzXdFOBQW6uS l//19kL+NOzjrsmidZWFryUrOeEM7NXJvijngnYRZYP0COyOUoyN4R0nlQ0OyxEu3LtB uh5w== X-Forwarded-Encrypted: i=1; AJvYcCWkoidJq+WA5VxMcS3vCjGg2tR9hioMmu9wpqYj4yu2rNJUYrENCqcitqbDAJoaFzUPu5uAwa/D/XRIGbs=@vger.kernel.org X-Gm-Message-State: AOJu0YwbxC6LiA2ZC7Arm9m5AYO2tN8pptnranD/EHgMxfeGAxu0/9tW azvLR1dvPC5HF9nH+a3i4Sn/bCikzBdexVihJLRk8Lb1XoHsO4uezG8D X-Gm-Gg: ATEYQzy1sSHIXoNtD2IrzyCSnJeEf1wb+ttHFoMGa83XYZ7IcI6kouU3TP/e895eJIe qRnTtVj1d/tIldc4ymM7j8EFO08S7/KgCSoZ4gcZY6c6KN4EUcDNvfye6w3yHnByQ8Cjbxq//vv MA/NaXEBAGuuqHmz12iJ+JTlfaOEuPfiRkW7+OeCsOaCNCyWr2bPes0+KBavwF7eTCYT2c3fI3V zYjTVT+uwHnlNsdTCAWuiZl0etY0vRFTB5u1u5ZbAMsR63AP3OjpP24v41UtV0gsxII4pVzJ0QG PVsLwPodiuYjwkwAN5+72UcHOCiPbygVIBuiZlGWX/kWd4fA1AjDROGG6SNuYcaE+fs+S156T7s CG+dWKSbz8cc76C7G6v8Xk3bAUxS4HIH+BTg1k4u0odGBDS/ZoPiQoJPzzDQlASKcAoqVsy3r05 RbKQ+ZJ4fBMlbFX/ulf4Dt29XD/5e16xPAsqQe3hW2V58USqJviAHF8DCc1K5qpG7ltRKS X-Received: by 2002:a05:6a00:2e94:b0:829:6f37:158a with SMTP id d2e1a72fcca58-82ce88e4f64mr6184763b3a.18.1775097866176; Wed, 01 Apr 2026 19:44:26 -0700 (PDT) Received: from KASONG-MC4 ([43.132.141.25]) by smtp.gmail.com with ESMTPSA id d2e1a72fcca58-82cf9b2443dsm1570003b3a.4.2026.04.01.19.44.22 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 01 Apr 2026 19:44:25 -0700 (PDT) Date: Thu, 2 Apr 2026 10:44:20 +0800 From: Kairui Song To: Shakeel Butt Cc: Baolin Wang , 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 Subject: Re: [PATCH] mm: vmscan: fix dirty folios throttling on cgroup v1 for MGLRU Message-ID: References: <3445af0f09e8ca945492e052e82594f8c4f2e2f6.1774606060.git.baolin.wang@linux.alibaba.com> 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, 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. > > 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.