From nobody Mon Apr 13 07:12:28 2026 Received: from outbound.st.icloud.com (p-east2-cluster5-host7-snip4-10.eps.apple.com [57.103.79.33]) (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 0B4202236F0 for ; Fri, 10 Apr 2026 12:44:27 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=57.103.79.33 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1775825069; cv=none; b=Vn/eLCQG5xYvvxUnOxrrh58g5Qyf/nvTsQBpY2Wm1rlY7wTwnOqymHpQMYVnVfYU7vtwnYZ7bQE3+y27Dp9z/aXRS/whTbXkjSFBCfMcNwjxUThEc3sjHSiIpgpC+nBiYY98EHIzPVX/o5TTByjsZ3zyblZs5yDvwRTPSQ+DBsM= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1775825069; c=relaxed/simple; bh=o0V0zHRuokKFdrTmqqx9vAI1MOcEwIIWKgzyYz0MNDI=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=eJkuYHYMN2r3z6l49mP2F0bEl8PW+nW7Wn76GcDwMYqN8OW9Z9VfIRYHqBLjIgba9nuCpK2ZLKGdLwEafoFfPQxuqg1WrmrVosC0Fj+jDRmrZL7ukaGrchqXWWzZWXD44lkPuzq2F2YmjtxJ1uAXHdHGjjwBRPD4UHZFz9hEq/c= 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=NggYHnO4; arc=none smtp.client-ip=57.103.79.33 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="NggYHnO4" 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 D5BA7180035C; Fri, 10 Apr 2026 12:44:23 +0000 (UTC) Dkim-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=icloud.com; s=1a1hai; t=1775825067; x=1778417067; bh=W+PRHeM3s2DI2yQOSrDPnTDvHR27Fnjgpu54ajqjWKM=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:To:x-icloud-hme; b=NggYHnO4sCFiWf2yFeD6rksIwDpSw5yxCxi26nNqpz/6DmfEeQq/s5yQcbpafCjC3u86NGruNIuxFFxBEfUNrqff969cVpMFeNg9kffWOjSeA2WVFu6R8LCRCc+ktl7hBGCS9QDJZ2+Nt+i+dDtwFwKl2DsS3t384wx51BwUZxlXXb2FqUgTohxH1MztHwR7mUYqWjC+rv8yc7ytntwh2uopoly7RtFbyb/dWdn7hJZbSLq7O6pNmB6SHfHIpX4tIdUUdDS4BzBD1rQGXfjB2LilghNGYo/JpZE4yuACanaONuMVhzLqiR2SmNtWsOUCWrUw2KKOPlclStY7gQpg/Q== 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 D257B180036C; Fri, 10 Apr 2026 12:44:18 +0000 (UTC) From: Zhang Peng Date: Fri, 10 Apr 2026 20:44:00 +0800 Subject: [PATCH v3 2/5] mm/vmscan: extract folio activation into folio_active_bounce() 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-2-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=2167; i=zippermonkey@icloud.com; s=20260309; h=from:subject:message-id; bh=MwBPaFWPFTZ2m6kdtZRGEvS5uyMpPolk6vIxczHd7KA=; b=XuRAinfERZ2Os9psc4BxOrW2+d/eB2893MURTJHmBehjAGSD2yk28pf6dvlnr4MR8QpkWRk0C GkBfS5+/tOUDxEzBpWDrzBUO114U9QSuMrOTttn1auf5zpTB3m/Ornh X-Developer-Key: i=zippermonkey@icloud.com; a=ed25519; pk=tPCLpFnBfIyHsp0k7eaUTUREEa36bQNW/69X+NS8wBU= X-Proofpoint-GUID: 7VQ5o_7CxGS7jTlLb2DDTJXiqvZ-pwy7 X-Proofpoint-ORIG-GUID: 7VQ5o_7CxGS7jTlLb2DDTJXiqvZ-pwy7 X-Authority-Info-Out: v=2.4 cv=edowvrEH c=1 sm=1 tr=0 ts=69d8f0a9 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=tUYT8qNuPuMAWAmJffYA:9 a=QEXdDO2ut3YA:10 a=J82S1U87d15UFHHUFZS8:22 a=R6HnoDE5lksTgPyyjrIf:22 X-Proofpoint-Spam-Details-Enc: AW1haW4tMjYwNDEwMDExOSBTYWx0ZWRfX4/cDOcCkKePu 3FbeuyWGTLWr3SZ7vWpug4GM8Fri06MlOfPZODbyqIWdMcBlEiIGf4a18bKniQ62gHVcvmH4WOF XUry12O/5NkMvgTyC3m+lgbxWUMwtGYo6eybPYHiawvEhREp/WWgEgMBifHtY4dFmzEziIm5/Fq r5Al2wsZ6ahvImQcmgTuxj98XI0qe+27gJq/hxcQDdHBxSuNbxc54k5j/ZrhDQw7NPIHBXGJxvT wDxlaE8pykTgfcnx1jBRqDi/Ul9zpZzxHSB5HjdgRlyZfYtusprajOnPPXd1+ANt6WAP0LVxis/ jAGmtSYsy9TtW5nWurst4XbEI/cx2909BdT4wpl/cPLEpTKg1SShGzvMEuSbvA= 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 suspectscore=0 lowpriorityscore=0 adultscore=0 mlxscore=0 phishscore=0 clxscore=1015 malwarescore=0 spamscore=0 bulkscore=0 mlxlogscore=999 classifier=spam authscore=0 adjust=0 reason=mlx scancount=1 engine=8.22.0-2601150000 definitions=main-2604100119 From: Zhang Peng The activate_locked label in shrink_folio_list() handles swap cache reclaim, marks the folio active, and updates activation statistics. Extract this block into folio_active_bounce() to make shrink_folio_list() easier to follow. No functional change Suggested-by: Kairui Song Signed-off-by: Zhang Peng --- mm/vmscan.c | 30 +++++++++++++++++++----------- 1 file changed, 19 insertions(+), 11 deletions(-) diff --git a/mm/vmscan.c b/mm/vmscan.c index f3f03a44042e..0860a48d5bf3 100644 --- a/mm/vmscan.c +++ b/mm/vmscan.c @@ -1052,6 +1052,24 @@ static bool may_enter_fs(struct folio *folio, gfp_t = gfp_mask) return !data_race(folio_swap_flags(folio) & SWP_FS_OPS); } =20 +/* Mark folio as active and prepare to bounce back to head of LRU */ +static void folio_active_bounce(struct folio *folio, struct reclaim_stat *= stat, + unsigned int nr_pages) +{ + /* Not a candidate for swapping, so reclaim swap space. */ + if (folio_test_swapcache(folio) && + (mem_cgroup_swap_full(folio) || folio_test_mlocked(folio))) + folio_free_swap(folio); + VM_BUG_ON_FOLIO(folio_test_active(folio), folio); + if (!folio_test_mlocked(folio)) { + int type =3D folio_is_file_lru(folio); + + folio_set_active(folio); + stat->nr_activate[type] +=3D nr_pages; + count_memcg_folio_events(folio, PGACTIVATE, nr_pages); + } +} + /* * Reclaimed folios are counted in stat->nr_reclaimed. */ @@ -1527,17 +1545,7 @@ static void shrink_folio_list(struct list_head *foli= o_list, nr_pages =3D 1; } activate_locked: - /* Not a candidate for swapping, so reclaim swap space. */ - if (folio_test_swapcache(folio) && - (mem_cgroup_swap_full(folio) || folio_test_mlocked(folio))) - folio_free_swap(folio); - VM_BUG_ON_FOLIO(folio_test_active(folio), folio); - if (!folio_test_mlocked(folio)) { - int type =3D folio_is_file_lru(folio); - folio_set_active(folio); - stat->nr_activate[type] +=3D nr_pages; - count_memcg_folio_events(folio, PGACTIVATE, nr_pages); - } + folio_active_bounce(folio, stat, nr_pages); keep_locked: folio_unlock(folio); keep: --=20 2.43.7