On Wed, Aug 3, 2022 at 6:33 PM Steven Rostedt <rostedt@xxxxxxxxxxx> wrote: > > We don't care if the lock is held or not. The point of the matter is that > spinlocks in RT do not disable preemption. The code that the > preempt_disable_under_spinlock() is inside, can not be preempted. If it is, > bad things can happen. I think you're missing Willy's point - the use would be to verify that the spinlock really *is* held, because that's what disables preemption on non-RT. But no, I don't think it's worth the pain to have to specify which spinlock is held, because the spinlock might have been taken by the caller and we don't even have access to it - or care - we just know somebody did take it. If we want extra debuggingm it might be something like just verifying that yes, the preempt count (on a non-RT preemptible kernel) really is elevated already. > I wonder if raw_preempt_disable() would be another name to use? NO! The point is that normal non-RT code does *not* disable preemption at all, because it is already disabled thanks to the earlier spinlock. So we definitely do *not* want to call this "raw_preempt_disable()", because it's actually not supposed to normally disable anything at all. Only for RT, where the spinlock code doesn't do it. Linus