Skip to content

Commit 168660b

Browse files
Sebastian Andrzej SiewiorKAGA-KOKO
authored andcommitted
locking/rt: Add sparse annotation for RCU.
Every lock, that becomes a sleeping lock on PREEMPT_RT, starts a RCU read side critical section. There is no sparse annotation for this and sparse complains about unbalanced locking. Add __acquires/ __releases for the RCU lock. This covers all but the trylock functions. A __cond_acquires() annotation didn't work. 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 b1f01f9 commit 168660b

File tree

1 file changed

+7
-7
lines changed

1 file changed

+7
-7
lines changed

kernel/locking/spinlock_rt.c

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ static __always_inline void __rt_spin_lock(spinlock_t *lock)
5151
migrate_disable();
5252
}
5353

54-
void __sched rt_spin_lock(spinlock_t *lock)
54+
void __sched rt_spin_lock(spinlock_t *lock) __acquires(RCU)
5555
{
5656
spin_acquire(&lock->dep_map, 0, 0, _RET_IP_);
5757
__rt_spin_lock(lock);
@@ -75,7 +75,7 @@ void __sched rt_spin_lock_nest_lock(spinlock_t *lock,
7575
EXPORT_SYMBOL(rt_spin_lock_nest_lock);
7676
#endif
7777

78-
void __sched rt_spin_unlock(spinlock_t *lock)
78+
void __sched rt_spin_unlock(spinlock_t *lock) __releases(RCU)
7979
{
8080
spin_release(&lock->dep_map, _RET_IP_);
8181
migrate_enable();
@@ -225,7 +225,7 @@ int __sched rt_write_trylock(rwlock_t *rwlock)
225225
}
226226
EXPORT_SYMBOL(rt_write_trylock);
227227

228-
void __sched rt_read_lock(rwlock_t *rwlock)
228+
void __sched rt_read_lock(rwlock_t *rwlock) __acquires(RCU)
229229
{
230230
rtlock_might_resched();
231231
rwlock_acquire_read(&rwlock->dep_map, 0, 0, _RET_IP_);
@@ -235,7 +235,7 @@ void __sched rt_read_lock(rwlock_t *rwlock)
235235
}
236236
EXPORT_SYMBOL(rt_read_lock);
237237

238-
void __sched rt_write_lock(rwlock_t *rwlock)
238+
void __sched rt_write_lock(rwlock_t *rwlock) __acquires(RCU)
239239
{
240240
rtlock_might_resched();
241241
rwlock_acquire(&rwlock->dep_map, 0, 0, _RET_IP_);
@@ -246,7 +246,7 @@ void __sched rt_write_lock(rwlock_t *rwlock)
246246
EXPORT_SYMBOL(rt_write_lock);
247247

248248
#ifdef CONFIG_DEBUG_LOCK_ALLOC
249-
void __sched rt_write_lock_nested(rwlock_t *rwlock, int subclass)
249+
void __sched rt_write_lock_nested(rwlock_t *rwlock, int subclass) __acquires(RCU)
250250
{
251251
rtlock_might_resched();
252252
rwlock_acquire(&rwlock->dep_map, subclass, 0, _RET_IP_);
@@ -257,7 +257,7 @@ void __sched rt_write_lock_nested(rwlock_t *rwlock, int subclass)
257257
EXPORT_SYMBOL(rt_write_lock_nested);
258258
#endif
259259

260-
void __sched rt_read_unlock(rwlock_t *rwlock)
260+
void __sched rt_read_unlock(rwlock_t *rwlock) __releases(RCU)
261261
{
262262
rwlock_release(&rwlock->dep_map, _RET_IP_);
263263
migrate_enable();
@@ -266,7 +266,7 @@ void __sched rt_read_unlock(rwlock_t *rwlock)
266266
}
267267
EXPORT_SYMBOL(rt_read_unlock);
268268

269-
void __sched rt_write_unlock(rwlock_t *rwlock)
269+
void __sched rt_write_unlock(rwlock_t *rwlock) __releases(RCU)
270270
{
271271
rwlock_release(&rwlock->dep_map, _RET_IP_);
272272
rcu_read_unlock();

0 commit comments

Comments
 (0)