Re: [PATCH v5 10/17] mm/page-flags: check page/folio->private instead of PG_private
From: David Hildenbrand (Arm)
Date: Mon Sep 21 2026 - 05:29:05 EST
On 9/21/26 04:28, Zi Yan wrote:
> After the changes of the prior commits, page/folio->private != NULL is now
> equivalent to checking PG_private.
>
> Stop checking PG_private on pages and folios and use page/folio->private
> instead, except swapcache and hugetlb folios, because the former uses a
> field (swp_entry_t swap) overlapping with ->private and the latter sets its
> flags in ->private. Exclude swapcache and hugetlb when the code is meant to
> check PG_private only. PG_swapcache and folio->swap.val cannot be set/clear
> as a whole, so excluding swapcache with folio_test_swapcache() is not
> reliable. Instead, use folio_test_swapbacked(), since PG_swapbacked is
> stable when a folio is added to/removed from swapcache. Add a helper,
> folio_has_attached_private(), for this check.
>
> folio_test_private() and PagePrivate() now read folio/page->private plainly
> instead of an atomic read of PG_private bit, so KCSAN complains about
> possible data races. Annotate them with data_race().
>
> folio_expected_ref_count() can be called without the folio lock, so
> annotate folio->mapping with data_race() while at it.
>
> folio_set/clear_private() and Set/ClearPagePrivate() become no-ops.
> PG_private is no longer checked at page free time. They will be removed in
> an upcoming commit.
>
> Remove KPF_PRIVATE since PG_private is no longer used.
>
Acked-by: David Hildenbrand (Arm) <david@xxxxxxxxxx>
--
Cheers,
David