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=1796332854; b=Lbc43hC5iVOnxQKWud4obQGnIZOLocSpYUujpPriFjsGgn9wNLhx7yIEFFH5vtE0yIop 45sDqJWFlNaBnjLG5D2u7PbncKhYlywFt0zFCWytXyalnKM3nHO1dzijpbak4SW9lvb3A Y2GW7Q+BD76Zf9FPVqjUKFsL0kTgBE2gGdsUpEgZj/voaBTVRyl5s/gZaAlgKFO8XWg32 +yVhIscqYLdEdVFTVjIm09l/HK0YsxjlmzKEP30S0p1IyfCW8hV8Cs37KG2TOaWy64io3 d9EzxXlWjChknZBhOEBlVXJZO+ynbi95IR5+JeP73WUYWvktsYwKBIUhh6tIYod5WZQ== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796332854; h=Received:DKIM-Signature:Message-ID:From:Subject:Reply-To:To:Cc: In-Reply-To:References:Content-Type:Content-Transfer-Encoding:Date; bh=iyNt9q2jgFAvv+ssxRpCSWB9Jils8OkCwSiXj6SozZ0=; b=huHLPQRFlDt3tai0a7K89YwkD8zfytE+1V+nBNa1Jd4rXtRelTpwekvFWmC8/nTUqLfD fWEl2jnNSDEWaIdhDCt12ntQHSi6uA2qfEZu6qA3NcGNrotu9gcMfek8dqzVE6lMDYq+S H2MyqcFY3GEUnUkDJ/6dTmihHPpcg4KHTqr5ev7t5lTIrkZOYAvAMpczlMgm0knOMPf7e BZNgS0rDgpzQ7P2BAyzj3gdsGq1Y/4+WELLX8sSZArTxrYYN5bCwZKWPvPODWR+y2h7gS p4ewoAOvkzffB7ZLePQEJ5XEBJ3ZCP+I2/m97L7rV6XefUdq8j4bb+7uGR2RZYOKQEw== 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=cUzRQofG; 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 BCF52606A322 for ; Thu, 3 Dec 2026 21:20:54 +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=cUzRQofG Received: by smtp.kernel.org (Postfix) with ESMTPSA id 970821F000CE; Thu, 3 Dec 2026 21:20:52 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1796332854; bh=iyNt9q2jgFAvv+ssxRpCSWB9Jils8OkCwSiXj6SozZ0=; h=From:Subject:Reply-To:To:Cc:In-Reply-To:References:Date; b=cUzRQofGIjQZALx3APMexvKalLCf+2Neq5tylYHE1p50mfLhmXvQ4pfAeh8BFqrvi ZwjgFI/oMr7/57FVY/bK+hGLNGnBQBk2NGqgLKo1rYGSfSiHKMb+b5mUKNynRS0EEz tfaddD2ADoLTGtkFSsU2lU9/3vFoQUM/SDdVq/EdBqaWGM3gngTbEW0OxrAOsoXPug ceZkdFzGmjwUfMlipISYwKS6NMXg2BDD9DDpbHoTY78bsk8qSSJRj8jnlBWs48Vni/ b89T+W/MjR9bVym2QZ1VXl9P/+V6wu0Cv2ku6QmdXE6Gm6cYiYk7fhy63O1tcxJJSC dY2/0gYkEWCNA== Message-ID: From: sashiko-bot@kernel.org Subject: Re: [PATCH v8 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 Zhengzhuo" , "Lian Wang" , "Joanne Koong" , "Kunwu Chan" , "Hui Zhu" , "Maxim Muzafarov" , "Tianyi Chen" , "Aveline Noir" , damon@lists.linux.dev, "Ridong Chen" , tj@kernel.org, mkoutny@suse.com In-Reply-To: <20261204-mglru-fg-v8-14-64f81c876c15@tencent.com> References: <20261204-mglru-fg-v8-0-64f81c876c15@tencent.com> <20261204-mglru-fg-v8-14-64f81c876c15@tencent.com> Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Date: Thu, 03 Dec 2026 21:20:52 +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 fc7c744a30464213e9e1a5e43f610a1bb8e8a4d7 Author: Kairui Song mm/madvise: adapt for LRU refs based operations for MGLRU This commit adds madvise_cold_prep_folio() and madvise_pageout_prep_folio() to update folio young, workingset, and LRU reference state for both the active/inactive LRU and MGLRU during MADV_COLD and MADV_PAGEOUT. > diff --git a/mm/madvise.c b/mm/madvise.c > index 227f1c759668c..28ffaf921e9f0 100644 > --- a/mm/madvise.c > +++ b/mm/madvise.c > @@ -368,6 +368,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 updates in madvise_cold_prep_folio() and madvise_pageout_prep_folio() be moved into folio or reclaim helpers? Branching on lru_gen_enabled() and manipulating folio_lru_refs(), folio_set_lru_refs(), and LRU_REFS_WORKINGSET directly couples mm/madvise.c to MGLRU internals that otherwise stay inside LRU and reclaim code. [1] https://lore.kernel.org/r/fe08f69a-0e62-4e4c-b87f-d4f3f9fb2a0b@kernel.o= rg --=20 Sashiko AI review =C2=B7 https://sashiko.dev/#/patchset/20261204-mglru-fg-v= 8-0-64f81c876c15@tencent.com?part=3D14