From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from out-189.mta1.migadu.com (out-189.mta1.migadu.com [95.215.58.189]) (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 D8EFF54652 for ; Wed, 1 Apr 2026 20:32:52 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=95.215.58.189 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1775075575; cv=none; b=qQ0ofbS9GUXlzDwPwcCrmca3dYQKLcAmn278th2BI0yqHvP7Gon2H3Srg4EhReQmAq3R5P7aGDmI0IYw1IyIBBe2XgzvbQSHF4WDZQBZjCjp2WAdvA1OZR35iR5viCFdlgZe7fzvgFd8PkVykyMZh4oxVDYBV69QolFB3xn7+9Q= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1775075575; c=relaxed/simple; bh=shdJzeCcxisD65qCh2rCw8PyBs7D0OOKmlQshjRoHt0=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=Ww1mKoMOK/pWxJIg0CFaCyOD7XA5AVyWpmJiU1lRHwUR5HNs6wkqrQO6GIg033MusFMQ6Ju90bBZjEHziwBcbEzrgk9v8iZ/PbwLT1W5Ka6yaRk24ftODHvyh522bfvENLz7ZbPK8KJC5Yeq/rB2hMGEQ46i6gx1n0os2Efs3lM= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.dev; spf=pass smtp.mailfrom=linux.dev; dkim=pass (1024-bit key) header.d=linux.dev header.i=@linux.dev header.b=leaPaYSm; arc=none smtp.client-ip=95.215.58.189 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.dev Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linux.dev Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linux.dev header.i=@linux.dev header.b="leaPaYSm" Date: Wed, 1 Apr 2026 13:32:40 -0700 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.dev; s=key1; t=1775075570; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=vg1qGD3qx7K/fSuaArorcBrvxHQxJiEvWr7E5KZsN8E=; b=leaPaYSmz2vEv7lc5Zpx3vd5Mj5O90XGj/bgb5NLS7Vsc6IlyA6siBBXKVwDqmwFnqM3n8 hXRfpcplhXCi/uc+53US1FqFRZw0P1svlG+IK9k8FHU0phLg6arC/Iom52z0Kh63anYDQ5 C6J6s31IId36Tvi+MQ1hq+BDBUDEaOQ= X-Report-Abuse: Please report any abuse attempt to abuse@migadu.com and include these headers. From: Shakeel Butt To: Baolin Wang 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 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: <3445af0f09e8ca945492e052e82594f8c4f2e2f6.1774606060.git.baolin.wang@linux.alibaba.com> X-Migadu-Flow: FLOW_OUT 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. This is v1 only and I don't care much but what is stopping you from moving away from v1? Acked-by: Shakeel Butt