Re: [PATCHv4 09/14] mm/hugetlb: Remove fake head pages
From: Kiryl Shutsemau
Date: Tue Jan 27 2026 - 10:00:01 EST
On Thu, Jan 22, 2026 at 03:00:03PM +0800, Muchun Song wrote:
> > + if (pfn)
> > + return pfn_to_page(pfn);
> > +
> > + tail = alloc_pages_node(node, GFP_KERNEL | __GFP_ZERO, 0);
> > + if (!tail)
> > + return NULL;
> > +
> > + p = page_to_virt(tail);
> > + for (int i = 0; i < PAGE_SIZE / sizeof(struct page); i++)
> > + prep_compound_tail(p + i, NULL, order);
> > +
> > + spin_lock(&hugetlb_lock);
>
> hugetlb_lock is considered a contended lock, better not to abuse it.
> cmpxchg() is enought in this case.
We hit the lock once per node (excluding races). Its contribution to the
lock contention is negligible. spin_lock() is easier to follow. I will
keep it.
Ack for the rest of your comments.
--
Kiryl Shutsemau / Kirill A. Shutemov