From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mta1.migadu.com (out-213.mta1.migadu.com [95.215.58.213]) (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 8179133B6C9 for ; Wed, 12 Aug 2026 03:11:37 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=95.215.58.213 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1786504300; cv=none; b=KjL8zZ6d7LtJT8VZdLWKw09Mocn9wo3NKiP4YrY2Ns7qwa9G+o32ZsZ3MrXUG35LeXw8vwpGC2YnvDBhwT0FohVqRx16mSfR+sTTdONmluU39/TWEWDkyzeIIwfeBJH27RBh50wrJ5KsqcITJBSDMvJLQpWqoixlVI++p4LE4WQ= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1786504300; c=relaxed/simple; bh=t86JxHziNoCkZyq9Kev8+A/YFqRdo1YCTbOIRVlOfTk=; h=MIME-Version:Date:Content-Type:From:Message-ID:Subject:To:Cc: In-Reply-To:References; b=FOXpdUK5ifEt9jPnKWvwSgvKDCcg6848nmIBKkgpijwlUveKeKunYnXhFAHql2doDzs0Q06CwjpaR5U3QWNUbGfmOB+cUsSZXjmgtAGdnPtS1MsUlWc/E3upgyK9GTNjIsUij4KdQwEDUwASLR/wiChzB5uztcxJaWTpaPJRcj4= 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=a8i42++q; arc=none smtp.client-ip=95.215.58.213 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="a8i42++q" X-Envelope-To: linux-kernel@vger.kernel.org DKIM-Signature: a=rsa-sha256; bh=t86JxHziNoCkZyq9Kev8+A/YFqRdo1YCTbOIRVlOfTk=; c=simple/simple; d=linux.dev; h=from:to:subject:date:message-id:mime-version:content-type; s=key1; t=1786504295; v=1; x=1787109095; b=a8i42++q6uToawNvM+PY+NuMQIQX31H/wPyF9Kh9jXVzmmtPqtRfVFFpZtccLp0zoA70A7p2 bnbNYUQZbxWI1Ia/dkUgWz9OlIdmZ+zSMWC1MI+i32A2lfdFOumHxIBze4oBimzSExCAevGe6QA Qp9B4JLJq9g62xPLGBJzKusg= X-Envelope-To: linux-kernel@vger.kernel.org Received: from webmail.migadu.com (2001:41d0:303:fc7a::) by mta10.migadu.com with ESMTPS id 38281a8b4824b520; Wed, 12 Aug 2026 03:11:35 +0000 Authentication-Results: mta10.migadu.com; none X-Migadu-Scanner: mta10.migadu.com Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Date: Wed, 12 Aug 2026 03:11:27 +0000 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable From: "Hui Zhu" Message-ID: TLS-Required: No Subject: Re: [PATCH] mm/vmscan: fix missing NR_ISOLATED counter update in MGLRU reclaim path To: "Kairui Song" Cc: "Andrew Morton" , "Kairui Song" , "Qi Zheng" , "Shakeel Butt" , "Barry Song" , "Axel Rasmussen" , "Yuanchu Xie" , "Wei Xu" , "Johannes Weiner" , "David Hildenbrand" , "Michal Hocko" , "Lorenzo Stoakes" , linux-mm@kvack.org, linux-kernel@vger.kernel.org, "Hui Zhu" In-Reply-To: References: <20260811071703.425097-1-hui.zhu@linux.dev> >=20 >=20On Tue, Aug 11, 2026 at 03:17:03PM +0800, Hui Zhu wrote: >=20 >=20>=20 >=20> From: Hui Zhu > >=20=20 >=20> The MGLRU evict_folios() isolates folios from the LRU without upda= ting > > NR_ISOLATED_ANON/FILE counters, unlike the legacy shrink_inactive_li= st() > > path. > > This causes compaction's too_many_isolated() check and the OOMkiller= to > > under-count isolated pages when MGLRU reclaim is active, potentially > > leading to unnecessary compaction attempts or incorrect OOM decision= s > > under memory pressure. > >=20 >=20This patch still doesn't cover the OOM problem, too_many_isolated is = not > used for MGLRU. I prefer to keep unifying them like what we did previou= sly > with writeback. I will address this in the v2. >=20 >=20It might work for compaction though, did you test it? I didn't test it, I just came to the conclusion through code analysis. isolate_migratepages_block() calls too_many_isolated() which reads NR_ISOLATED counters, and since MGLRU doesn't update them, th= e check may under-count isolated pages and fail to throttle when it should. >=20 >=20>=20 >=20> Add NR_ISOLATED counter updates in evict_folios(): increment after > > isolate_folios() and decrement after all retry passes complete, usin= g > > the original isolated count saved before retry. The current patch is based on mm-stable. I will rebase on mm-unstable and use the existing nr_isolated variable. Best, Hui > >=20=20 >=20> Signed-off-by: Hui Zhu > > --- > > mm/vmscan.c | 10 ++++++++++ > > 1 file changed, 10 insertions(+) > >=20=20 >=20> diff --git a/mm/vmscan.c b/mm/vmscan.c > > index bc324e37c5f1..723b513574b3 100644 > > --- a/mm/vmscan.c > > +++ b/mm/vmscan.c > > @@ -4817,6 +4817,7 @@ static int evict_folios(unsigned long nr_to_sc= an, struct lruvec *lruvec, > > struct lru_gen_mm_walk *walk; > > int scanned, reclaimed; > > int isolated =3D 0, type, type_scanned; > > + int isolated_orig =3D 0; > >=20 >=20The variable name looks a bit confusing, and what is your based commi= t? > In latest mm-unstable there is already a nr_isolated you can use. >