Re: [PATCH v7 6/7] mm: Make alloc_contig_range handle in-use hugetlb pages

From: Mike Kravetz
Date: Wed Apr 14 2021 - 13:08:13 EST


On 4/13/21 9:52 PM, Oscar Salvador wrote:
> On Tue, Apr 13, 2021 at 03:48:53PM -0700, Mike Kravetz wrote:
>> The label free_new is:
>>
>> free_new:
>> spin_unlock_irq(&hugetlb_lock);
>> __free_pages(new_page, huge_page_order(h));
>>
>> return ret;
>>
>> So, we are locking and immediately unlocking without any code in
>> between. Usually, I don't like like multiple labels before return.
>> However, perhaps we should add another to avoid this unnecessary
>> cycle. On the other hand, this is an uncommon race condition so the
>> simple code may be acceptable.
>
> I guess we could have something like:
>
> free_new:
> spin_unlock_irq(&hugetlb_lock);
> free_new_nolock:
> __free_pages(new_page, huge_page_order(h));
>
> return ret;
>
> And let the retry go to there without locking. But as you said, the
> racecondition is rare enough, so I am not sure if this buys us much.
> But I can certainly add it if you feel strong about it.

No strong feelings. I am fine with it as is.

--
Mike Kravetz