Re: [PATCH v4 18/18] mm: factor out can_spin_trylock()

From: Brendan Jackman

Date: Fri Jul 03 2026 - 07:51:56 EST


On Fri Jul 3, 2026 at 9:32 AM UTC, Vlastimil Babka (SUSE) wrote:
> On 7/2/26 11:49, Brendan Jackman wrote:
>> Deduplicate checks for whether the current context is safe for
>> spin_trylock().
>>
>> Does this function really belong in mm/internal.h or is it generic? Not
>> sure. If someone ends up duplicating this logic elsewhere in the kernel,
>> that would be a shame. But goes in some generic header, someone treats
>> it as documentation about where it's guaranteed safe to spin_trylock(),
>> and then it emerges that there are other subtle preconditions that
>> didn't affect the mm usecase, that would be worse. So, just be
>> conservative and keep it local.
>
> Agreed. We could even use page_alloc.h ?

Would be nice to shrink the scope but I think it would be "wrong" for
slub.c to get it from there. It's not to do with the page allocator.