From nobody Mon Apr 13 07:12:39 2026 Received: from outbound.st.icloud.com (p-east2-cluster5-host6-snip4-6.eps.apple.com [57.103.79.99]) (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 4FDC68F4A for ; Fri, 10 Apr 2026 12:44:23 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=57.103.79.99 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1775825064; cv=none; b=Oai/DuOuiFOrpWqPuwENpKlrLf9hX+q7z5OtAIyuPtOQ0ekCV5xLWOoBxI1K5/wqgKeR7OtUQ0abk22oXj5LD/NQnAC9oRjLW1nVPItlPBgl9KWeJQ5sjoYgQ+Xowq5QWp/h9Xl/SUDPQsqSTTtk8B7+8oU2psjCR1PA5dlI2UU= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1775825064; c=relaxed/simple; bh=tqh3vdlmNsT48tUHWGrESaIe4SZ64Y1OWUn3hKrdDcw=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=QD9PWVU4vDeyHnQ2/EdNmPczREwHqzCBTfLWpPfTxbpGGrvdxuVFLGmY+2rHIGhbG+z24iYgstLUe4oLoJPn1ftIJeIVLDm92gh7/U9whKPGLnmfakFXd+NXxyKh6KlPtNvnLDMroW20J02QZNRHJtlBd8tzucWch5lBATbAwxI= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=icloud.com; spf=pass smtp.mailfrom=icloud.com; dkim=pass (2048-bit key) header.d=icloud.com header.i=@icloud.com header.b=Bwbh/WpM; arc=none smtp.client-ip=57.103.79.99 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=icloud.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=icloud.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=icloud.com header.i=@icloud.com header.b="Bwbh/WpM" Received: from outbound.st.icloud.com (unknown [127.0.0.2]) by p00-icloudmta-asmtp-us-east-1a-100-percent-0 (Postfix) with ESMTPS id 05F991800370; Fri, 10 Apr 2026 12:44:18 +0000 (UTC) Dkim-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=icloud.com; s=1a1hai; t=1775825062; x=1778417062; bh=xnHQdlgcOL/4fk6OrbKqPiZnFKcP7FFawnir2OWjlBA=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:To:x-icloud-hme; b=Bwbh/WpMXu14l1eAf+6SpysHVgxbbXiWS9bo9Z//gBroQLPS8aTS62h/sarDCcBrJne3AGys38BrvIgbydxiOb7aAfGrnMc3Pt1f44J5pU+PYsfOv9uGD9v9NLwnddhnlCn9S6P1briLTnPwqSM+YrzZwuYztyHI0mqax+JW9Lbjie0AmGQim6Ue+ukaFBOaNF9LY3sfavIsohQ+cpgsvSKsDhjtt/LpXyAnap+qbwEY7t46UfGocrbYKVOzayk74ET/Am9gHS1+Lb2k0GlSMDuAqfOdeYIsPSVJjPOLjtEBkl/SwXwE7OUa/VMpOlYtxRhhOGaXa1HBFvIl5VtqCg== Received: from [21.6.122.162] (unknown [17.42.251.67]) by p00-icloudmta-asmtp-us-east-1a-100-percent-0 (Postfix) with ESMTPSA id 1BC7618002D9; Fri, 10 Apr 2026 12:44:11 +0000 (UTC) From: Zhang Peng Date: Fri, 10 Apr 2026 20:43:59 +0800 Subject: [PATCH v3 1/5] mm/vmscan: track reclaimed pages in reclaim_stat 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="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20260410-batch-tlb-flush-v3-1-ff0b9d3a351a@icloud.com> References: <20260410-batch-tlb-flush-v3-0-ff0b9d3a351a@icloud.com> In-Reply-To: <20260410-batch-tlb-flush-v3-0-ff0b9d3a351a@icloud.com> To: Andrew Morton , David Hildenbrand , Lorenzo Stoakes , "Liam R. Howlett" , Vlastimil Babka , Mike Rapoport , Suren Baghdasaryan , Michal Hocko , Johannes Weiner , Qi Zheng , Shakeel Butt , Axel Rasmussen , Yuanchu Xie , Wei Xu , Michal Hocko Cc: linux-mm@kvack.org, linux-kernel@vger.kernel.org, Kairui Song , Zhang Peng X-Mailer: b4 0.14.3 X-Developer-Signature: v=1; a=ed25519-sha256; t=1775825044; l=4784; i=zippermonkey@icloud.com; s=20260309; h=from:subject:message-id; bh=L4RSnGOlWbx1ob39I2cW9qTJxKxYSjJYIPZI0IE6F+E=; b=gQ9yLWGUxW517zEk1IQvsIrvKwskhHYXuieEWSNucHDUrXNZoYMUsoqxvdu9QG4YJ8utPTMaH nxzrqn2oSXJBbe8SlTaqo/SI2qppqjltR2eijdLF2P5/LITQ5LcTV3i X-Developer-Key: i=zippermonkey@icloud.com; a=ed25519; pk=tPCLpFnBfIyHsp0k7eaUTUREEa36bQNW/69X+NS8wBU= X-Proofpoint-ORIG-GUID: vaOzalWNA5dld2tRGp3kg27SWnVGxl2v X-Proofpoint-Spam-Details-Enc: AW1haW4tMjYwNDEwMDExNyBTYWx0ZWRfX2XHa8stvVtpF BPoMCkjTdv2QLkEvhwXsB0DDRj3wFo0+/JQa3rO+zlJtjFQMji893q2bvF08omGsoPYMs/f6Jzq py0b8c7zAyU9Pu+5xlAWH16EHH8uleRxDlYZpErHCitwpuRajSJG6sPpx5cfSVF+OM2pyp3ff81 GSOrdhgts6jvbyiHMNWapM8JJELSjGjEBFfyP/AcRj2N6Jkl+SedppnH8mOPfivW+I+Y15kNRFs l0eW7MB6l4hIUOY0HKcr9R0CqEL4iRj+LrB7maYqt4dXJ7ehaSEKDI+tLY+oPeKOGP4FUlv9dqK vydVwDlqgSSfIref8+Ah2xpOyPcP82NiOgRM7gd2y12DfTLswxZTDODfI3I83c= X-Authority-Info-Out: v=2.4 cv=V+ZwEOni c=1 sm=1 tr=0 ts=69d8f0a4 cx=c_apl:c_pps:t_out a=YrL12D//S6tul8v/L+6tKg==:117 a=YrL12D//S6tul8v/L+6tKg==:17 a=IkcTkHD0fZMA:10 a=A5OVakUREuEA:10 a=x7bEGLp0ZPQA:10 a=YE32fvk_ji8A:10 a=VkNPw1HP01LnGYTKEx00:22 a=GvQkQWPkAAAA:8 a=_Dbb_MnoW-ofl-KRMSEA:9 a=QEXdDO2ut3YA:10 a=J82S1U87d15UFHHUFZS8:22 a=R6HnoDE5lksTgPyyjrIf:22 X-Proofpoint-GUID: vaOzalWNA5dld2tRGp3kg27SWnVGxl2v X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1143,Hydra:6.1.51,FMLib:17.12.100.49 definitions=2026-04-10_03,2026-04-09_02,2025-10-01_01 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 mlxlogscore=999 spamscore=0 mlxscore=0 malwarescore=0 phishscore=0 adultscore=0 lowpriorityscore=0 clxscore=1015 suspectscore=0 bulkscore=0 classifier=spam authscore=0 adjust=0 reason=mlx scancount=1 engine=8.22.0-2601150000 definitions=main-2604100117 From: Zhang Peng shrink_folio_list() returns nr_reclaimed while all other statistics are reported via reclaim_stat. Add nr_reclaimed to reclaim_stat and change the function to void for a consistent interface. No functional change. Suggested-by: Kairui Song Signed-off-by: Zhang Peng --- include/linux/vmstat.h | 1 + mm/vmscan.c | 25 ++++++++++++++----------- 2 files changed, 15 insertions(+), 11 deletions(-) diff --git a/include/linux/vmstat.h b/include/linux/vmstat.h index 3c9c266cf782..f088c5641d99 100644 --- a/include/linux/vmstat.h +++ b/include/linux/vmstat.h @@ -26,6 +26,7 @@ struct reclaim_stat { unsigned nr_unmap_fail; unsigned nr_lazyfree_fail; unsigned nr_demoted; + unsigned nr_reclaimed; }; =20 /* Stat data for system wide items */ diff --git a/mm/vmscan.c b/mm/vmscan.c index 5ee64cf81378..f3f03a44042e 100644 --- a/mm/vmscan.c +++ b/mm/vmscan.c @@ -1053,9 +1053,9 @@ static bool may_enter_fs(struct folio *folio, gfp_t g= fp_mask) } =20 /* - * shrink_folio_list() returns the number of reclaimed pages + * Reclaimed folios are counted in stat->nr_reclaimed. */ -static unsigned int shrink_folio_list(struct list_head *folio_list, +static void shrink_folio_list(struct list_head *folio_list, struct pglist_data *pgdat, struct scan_control *sc, struct reclaim_stat *stat, bool ignore_references, struct mem_cgroup *memcg) @@ -1063,7 +1063,7 @@ static unsigned int shrink_folio_list(struct list_hea= d *folio_list, struct folio_batch free_folios; LIST_HEAD(ret_folios); LIST_HEAD(demote_folios); - unsigned int nr_reclaimed =3D 0, nr_demoted =3D 0; + unsigned int nr_demoted =3D 0; unsigned int pgactivate =3D 0; bool do_demote_pass; struct swap_iocb *plug =3D NULL; @@ -1477,7 +1477,7 @@ static unsigned int shrink_folio_list(struct list_hea= d *folio_list, * increment nr_reclaimed here (and * leave it off the LRU). */ - nr_reclaimed +=3D nr_pages; + stat->nr_reclaimed +=3D nr_pages; continue; } } @@ -1507,7 +1507,7 @@ static unsigned int shrink_folio_list(struct list_hea= d *folio_list, * Folio may get swapped out as a whole, need to account * all pages in it. */ - nr_reclaimed +=3D nr_pages; + stat->nr_reclaimed +=3D nr_pages; =20 folio_unqueue_deferred_split(folio); if (folio_batch_add(&free_folios, folio) =3D=3D 0) { @@ -1549,7 +1549,7 @@ static unsigned int shrink_folio_list(struct list_hea= d *folio_list, =20 /* Migrate folios selected for demotion */ nr_demoted =3D demote_folio_list(&demote_folios, pgdat, memcg); - nr_reclaimed +=3D nr_demoted; + stat->nr_reclaimed +=3D nr_demoted; stat->nr_demoted +=3D nr_demoted; /* Folios that could not be demoted are still in @demote_folios */ if (!list_empty(&demote_folios)) { @@ -1589,7 +1589,6 @@ static unsigned int shrink_folio_list(struct list_hea= d *folio_list, =20 if (plug) swap_write_unplug(plug); - return nr_reclaimed; } =20 unsigned int reclaim_clean_pages_from_list(struct zone *zone, @@ -1623,8 +1622,9 @@ unsigned int reclaim_clean_pages_from_list(struct zon= e *zone, * change in the future. */ noreclaim_flag =3D memalloc_noreclaim_save(); - nr_reclaimed =3D shrink_folio_list(&clean_folios, zone->zone_pgdat, &sc, + shrink_folio_list(&clean_folios, zone->zone_pgdat, &sc, &stat, true, NULL); + nr_reclaimed =3D stat.nr_reclaimed; memalloc_noreclaim_restore(noreclaim_flag); =20 list_splice(&clean_folios, folio_list); @@ -1992,8 +1992,9 @@ static unsigned long shrink_inactive_list(unsigned lo= ng nr_to_scan, if (nr_taken =3D=3D 0) return 0; =20 - nr_reclaimed =3D shrink_folio_list(&folio_list, pgdat, sc, &stat, false, + shrink_folio_list(&folio_list, pgdat, sc, &stat, false, lruvec_memcg(lruvec)); + nr_reclaimed =3D stat.nr_reclaimed; =20 move_folios_to_lru(&folio_list); =20 @@ -2168,7 +2169,8 @@ static unsigned int reclaim_folio_list(struct list_he= ad *folio_list, .no_demotion =3D 1, }; =20 - nr_reclaimed =3D shrink_folio_list(folio_list, pgdat, &sc, &stat, true, N= ULL); + shrink_folio_list(folio_list, pgdat, &sc, &stat, true, NULL); + nr_reclaimed =3D stat.nr_reclaimed; while (!list_empty(folio_list)) { folio =3D lru_to_folio(folio_list); list_del(&folio->lru); @@ -4862,7 +4864,8 @@ static int evict_folios(unsigned long nr_to_scan, str= uct lruvec *lruvec, if (list_empty(&list)) return scanned; retry: - reclaimed =3D shrink_folio_list(&list, pgdat, sc, &stat, false, memcg); + shrink_folio_list(&list, pgdat, sc, &stat, false, memcg); + reclaimed =3D stat.nr_reclaimed; sc->nr.unqueued_dirty +=3D stat.nr_unqueued_dirty; sc->nr_reclaimed +=3D reclaimed; trace_mm_vmscan_lru_shrink_inactive(pgdat->node_id, --=20 2.43.7