From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from out-177.mta0.migadu.com (out-177.mta0.migadu.com [91.218.175.177]) (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 368F81DED5B for ; Tue, 11 Aug 2026 07:17:43 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=91.218.175.177 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1786432664; cv=none; b=DHqZY4UqwHtBTvKhjSmRYoSp7OiIIlK0NEnXua8wjAkGUpeBWu46BnqLj7mtkFu8VpfaIh9Yc/uXrfFMmnT3qj2ZS8Un7d06Uo0okP+zxanqBkiYf4QuEODly+GB1eQoy+nFBIYyjka4dQyIbCP2PWwW7GDukI5lK4djNrF1xd0= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1786432664; c=relaxed/simple; bh=t98rBtUE+YStet2j3kz0kARyS2GbzCyuE7KEG4BsUS0=; h=From:To:Cc:Subject:Date:Message-ID:MIME-Version; b=t9KX5AQ5LjEy3kYzitkreIFHkPxBh/q5AgF+KxV+HIVato6oNY3/Shpyxq23Tb6GHFc6oXgBklETogxHiSzrUkPPVbSu7C0aPaYQdTEmvvYEziB1CboiPyDd/5DqtNvS1i9cU859S5EGkBzC5/uzyzFluDe48g6fcMMliaAeXXU= 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=whoONuDu; arc=none smtp.client-ip=91.218.175.177 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="whoONuDu" X-Report-Abuse: Please report any abuse attempt to abuse@migadu.com and include these headers. DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.dev; s=key1; t=1786432660; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding; bh=DFqAUEtZlp1HILfzDd0oPsCphQU6caRSwneCZ/ZFUY4=; b=whoONuDu4SqWYGhHUyluEz9yRLfR/ZXL/2SKmsZWb8CiowXhfuaJ05TsqP0GPl0HeYApFg T8W7wP99yuX1co/MxBRGF6n2pjSB3PUq7Rh3Fux4PaXPua3fAvhAXInWyH8CZ4eAcNI71/ dc38iPAJf9F1Uj0vZwgaMWar4Qk3zAA= From: "Hui Zhu" To: 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 Cc: Hui Zhu Subject: [PATCH] mm/vmscan: fix missing NR_ISOLATED counter update in MGLRU reclaim path Date: Tue, 11 Aug 2026 15:17:03 +0800 Message-ID: <20260811071703.425097-1-hui.zhu@linux.dev> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Migadu-Flow: FLOW_OUT From: Hui Zhu The MGLRU evict_folios() isolates folios from the LRU without updating NR_ISOLATED_ANON/FILE counters, unlike the legacy shrink_inactive_list() 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 decisions under memory pressure. Add NR_ISOLATED counter updates in evict_folios(): increment after isolate_folios() and decrement after all retry passes complete, using the original isolated count saved before retry. Signed-off-by: Hui Zhu --- mm/vmscan.c | 10 ++++++++++ 1 file changed, 10 insertions(+) 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_scan, struct lruvec *lruvec, struct lru_gen_mm_walk *walk; int scanned, reclaimed; int isolated = 0, type, type_scanned; + int isolated_orig = 0; bool skip_retry = false; struct mem_cgroup *memcg = lruvec_memcg(lruvec); struct pglist_data *pgdat = lruvec_pgdat(lruvec); @@ -4829,6 +4830,11 @@ static int evict_folios(unsigned long nr_to_scan, struct lruvec *lruvec, scanned = isolate_folios(nr_to_scan, lruvec, sc, swappiness, &list, &isolated, &type, &type_scanned); + isolated_orig = isolated; + if (isolated) + __mod_node_page_state(pgdat, NR_ISOLATED_ANON + type, + isolated); + /* Scanning may have emptied the oldest gen, flush it */ if (scanned) try_to_inc_min_seq(lruvec, swappiness); @@ -4891,6 +4897,10 @@ static int evict_folios(unsigned long nr_to_scan, struct lruvec *lruvec, goto retry; } + if (isolated_orig) + mod_node_page_state(pgdat, NR_ISOLATED_ANON + type, + -isolated_orig); + return scanned; } -- 2.53.0