Re: [PATCHv4 09/14] mm/hugetlb: Remove fake head pages
From: Muchun Song
Date: Tue Jan 27 2026 - 21:44:51 EST
> On Jan 27, 2026, at 22:51, Kiryl Shutsemau <kas@xxxxxxxxxx> wrote:
>
> 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.
I don't think cmpxchg() is hard to follow. It’s precisely because of
your abuse that interrupts still have to be disabled here—hugetlb_lock
must be an irq-off lock. Are you really going to use spin_lock_irq just
because “it feels simpler” to you?
>
> Ack for the rest of your comments.
>
>
> --
> Kiryl Shutsemau / Kirill A. Shutemov