Re: [PATCH] mm/huge_memory: fix huge zero folio publication race

From: Andrew Morton

Date: Wed Jul 29 2026 - 21:08:58 EST


On Wed, 29 Jul 2026 08:44:12 +0200 "David Hildenbrand (Arm)" <david@xxxxxxxxxx> wrote:

> > --- a/mm/huge_memory.c
> > +++ b/mm/huge_memory.c
> > @@ -245,8 +245,11 @@ static bool get_huge_zero_folio(void)
> > }
> > WRITE_ONCE(huge_zero_pfn, folio_pfn(zero_folio));
> >
> > - /* We take additional reference here. It will be put back by shrinker */
> > - atomic_set(&huge_zero_refcount, 2);
> > + /*
> > + * Publish the folio and PFN before making them available to lockless
> > + * users. Pairs with a successful atomic_inc_not_zero() above.
> > + */
> > + atomic_set_release(&huge_zero_refcount, 2);
> > preempt_enable();
> > count_vm_event(THP_ZERO_PAGE_ALLOC);
> > return true;
>
> https://lore.kernel.org/r/20260728-fix-refcounted-huge-zero-v1-0-3f261f5447b4@xxxxxxxxxx

Does that actually fix the same thing?

Is so, Xueyuan's Fixes: is 97ae17497e99 ("thp: implement refcounting
for huge zero page"). Which to believe?