Re: [RFC] making nested spin_trylock() work on UP?

From: Alexei Starovoitov

Date: Thu Apr 16 2026 - 10:26:52 EST


On Thu Apr 16, 2026 at 3:05 AM PDT, Vlastimil Babka (SUSE) wrote:
>> I think we need a special spinlock type that wraps something like this
>> and use them when spinlocks can be trylock'd in an unknown context:
>> pcp lock, zone lock, per-node partial slab list lock,
>> per-node barn lock, etc.
>
> Soudns like a lot of hassle for a niche config (SMP=n) where nobody would
> use e.g. bpf tracing anyway. We already have this in kmalloc_nolock():
>
> /*
> * See the comment for the same check in
> * alloc_frozen_pages_nolock_noprof()
> */
> if (IS_ENABLED(CONFIG_PREEMPT_RT) && (in_nmi() || in_hardirq()))
> return NULL;
>
> It would be trivial to extend this to !SMP. However it wouldn't cover the
> kprobe context. Any idea Alexei?

Yeah. Totally fine with that. Certainly better than "special spinlock type".