From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=100.103.45.18 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796157078; b=CZWNIwcB04BfIEiDBwWuap2SZUguS1oMEIW+OQsUusdOilloFXUVkpyi30f1ubsseuY6 GWiOiQOVQdG24W8Euxmy55itpZpVBoWCkV0tgs8Hn/Xx6JaF9MDhutwvlenACeUwuF7xu pY7GFHoYuyNn47AT81ViMkiU0j6oSfw7241mr9RzQVDmX4e5uHb3exEeeyGhvejpZ5rf0 OwY2h4DewkwOF7QXqbWh7pfPy1p3T3K91osL54U5FlWR6DxE93pd+tWjA+AFzA72vJYa9 O+2cceOX6mNVbrmTmzdd/AUIVuSc+0YyDnbcgj+8FTFvxrYKboVGReKjNRm2ii4kFmw== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796157078; h=Received:DKIM-Signature:Message-ID:From:Subject:Reply-To:To:Cc: In-Reply-To:References:Content-Type:Content-Transfer-Encoding:Date; bh=3BZDjM5CE4AsvtGdq7qqp9VaLDh/hgjcMJHDvHFNsM8=; b=0A7xE8dScmhIMjcgiPIazgvx9RSzurjVcBh1qzyIf4yjAgqYEWrwUms53cUsNcaQkYuA irLOdPvCjtUGOGoostmyudSERMH0TeDT8IHKVDFcjV71Ftp4ncCojbGFtQrJeFVI4BUlr 8EkSGOAHcWAc7czBDFbyMHRVEiGEzx4ZSDW+PBE1Zl5SCzu0cNtq+nnAiSNOFuyrwkyQ5 wIeWEtPmWLjpuKTn4UxF/d8Ji8oAK2Vcx8wfv+QcRSxeCOu7E6xrFo+7uhXQ7xWXcaeoL 0eGz8bsMVmNwMrszcrkEEuG8WLxHNuu7qiLuzRjtzuzMQqeFQCXNgYqdEL+eLJ5isuA== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=Gx2yZf7y; arc=none smtp.remote-ip=100.103.45.18 Received: from smtp.kernel.org (quasi.space.kernel.org [100.103.45.18]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 8090B606A31A for ; Tue, 1 Dec 2026 20:31:18 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=Gx2yZf7y Received: by smtp.kernel.org (Postfix) with ESMTPSA id 28B881F00893; Tue, 1 Dec 2026 20:31:16 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1796157077; bh=3BZDjM5CE4AsvtGdq7qqp9VaLDh/hgjcMJHDvHFNsM8=; h=From:Subject:Reply-To:To:Cc:In-Reply-To:References:Date; b=Gx2yZf7y+8yHpaGYjguk+BpMVWx/qJIyPCrV/Y5n3go7Y7lV/GmlAeWYU38JqfJ4r tE1j55EsbqVRRbo3WGj1AjhaLDF9YNceVjIJWCwpm0/MTRjd0p6eJ38EpG6vdbIMxX hO5Jql3DWc/zlpbSyOxOpOPjdWWjSA28JQRlBG2Ode0XWONTgjVtFBXbiPUIEDTdlC HNduxpSJWNqsCO6Tg1KyejnZwqiSdx1/ijq+as8lssofCtKvKSbpyojp2mlU+LpBsO bWJcveWqiCXV3pR88HosptW7yBkeXYCCEXlXdNYknSAEFY2luvDB1Fwjl4I6vuWYy7 Smd1BhpJgu81w== Message-ID: From: sashiko-bot@kernel.org Subject: Re: [PATCH v7 14/19] mm/madvise: adapt for LRU refs based operations for MGLRU Reply-To: sashiko-reviews@lists.linux.dev To: "Kairui Song" , linux-mm@kvack.org Cc: "Andrew Morton" , "Johannes Weiner" , "Muchun Song" , "Qi Zheng" , "Ying Huang" , "Chris Li" , "Baoquan He" , "Nico Pache" , "Usama Arif" , "Michal Hocko" , "Roman Gushchin" , "Shakeel Butt" , "David Hildenbrand" , "Lorenzo Stoakes" , "Liam R. Howlett" , "Barry Song" , "Axel Rasmussen" , "Yuanchu Xie" , "Wei Xu" , "Vlastimil Babka" , "Suren Baghdasaryan" , "Nhat Pham" , "Youngjun Park" , "Zi Yan" , "Gregory Price" , =?utf-8?b?TWF0dGhldyBXaWxjb3ggKE9yYWNsZSk=?= , "Baolin Wang" , "Ryan Roberts" , "Dev Jain" , "Lance Yang" , "Hugh Dickins" , "SJ Park" , "David Rientjes" , "Yu Zhao" , "Vernon Yang" , "Zicheng Wang" , "Tal Zussman" , "Kairui Song" , "Xiang Liu" , "Ehab Ababneh" , "Zhao Zhenzhuo" , "Lian Wang" , "Joanne Koong" , "Kunwu Chan" , "Hui Zhu" , "Maxim Muzafarov" , "Tianyi Chen" , damon@lists.linux.dev, "Ridong Chen" , tj@kernel.org, mkoutny@suse.com In-Reply-To: <20261202-mglru-fg-v7-14-5965a96d86d0@tencent.com> References: <20261202-mglru-fg-v7-0-5965a96d86d0@tencent.com> <20261202-mglru-fg-v7-14-5965a96d86d0@tencent.com> Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Date: Tue, 01 Dec 2026 20:31:15 +0000 X-Mailing-List: damon@lists.linux.dev List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list Thank you for your contribution! Sashiko AI review found 1 potential issue to consider: - [Low] mm/madvise: open-coded LRU and MGLRU ref manipulation in mm/madvise.c -- commit afb8e93f4729e4e9ddecb1a2901862b67ca1c853 Author: Kairui Song mm/madvise: adapt for LRU refs based operations for MGLRU This commit introduces madvise_cold_prep_folio() and madvise_pageout_prep_folio() in mm/madvise.c so that MADV_COLD and MADV_PAGEOUT update folio LRU reference counts and workingset state appropriately for both classical LRU and MGLRU. > diff --git a/mm/madvise.c b/mm/madvise.c > index 66600e82605c2..c6c2e8189f4b1 100644 > --- a/mm/madvise.c > +++ b/mm/madvise.c > @@ -359,6 +359,38 @@ static inline int madvise_folio_pte_batch(unsigned l= ong addr, unsigned long end, > FPB_MERGE_YOUNG_DIRTY); > } > =20 > +static void madvise_cold_prep_folio(struct folio *folio) > +{ > + /* > + * For the active/inactive LRU, a folio demoted out of the active > + * list should have PG_workingset so its refault is still accounted > + * as a workingset refault, and the referenced bit always needs to > + * be cleared even for inactive folios. For MGLRU, MADV_COLD clears > + * refs in folio_deactivate(); MADV_PAGEOUT handles refs after isolatio= n. > + */ > + if (!lru_gen_enabled()) { > + folio_clear_lru_refs(folio); > + if (folio_test_active(folio)) > + folio_set_workingset(folio); > + } else { > + folio_test_clear_young(folio); > + } > +} > + > +static void madvise_pageout_prep_folio(struct folio *folio) > +{ > + unsigned int refs =3D folio_lru_refs(folio); > + > + /* > + * For MGLRU, clear refs below LRU_REFS_WORKINGSET and cap > + * the rest at it: MADV suggests the folio is cold, so the eviction sha= dow > + * should not record its hotness in the high tier counters, but > + * the workingset classification is preserved for PSI. > + */ > + if (lru_gen_enabled()) > + folio_set_lru_refs(folio, refs >=3D LRU_REFS_WORKINGSET ? LRU_REFS_WOR= KINGSET : 0); > +} [Severity: Low] As reported by David Hildenbrand (Arm) on v6 [1], can the LRU and MGLRU reference, workingset, and young state handling in madvise_cold_prep_folio() and madvise_pageout_prep_folio() be moved into folio or reclaim helpers so mm/madvise.c does not have to branch on lru_gen_enabled() and manipulate LRU internals directly? [1] https://lore.kernel.org/r/fe08f69a-0e62-4e4c-b87f-d4f3f9fb2a0b@kernel.o= rg --=20 Sashiko AI review =C2=B7 https://sashiko.dev/#/patchset/20261202-mglru-fg-v= 7-0-5965a96d86d0@tencent.com?part=3D14