From nobody Fri Apr 3 00:00:52 2026 Received: from outbound.ci.icloud.com (ci-2006j-snip4-8.eps.apple.com [57.103.90.229]) (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 527323B960F for ; Thu, 26 Mar 2026 08:36:42 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=57.103.90.229 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1774514207; cv=none; b=DPDKtkrXtF6fIsSaqCZmWIHRc9Z3c/3OzGt3Vgzmu3hY1BLX+ftRFyjg0mHWAduuZyRDZhctrx8naiXszWHq9ng1Sek2r+TZK/iHOkNRXT/ch/DvgBEAmRYv7yolBah1JYXb+k1eG8aOkVOmxOJyrDfzYdxW7X9fPveScWGXOAw= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1774514207; c=relaxed/simple; bh=tqh3vdlmNsT48tUHWGrESaIe4SZ64Y1OWUn3hKrdDcw=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=mDYGCoBU8+NmkscAXTm2dup4raG5PROZKqpLre3jsySJeAvAI+dp6gd4RBZgN50F7xcONdM0G+7K+gNLg1EhQa6JbD4ZLOFoEkQHHz2ENTZcm8tnoCVpwnSB4ix2Hhirj3CJBsBUaCNZoqwHoB+vDaWZ6umcru9B3tQjsq6l5pw= 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=xv0llZso; arc=none smtp.client-ip=57.103.90.229 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="xv0llZso" Received: from outbound.ci.icloud.com (unknown [127.0.0.2]) by p00-icloudmta-asmtp-us-central-1k-100-percent-11 (Postfix) with ESMTPS id 0B238180010E; Thu, 26 Mar 2026 08:36:38 +0000 (UTC) Dkim-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=icloud.com; s=1a1hai; t=1774514201; x=1777106201; bh=xnHQdlgcOL/4fk6OrbKqPiZnFKcP7FFawnir2OWjlBA=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:To:x-icloud-hme; b=xv0llZso92roc6dajC0joL0IrCGYUWOmiaNYuBcCOkIvKjSgC4dRNIHAbkKorw2uVYG2agAW900AuFdKL06LXGTdMJRvpUn/CfNr2wuNVyxFvmKjclEg+F+K2NY/OndS62yUhg2E3q6mPTGs3Cr/ZHCffahLm1eq9HmerHgG+uznXg2jM31OW5pi2Y/PixWMnUTk+E3eP8cFcGf2TJpqz5jT/rCCnEFe+NKyjd2a/mykd9kHwT+DLsp4j7FGl8G9fgT96S60Vt/90xYKms/XpLLfY04yPzdNvw5HPu36x0afTMQgugERhhKzpq6GzkR0Y23Ia4TduBuxP4oVxheQGA== Received: from [21.6.122.162] (unknown [17.57.156.36]) by p00-icloudmta-asmtp-us-central-1k-100-percent-11 (Postfix) with ESMTPSA id 4B565180020C; Thu, 26 Mar 2026 08:36:33 +0000 (UTC) From: Zhang Peng Date: Thu, 26 Mar 2026 16:36:17 +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-403e523325c4@icloud.com> References: <20260326-batch-tlb-flush-v2-0-403e523325c4@icloud.com> In-Reply-To: <20260326-batch-tlb-flush-v2-0-403e523325c4@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=1774514187; l=4784; i=zippermonkey@icloud.com; s=20260309; h=from:subject:message-id; bh=L4RSnGOlWbx1ob39I2cW9qTJxKxYSjJYIPZI0IE6F+E=; b=2UV1ap/2XGBFOjlcc27PyZc1fCg3+tnRXSu6BT6jv0K3cIvJ26xjERomAh6jkgpWLeAH1rLK0 ySUc5HwZkDZDb6cRQcK74iUfnSbKqi3c2pFBSt+jf4wYfmgY2Kn6VGi X-Developer-Key: i=zippermonkey@icloud.com; a=ed25519; pk=tPCLpFnBfIyHsp0k7eaUTUREEa36bQNW/69X+NS8wBU= X-Proofpoint-GUID: rKqbL-ccvg4837RxPW9bvsrkbaBUYOvm X-Authority-Info-Out: v=2.4 cv=SONPlevH c=1 sm=1 tr=0 ts=69c4f018 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-Spam-Details-Enc: AW1haW4tMjYwMzI2MDA2MiBTYWx0ZWRfX9KnOKacCtdnj kuHp4ES2ft9H0ny5hcWJTUqgzRxXQ4Hcud1TTC2qe5eenz0nK/vy4xtjtZUNxNoAsnK9Lybsj9y UVexacLPeeuzFNen0DU+ZUMLnMzNpLXVk8yRejr3FDOnq2WfLdn7SRy1Te0GqNeFFbb3xa1krum 0Xh3AZKgc24e6Zbo5QjRkvanSOWHWbiUx5h0cd/DV1L4abYbRmDZ3gw00rJSQBL9h4iue/XdglK k4o5OHSpk6hrYgJcU1hSfj2LZi9YW1WlYRlmNm6A8NASMbAQ3L5wdVrj2rXrBhFI5IeCqDPwFOe jamXbCYEUyefgQh6bMpWatOtP7+jpVe1joFoAkx32ePhe2DivtW24ih4RgRzCM= X-Proofpoint-ORIG-GUID: rKqbL-ccvg4837RxPW9bvsrkbaBUYOvm 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 phishscore=0 mlxscore=0 bulkscore=0 mlxlogscore=999 lowpriorityscore=0 adultscore=0 clxscore=1015 suspectscore=0 spamscore=0 malwarescore=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