From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 32320606A334 for ; Thu, 3 Dec 2026 20:17:10 +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 kanga.kvack.org (Postfix) id F10936B05B3; Thu, 3 Dec 2026 15:17:08 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id EE85B6B05B4; Thu, 3 Dec 2026 15:17:08 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id E260F6B05B5; Thu, 3 Dec 2026 15:17:08 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0017.hostedemail.com [216.40.44.17]) by kanga.kvack.org (Postfix) with ESMTP id ACDD76B05B3 for ; Thu, 3 Dec 2026 15:17:08 -0500 (EST) Received: from smtpin19.hostedemail.com (lb01a-stub [10.200.18.249]) by unirelay01.hostedemail.com (Postfix) with ESMTP id 409361C1DFC for ; Thu, 3 Dec 2026 20:17:08 +0000 (UTC) X-FDA: 85503780936.19.E20EC52 Received: from sea.source.kernel.org (sea.source.kernel.org [172.234.252.31]) by imf23.hostedemail.com (Postfix) with ESMTP id 74A7614000F for ; Thu, 3 Dec 2026 20:17:06 +0000 (UTC) Authentication-Results: imf23.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20260515 header.b=NWAWN68O; dmarc=pass (policy=quarantine) header.from=kernel.org; spf=pass (imf23.hostedemail.com: domain of sashiko-bot@kernel.org designates 172.234.252.31 as permitted sender) smtp.mailfrom=sashiko-bot@kernel.org ARC-Seal: i=1; a=rsa-sha256; d=hostedemail.com; s=arc-20220608; cv=none; t=1796329026; b=QLYD0KpmjFflkI5TUVwUTGjXZwtUV0lnmfI85J6NazmaIPdjznnjY6WHCQoq4rTSVpHGDY XS2NaiDDbD6GE2xjvNMWWRs5rRYpo7/ZCQkFUtNPODfBSAeanYVwLj+8NzKVOWCO+8X0UC OoZT1bqtP9wq2wvfrHaNNHlPbr1Jq1U= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1796329026; h=from:from:sender:reply-to:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=xYSBE2wrToo2Ukk6EdE42PV8Lcb4gfQzuGUsXAwqkQc=; b=KNa8Z6XsvITalUjfTVq9zgrUKpvvwlSerpWo9cKyukr3zJ5oVKGQwnsm0z+EBT3Of5iV2m phLUbIQd+4AR9UziOwcsXvH/nc7g6n6etK/HwjJ5Qd9+kt1qtIST9vNpK0idRe0xCH5yex pTqGI5fW3QQMSuX6llURuLxEADyWb0U= ARC-Authentication-Results: i=1; imf23.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20260515 header.b=NWAWN68O; dmarc=pass (policy=quarantine) header.from=kernel.org; spf=pass (imf23.hostedemail.com: domain of sashiko-bot@kernel.org designates 172.234.252.31 as permitted sender) smtp.mailfrom=sashiko-bot@kernel.org Received: from smtp.kernel.org (quasi.space.kernel.org [100.103.45.18]) by sea.source.kernel.org (Postfix) with ESMTP id 606B442470; Thu, 3 Dec 2026 20:17:05 +0000 (UTC) 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-Rspamd-Server: rspam02 X-Rspamd-Queue-Id: 74A7614000F X-Rspam-User: X-Stat-Signature: 39ysb8qnyag9sxx6rpa1edjhudrgeayd X-Spam-Status: No, score=-10.8 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_PASS,SPF_PASS autolearn=ham autolearn_force=no version=4.0.1 X-HE-Tag: 1796329026-33612 X-HE-Meta: U2FsdGVkX1+QqdvS69D5xwf4Y2ER6AKTZH8R+6OoCZ54msCbciA9nTrniC85Wc9WwQ0iA1iNz8SWxjS1ZMxoj4pL0l8LlW0wY43WRiKvGZnUM1mq8NKDO2UvOf4WgnNTomZNdf6ledA5TMfq/yTF5vTVlLbBVpHN1VYOtEBIPkVDMKg5ReASCVu2UlVUcy4NbnCQOSbTtlKDpi06tNBo8Q1QrU9XhJgJER3CEJdSww0eXpTRkmz8kUi0zFXWcZyC6oh88JSjIwXtYHqdwPrWLKBB/bvadNHg8xWKsNTLMMHJkF8O7pVW5IDrqnkXKrxWaWF7Vsec0R8NPue1XAANqQgqK5BgqCNv981Sn5xrbR3hj0K5JYxCbRCyA723x/jmbBq/7HyyokYL7DUOphDwfCoAEBIquTP6DN7XJ532peGizGJgLtDWh03RhqEIZDYYyoYPG53OTfaMBukHFcv60aBwjeG02HsdyMa/UEqErx0W9O0s4KOYgZgvpD5yy4imxNSjsrNKW6yHSnW/NHd7H3mssnYvkJfFVIWQlBTCqalqAXAYdrPk+i+KRdw5C3nKMx/s6Aenf5NT1v5ZNPPNJrQvLIl/pnLBhj3gCdDxjh79/rEKomLXaFFZYbW8i3aTeSWgvGCWowqQqbT48Pk/MIaDxk+NRAz699bgG8pu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rJi5kuXV+Y2HOYGzeci/5GDfweFNmXhWtG8NF6tuV1eX0LU9ArEyMQbfIUTrKRCtFdSWitCJvp+kVYpt8ZtC4UH5w9j3bqyw+dXFhbqOHVM1laTjaCYdYxCLMZPuTU+hQ906bg7W88FeBINDwoueW0uqXe10D8MamJqJJac44wqlI5AcufFWd71zr57Va14rIWb6CMSYU8np cbLwbB9X Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: List-Subscribe: X-Spam-Checker-Version: SpamAssassin 4.0.1 (2024-03-26) on aws-us-west-2-korg-listserv-alma10-1 X-Archived-By: 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