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

From: Zi Yan

Date: Fri Jul 03 2026 - 11:18:22 EST


On Fri Jul 3, 2026 at 8:31 AM EDT, 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 if it 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.
>
> Suggested-by: Harry Yoo <harry@xxxxxxxxxx>
> Link: https://lore.kernel.org/all/397859cb-b127-4cc6-9c71-044afc99bf0c@xxxxxxxxxx/
> Reviewed-by: Vlastimil Babka (SUSE) <vbabka@xxxxxxxxxx>
> Reviewed-by: Harry Yoo (Oracle) <harry@xxxxxxxxxx>
> Signed-off-by: Brendan Jackman <jackmanb@xxxxxxxxxx>
> ---
> mm/internal.h | 23 +++++++++++++++++++++++
> mm/page_alloc.c | 17 +----------------
> mm/slub.c | 10 +---------
> 3 files changed, 25 insertions(+), 25 deletions(-)
>

Reviewed-by: Zi Yan <ziy@xxxxxxxxxx>

--
Best Regards,
Yan, Zi