Re: [PATCH v3 10/14] mm/page-flags: introduce folio_test_fs_private()
From: David Hildenbrand (Arm)
Date: Tue Sep 08 2026 - 13:42:25 EST
On 9/8/26 04:56, Zi Yan wrote:
> folio_test_fs_private() wraps folio->private != NULL check and excludes
> swapcache and hugetlb folios, since swapcache uses swp_entry_t overlapping
> with folio->private and hugetlb sets its own flags in folio->private.
> Replace open code with the helper, since core MM does this check
> frequently.
>
> No functional change intended.
>
> Assisted-by: Claude:claude-opus-4-8
> Assisted-by: Codex:gpt-5
> Signed-off-by: Zi Yan <ziy@xxxxxxxxxx>
> To: Andrew Morton <akpm@xxxxxxxxxxxxxxxxxxxx>
> To: David Hildenbrand <david@xxxxxxxxxx>
> To: Steven Rostedt <rostedt@xxxxxxxxxxx>
> To: Masami Hiramatsu <mhiramat@xxxxxxxxxx>
> To: Lorenzo Stoakes <ljs@xxxxxxxxxx>
> Cc: "Liam R. Howlett" <liam@xxxxxxxxxxxxx>
> Cc: Vlastimil Babka <vbabka@xxxxxxxxxx>
> Cc: Mike Rapoport <rppt@xxxxxxxxxx>
> Cc: Suren Baghdasaryan <surenb@xxxxxxxxxx>
> Cc: Michal Hocko <mhocko@xxxxxxxx>
> Cc: Mathieu Desnoyers <mathieu.desnoyers@xxxxxxxxxxxx>
> Cc: Zi Yan <ziy@xxxxxxxxxx>
> Cc: Baolin Wang <baolin.wang@xxxxxxxxxxxxxxxxx>
> Cc: Nico Pache <nico.pache@xxxxxxxxx>
> Cc: Ryan Roberts <ryan.roberts@xxxxxxx>
> Cc: Dev Jain <dev.jain@xxxxxxx>
> Cc: Barry Song <baohua@xxxxxxxxxx>
> Cc: Lance Yang <lance.yang@xxxxxxxxx>
> Cc: Usama Arif <usama.arif@xxxxxxxxx>
> Cc: Matthew Brost <matthew.brost@xxxxxxxxx>
> Cc: Joshua Hahn <joshua.hahnjy@xxxxxxxxx>
> Cc: Rakie Kim <rakie.kim@xxxxxx>
> Cc: Byungchul Park <byungchul@xxxxxx>
> Cc: Gregory Price <gourry@xxxxxxxxxx>
> Cc: Ying Huang <ying.huang@xxxxxxxxxxxxxxxxx>
> Cc: Alistair Popple <apopple@xxxxxxxxxx>
> Cc: linux-kernel@xxxxxxxxxxxxxxx
> Cc: linux-fsdevel@xxxxxxxxxxxxxxx
> Cc: linux-mm@xxxxxxxxx
> Cc: linux-trace-kernel@xxxxxxxxxxxxxxx
> ---
> include/linux/mm.h | 4 +---
> include/linux/page-flags.h | 26 +++++++++++++++++++++++---
> include/trace/events/pagemap.h | 4 +---
> mm/huge_memory.c | 4 +---
> mm/migrate.c | 3 +--
> mm/page-writeback.c | 5 +----
> mm/vmscan.c | 3 +--
> 7 files changed, 29 insertions(+), 20 deletions(-)
>
> diff --git a/include/linux/mm.h b/include/linux/mm.h
> index 5eb8a62fafb56..c861525cda83f 100644
> --- a/include/linux/mm.h
> +++ b/include/linux/mm.h
> @@ -3053,9 +3053,7 @@ static inline int folio_expected_ref_count(const struct folio *folio)
> * One reference from filesystem private data.
> * Use data_race() since folio might not be locked.
> */
> - ref_count += data_race(folio_test_private(folio)) &&
> - !folio_test_hugetlb(folio) &&
> - !folio_test_swapbacked(folio);
> + ref_count += data_race(folio_test_fs_private(folio));
> }
Lol :) That's what I meant with folio_has_attached_private()
(I think I prefer that name as it matches folio_attach_private(), but I might be
biased ;) )
This really should be sqashed into the previous patch, OR, have a prep patch
that only replaces these instances and uses folio_test_private() until you
convert it to folio->private in the second patch.
In short: touch these call sites only once, not twice in a row.
--
Cheers,
David