Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

locking/rt: Remove one __cond_lock() in RT's spin_trylock_irqsave()

spin_trylock_irqsave() has a __cond_lock() wrapper which points to
__spin_trylock_irqsave(). The function then invokes spin_trylock() which
has another __cond_lock() finally pointing to rt_spin_trylock().

The compiler has no problem to parse this but sparse does not recognise
that users of spin_trylock_irqsave() acquire a conditional lock and
complains.

Remove one layer of __cond_lock() so that sparse recognises conditional
locking.

Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Link: https://lore.kernel.org/all/20240812104200.2239232-3-bigeasy@linutronix.de

authored by

Sebastian Andrzej Siewior and committed by
Thomas Gleixner
b1f01f9e 52e0874f

+1 -4
+1 -4
include/linux/spinlock_rt.h
··· 132 132 #define spin_trylock_irq(lock) \ 133 133 __cond_lock(lock, rt_spin_trylock(lock)) 134 134 135 - #define __spin_trylock_irqsave(lock, flags) \ 135 + #define spin_trylock_irqsave(lock, flags) \ 136 136 ({ \ 137 137 int __locked; \ 138 138 \ ··· 141 141 __locked = spin_trylock(lock); \ 142 142 __locked; \ 143 143 }) 144 - 145 - #define spin_trylock_irqsave(lock, flags) \ 146 - __cond_lock(lock, __spin_trylock_irqsave(lock, flags)) 147 144 148 145 #define spin_is_contended(lock) (((void)(lock), 0)) 149 146