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=1796329025; b=ZLbAszjZeBZ9IfOx/D4UCY2UdFQb1Z9BvxrE3uShABTDob05pofcUe3kKMnbStn0KFVq vO7cg4vFi1Rg2ar/nkaetNMznOKAbl1EpIum5iROdGXfHBCPJCm41yxOcEsu5Ua8sPd4n b15hv6++TRXuFLuglNK4n5ka6sdsw0GVqBaCzBwJv6KumYmE2X63zx3BVGoZYGjgAl/E/ pOH8uh//TDnxJ1IWDg/WcujOdTOr3OrsZ7uxWjVqOIlh6x5td1ZpoLEBjlieKwUNrRL2w UrR3WlpleCXkp0mbw2iB3atnp2I1pfYZAwvzJ/i4d+jfj+lSAX3BQjo8P/IjMzVhE2g== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796329025; h=Received:DKIM-Signature:Message-ID:From:Subject:Reply-To:To:Cc: In-Reply-To:References:Content-Type:Content-Transfer-Encoding:Date; bh=xYSBE2wrToo2Ukk6EdE42PV8Lcb4gfQzuGUsXAwqkQc=; b=giC4BDh0jl7gGyH51mZiMlWiOXK3GkWYglQ6mOOa0mjIvujdCUsy5AyeZUgWDUZT4VkY RBFv3r661tAbMTlGpTf1XEyEfKq+DMRRIeAYxDp5QObC6SKI1ZcG+V3zJQH3P8y31sXFZ ma4D0YOecjJOm/EfimCXrizPxSGusIKQLhBVRnelWrLSjOT6XddYYPd0tnczp2hfSeR5U 3GZkwNYr/YGPAQ+7u1ObSfvDnlZwXkHqXDcoibjWkFyjsoutDpGSYdPGNCTyxGcQTq1VY gF8hQZpyvYjvHDnQioL9EewK1fzqy4kHbGRW2nWMeueFa9z8h+rXJZuU4KbhONcbVIA== 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=NWAWN68O; 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 A0D2B606A322 for ; Thu, 3 Dec 2026 20:17:05 +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=NWAWN68O Received: by smtp.kernel.org (Postfix) with ESMTPSA id 9519F1F000C2; Thu, 3 Dec 2026 20:17:01 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1796329025; bh=xYSBE2wrToo2Ukk6EdE42PV8Lcb4gfQzuGUsXAwqkQc=; h=From:Subject:Reply-To:To:Cc:In-Reply-To:References:Date; b=NWAWN68OQwlyhma/BCtCA35CeYfbnAtTT8Kj2ofejl3/AMJyILNwK3Az+gs+3euaA 5UfKjWy4thp54oB29Z3P/j9oWYqrnNVro20fgXTF2ZScDEyYDjtevtJlPPplKppPoV /UUfYiYEekFa1Nk5CoSoVHcae5i3TBIbr94+8OfZASaQi+PRV3hchlriXgjqvx+cYY 8KAcrzm1LOxXOaQVm3lSM4BrXQiCNC2LfyQ9fVGcTbIBdbOoeqS0ktPg5ZZmEwTdtl tswPZwMuIoNwz+zOfy7s4AAukpa2lG2QZr9gny7JuA98OSUB5DTF6YUdVyMtgGA33K 4GHGl71f/Ycag== Message-ID: From: sashiko-bot@kernel.org Subject: Re: [PATCH v8 08/19] mm/mglru: make folio lru referenced times count a generic API 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-8-64f81c876c15@tencent.com> References: <20261204-mglru-fg-v8-0-64f81c876c15@tencent.com> <20261204-mglru-fg-v8-8-64f81c876c15@tencent.com> Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Date: Thu, 03 Dec 2026 20:17:01 +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 3 potential issues to consider: - [Medium] mm: PG_workingset set before PG_uptodate in folio_migrate_flags() - [Medium] mm: /proc/kpageflags KPF_REFERENCED reports MGLRU refs parity - [Low] mm: unaddressed maintainer request to split MGLRU helpers out of mm_inline.h -- commit 1ce1bf59d4884a8811452eef49a607c737b4800b Author: Kairui Song mm/mglru: make folio lru referenced times count a generic API This commit makes the folio LRU refs helpers available regardless of CONFIG_LRU_GEN, moves the lru_gen_* helpers under CONFIG_LRU_GEN, and drops the separate PG_workingset copy from folio_migrate_flags() now that folio_migrate_lru_refs() copies it. > diff --git a/include/linux/mm_inline.h b/include/linux/mm_inline.h > index 3cdad5765b58d..1749cbddf1258 100644 > --- a/include/linux/mm_inline.h > +++ b/include/linux/mm_inline.h [ ... ] > @@ -228,7 +234,8 @@ static inline void lru_set_refs_flags(unsigned long *= flags, unsigned int refs) > *flags |=3D BIT(PG_referenced); > if (refs & BIT(1)) > *flags |=3D BIT(PG_workingset); > - *flags |=3D ((unsigned long)refs >> 2) << LRU_REFS_PGOFF; > + if (LRU_REFS_WIDTH) > + *flags |=3D ((unsigned long)refs >> 2) << LRU_REFS_PGOFF; > } [Severity: Medium] As reported by Lian Wang on RFC [1], does this leave /proc/kpageflags reporting the parity of the MGLRU refs count in KPF_REFERENCED instead of whether the folio was referenced? lru_set_refs_flags() encodes PG_referenced strictly as bit 0 of refs, so PG_referenced is clear whenever an MGLRU folio has refs equal to 2, 4, or 6. stable_page_flags() in fs/proc/page.c still copies raw PG_referenced directly to KPF_REFERENCED, misreporting those referenced folios as unreferenced to userspace tools such as page-types. Checking whether lru_get_refs_flags(k) is nonzero under CONFIG_LRU_GEN would preserve KPF_REFERENCED semantics. [ ... ] > +/** > + * folio_migrate_lru_refs - copy the reference state to a new folio > + * @new: the destination folio > + * @old: the source folio > + * > + * Transfer the reference state to @new during migration: the MGLRU > + * refs count, or PG_referenced and PG_workingset (bits 0-1 of the > + * encoding) for the active/inactive LRU. > + */ > +static inline void folio_migrate_lru_refs(struct folio *new, const struc= t folio *old) > { > - return lru_get_gen_flags(READ_ONCE(*const_folio_flags(folio, 0))); > + folio_set_lru_refs(new, folio_lru_refs(old)); > } [Severity: Low] As reported by David Hildenbrand (Arm) on v6 [2], this patch and the rest of the series still keep and expand the MGLRU and LRU-refs helpers in include/linux/mm_inline.h rather than splitting them out into a dedicated header as a prerequisite cleanup. mm/vmscan.h already has a CONFIG_LRU_GEN section, and all callers of folio_lru_gen(), lru_set_refs_flags(), lru_get_refs_flags(), folio_lru_refs(), folio_inc_lru_refs(), and folio_migrate_lru_refs() live under mm/. Should these helpers move out of include/linux/mm_inline.h before the later patches modify them, or is there maintainer agreement to defer the split to a follow-up series? [ ... ] > diff --git a/mm/migrate.c b/mm/migrate.c > index 96b66a272379f..f59dd50b3f229 100644 > --- a/mm/migrate.c > +++ b/mm/migrate.c > @@ -807,8 +807,6 @@ void folio_migrate_flags(struct folio *newfolio, stru= ct folio *folio) > folio_set_active(newfolio); > } else if (folio_test_clear_unevictable(folio)) > folio_set_unevictable(newfolio); > - if (folio_test_workingset(folio)) > - folio_set_workingset(newfolio); > if (folio_test_checked(folio)) > folio_set_checked(newfolio); > /* [Severity: Medium] Can moving the PG_workingset copy into folio_migrate_lru_refs() cause concurrent waiters on newfolio to falsely account migration as workingset thrashing and PSI memory stall? CPU0 (migration) CPU1 (reader / fault) __migrate_folio() __folio_migrate_mapping() xas_store(&xas, newfolio) local_irq_enable() folio_migrate_flags() folio_migrate_lru_refs() sets PG_workingset folio_wait_bit_common_timeout() !uptodate && workingset psi_memstall_enter() <-- false stall folio_mark_uptodate(newfolio) __folio_migrate_mapping() publishes newfolio into mapping->i_pages with PG_locked held and PG_uptodate clear, then re-enables interrupts before folio_migrate_flags() runs with preemption enabled. Previously PG_workingset was copied after folio_mark_uptodate(newfolio), whereas folio_migrate_lru_refs() now runs before it. A task blocking on PG_locked in folio_wait_bit_common_timeout() during that window sees !folio_test_uptodate(folio) && folio_test_workingset(folio) and charges delayacct_thrashing_start() and psi_memstall_enter() until migration unlocks newfolio. Calling folio_migrate_lru_refs() after folio_mark_uptodate(newfolio) would preserve the previous ordering. The comment above folio_migrate_lru_refs() in folio_migrate_flags() also still mentions only PG_referenced. [1] https://lore.kernel.org/r/20260804074935.99991-1-lianux.mm@gmail.com [2] https://lore.kernel.org/r/e85a2666-9722-420b-9a60-9d4251fc3d4c@kernel.o= rg --=20 Sashiko AI review =C2=B7 https://sashiko.dev/#/patchset/20261204-mglru-fg-v= 8-0-64f81c876c15@tencent.com?part=3D8