Skip to content

Commit 52e0874

Browse files
Sebastian Andrzej SiewiorKAGA-KOKO
authored andcommitted
locking/rt: Add sparse annotation PREEMPT_RT's sleeping locks.
The sleeping locks on PREEMPT_RT (rt_spin_lock() and friends) lack sparse annotation. Therefore a missing spin_unlock() won't be spotted by sparse in a PREEMPT_RT build while it is noticed on a !PREEMPT_RT build. Add the __acquires/__releases macros to the lock/ unlock functions. The trylock functions already use the __cond_lock() wrapper. Signed-off-by: Sebastian Andrzej Siewior <[email protected]> Signed-off-by: Thomas Gleixner <[email protected]> Link: https://lore.kernel.org/all/[email protected]
1 parent 2628cbd commit 52e0874

File tree

2 files changed

+9
-9
lines changed

2 files changed

+9
-9
lines changed

include/linux/rwlock_rt.h

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -24,13 +24,13 @@ do { \
2424
__rt_rwlock_init(rwl, #rwl, &__key); \
2525
} while (0)
2626

27-
extern void rt_read_lock(rwlock_t *rwlock);
27+
extern void rt_read_lock(rwlock_t *rwlock) __acquires(rwlock);
2828
extern int rt_read_trylock(rwlock_t *rwlock);
29-
extern void rt_read_unlock(rwlock_t *rwlock);
30-
extern void rt_write_lock(rwlock_t *rwlock);
31-
extern void rt_write_lock_nested(rwlock_t *rwlock, int subclass);
29+
extern void rt_read_unlock(rwlock_t *rwlock) __releases(rwlock);
30+
extern void rt_write_lock(rwlock_t *rwlock) __acquires(rwlock);
31+
extern void rt_write_lock_nested(rwlock_t *rwlock, int subclass) __acquires(rwlock);
3232
extern int rt_write_trylock(rwlock_t *rwlock);
33-
extern void rt_write_unlock(rwlock_t *rwlock);
33+
extern void rt_write_unlock(rwlock_t *rwlock) __releases(rwlock);
3434

3535
static __always_inline void read_lock(rwlock_t *rwlock)
3636
{

include/linux/spinlock_rt.h

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -32,10 +32,10 @@ do { \
3232
__rt_spin_lock_init(slock, #slock, &__key, true); \
3333
} while (0)
3434

35-
extern void rt_spin_lock(spinlock_t *lock);
36-
extern void rt_spin_lock_nested(spinlock_t *lock, int subclass);
37-
extern void rt_spin_lock_nest_lock(spinlock_t *lock, struct lockdep_map *nest_lock);
38-
extern void rt_spin_unlock(spinlock_t *lock);
35+
extern void rt_spin_lock(spinlock_t *lock) __acquires(lock);
36+
extern void rt_spin_lock_nested(spinlock_t *lock, int subclass) __acquires(lock);
37+
extern void rt_spin_lock_nest_lock(spinlock_t *lock, struct lockdep_map *nest_lock) __acquires(lock);
38+
extern void rt_spin_unlock(spinlock_t *lock) __releases(lock);
3939
extern void rt_spin_lock_unlock(spinlock_t *lock);
4040
extern int rt_spin_trylock_bh(spinlock_t *lock);
4141
extern int rt_spin_trylock(spinlock_t *lock);

0 commit comments

Comments
 (0)