Re: [PATCH v3 1/2] mm: drop page refcount zero state semantics

From: Kiryl Shutsemau

Date: Thu Jun 04 2026 - 07:09:29 EST


On Thu, Jun 04, 2026 at 10:15:12AM +0000, ilya.gladyshev@xxxxxxxxx wrote:
> @@ -115,8 +120,14 @@ static inline void init_page_count(struct page *page)
> set_page_count(page, 1);
> }
>
> +static inline void set_page_count_as_frozen(struct page *page)
> +{
> + set_page_count(page, 0);
> +}
> +

This name is strange. Maybe something like init_page_count_frozen()?

And don't you want to update it in patch 2 to set the bit?

> static inline void page_ref_add(struct page *page, int nr)
> {
> + VM_BUG_ON(__page_count_is_frozen(page_count(page)));

Hm. These VM_BUG_ONs are useless after patch 2.

In patch 2, you make __page_count_is_frozen() check the frozen bit and
page_count() masks out frozen bit.

I guess you want to read raw ref number here, no?

And why not VM_BUG_ON_PAGE/FOLIO()?


> atomic_add(nr, &page->_refcount);
> if (page_ref_tracepoint_active(page_ref_mod))
> __page_ref_mod(page, nr);

--
Kiryl Shutsemau / Kirill A. Shutemov