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

From: ilya . gladyshev

Date: Thu Jun 04 2026 - 08:54:38 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()?

TBH I slightly dislike "init" in this naming, but it's probably better
than our proposal. Maybe set_page_count_frozen()?

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

My bad, apologies. Don't even know how it passed stress-tests...

> >
> > 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?

Yes, indeed. I will rewrite with __page_count_is_frozen(struct page *)

> And why not VM_BUG_ON_PAGE/FOLIO()?

Will change to those

> >
> > atomic_add(nr, &page->_refcount);
> > if (page_ref_tracepoint_active(page_ref_mod))
> > __page_ref_mod(page, nr);
> >
> --
> Kiryl Shutsemau / Kirill A. Shutemov
>