Re: [RFC] making nested spin_trylock() work on UP?
From: Linus Torvalds
Date: Sat Feb 14 2026 - 11:33:24 EST
On Fri, 13 Feb 2026 at 22:29, Matthew Wilcox <willy@xxxxxxxxxxxxx> wrote:
>
> What if we use an atomic_t on UP to simulate there being a spinlock,
> but only for pcp?
Yes. Please just wrap this - very unusual - use case with a special
wrapper that can then be entirely different for UP and SMP, and use
something like the suggested "pcp_lock" that becomes a spinlock on
smp, and just a tracking variable on UP.
And I don't think it needs to even be marked as 'atomic_t' on UP - the
value is going to be idempotent even when modified from interrupts
(because it will just be modified back), so no need for any special
logic, I think. The generic 'atomic_t' ops on UP disable interrupts,
which is horrendous.
Changing spinlocks globally on UP to be something they haven't been
before does not sound like a good idea, particularly since no actual
developer uses UP any more (and honestly, UP is dead outside of very
low-end platforms or legacy like 68k).
Linus