From nobody Fri Apr 3 00:00:13 2026 Received: from outbound.ci.icloud.com (ci-2001l-snip4-7.eps.apple.com [57.103.91.120]) (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 005A6341062 for ; Thu, 26 Mar 2026 08:36:00 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=57.103.91.120 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1774514163; cv=none; b=u514OG5ndevNSC/VHwuWBK66XItElfFW1pG6ndLTjtWnNc1Es7YM4JEz0YxwmfJJjqa9SxDE+0SH1oC0C9zOaVuVQZi0aXwP/GMl8v0X6ea56opSYUXUWSsXxms5IUC8xGirsf5w78KjPEokJ8zMmBPpEuz0Fod9bTxwYG91e8s= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1774514163; c=relaxed/simple; bh=tqh3vdlmNsT48tUHWGrESaIe4SZ64Y1OWUn3hKrdDcw=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=XZog2N58ZhmnkjotRgNq18TmYHT4e20ifO5/rv7zdJHkDQYhpMip9yVmD+z53x+NkPpZeGpRFYV5BWGdWnLz0RejDRJHwrASkAOmiWAsGSXni8L4xPMGf1YLtNCgHUNy5oNFu3IGVaFeOOxGeWam8Cng6ZhmJ1shBfdDsBWLHWA= 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=Aj2oJ36O; arc=none smtp.client-ip=57.103.91.120 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="Aj2oJ36O" Received: from outbound.ci.icloud.com (unknown [127.0.0.2]) by p00-icloudmta-asmtp-us-central-1k-60-percent-5 (Postfix) with ESMTPS id 959FF1800334; Thu, 26 Mar 2026 08:35:56 +0000 (UTC) Dkim-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=icloud.com; s=1a1hai; t=1774514159; x=1777106159; bh=xnHQdlgcOL/4fk6OrbKqPiZnFKcP7FFawnir2OWjlBA=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:To:x-icloud-hme; b=Aj2oJ36Oa8STaZhy+ZlxoljrnBpK5q4yqOoxBOey5ztWp9e08tvEKnLOEZKkOu+sJ6b0ZcmOBoH/fN8Wv/Jcv9m0mU9HtRx92yKW/nhXB9zoGJ+l8LqifjE2acdCz1AHO6EOpvlEi5kLvJ/o0TIAjHoWXjoIxXbhoBGqe1IrL/o34gKXTZXfTUFJHAGDOlBw03QB5894GHOgVbW/WmN0rLwEDOS9Ajr04bRenBRINvN+e4oXwt2PcG76NzFWoRLJpqBCwp7UIur6f1FkW8PEY92dDRz+xf9UAC5XcgbBqt7M+bPeq0O/ESEwf6ajJk4xrDVXA3jj/OP0OZXsxi2cRA== Received: from [21.6.122.162] (unknown [17.57.156.36]) by p00-icloudmta-asmtp-us-central-1k-60-percent-5 (Postfix) with ESMTPSA id 73B1C1800335; Thu, 26 Mar 2026 08:35:51 +0000 (UTC) From: Zhang Peng Date: Thu, 26 Mar 2026 16:35:34 +0800 Subject: [PATCH v2 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: <20260326-batch-tlb-flush-v2-1-989ba60f970d@icloud.com> References: <20260326-batch-tlb-flush-v2-0-989ba60f970d@icloud.com> In-Reply-To: <20260326-batch-tlb-flush-v2-0-989ba60f970d@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=1774514145; l=4784; i=zippermonkey@icloud.com; s=20260309; h=from:subject:message-id; bh=L4RSnGOlWbx1ob39I2cW9qTJxKxYSjJYIPZI0IE6F+E=; b=5mK3faRwaQf6T9pJYCHo8hKEEXw/Vn8JHfr0/PR6cQzeIZlEa/fmvoMM2U+AkPtOOvi7+4Lyi xLjHYlvRlGoDmSc6lQ2b6EcuVAMtURo/b0d+Flc0cnneBWRweqN3o1K X-Developer-Key: i=zippermonkey@icloud.com; a=ed25519; pk=tPCLpFnBfIyHsp0k7eaUTUREEa36bQNW/69X+NS8wBU= X-Proofpoint-GUID: pVimxRQurKr82CmE_GQpIQ7Lord4Eqq1 X-Proofpoint-Spam-Details-Enc: AW1haW4tMjYwMzI2MDA2MiBTYWx0ZWRfX5/7rx9XrGfxx PD1dWLBMFQFI7P7RWMk0WPcmovs69DuUvvD3oF/PSNjH/BGZlzVWeTlb8yCHBRJtjEjNfyiH2yy Hj99Uhx5MwK770V9uOpa8u0yfVDIpuDqAvpgcVF15qgWoQfYzTDN8nutKSgSb1GmJjDaiBMSMcp REeS6662kMUZu9RaCwHP+QX/nPtjX7xY+v0N4/YJaEZwFEIokPPNJSvS5Ne59MKIyToGXLMk2rM 90Ojh4la3RVorSLgxfvIO5xfMv83xihVi6yo9RYopU/1o3ydV1mK/RZMQXPUpPEn/pBOJtPjTy0 9uS6KGkfsQEJ5VmtdQEPSt7/J1qVbDBDZD9WxmbqSnVCAa1RXufExnfaWrUTfc= X-Proofpoint-ORIG-GUID: pVimxRQurKr82CmE_GQpIQ7Lord4Eqq1 X-Authority-Info-Out: v=2.4 cv=Op1CCi/t c=1 sm=1 tr=0 ts=69c4efed cx=c_apl:c_pps:t_out a=2G65uMN5HjSv0sBfM2Yj2w==:117 a=2G65uMN5HjSv0sBfM2Yj2w==:17 a=IkcTkHD0fZMA:10 a=Yq5XynenixoA: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-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1143,Hydra:6.1.51,FMLib:17.12.100.49 definitions=2026-03-26_02,2026-03-24_01,2025-10-01_01 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 lowpriorityscore=0 malwarescore=0 bulkscore=0 phishscore=0 adultscore=0 mlxscore=0 suspectscore=0 clxscore=1015 mlxlogscore=999 spamscore=0 classifier=spam authscore=0 adjust=0 reason=mlx scancount=1 engine=8.22.0-2601150000 definitions=main-2603260062 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