Skip to content

Commit 45f67f3

Browse files
KAGA-KOKOPeter Zijlstra
authored and
Peter Zijlstra
committed
locking/rtmutex: Add a lockdep assert to catch potential nested blocking
There used to be a BUG_ON(current->pi_blocked_on) in the lock acquisition functions, but that vanished in one of the rtmutex overhauls. Bring it back in form of a lockdep assert to catch code paths which take rtmutex based locks with current::pi_blocked_on != NULL. Reported-by: Crystal Wood <[email protected]> Signed-off-by: Thomas Gleixner <[email protected]> Signed-off-by: "Peter Zijlstra (Intel)" <[email protected]> Signed-off-by: Sebastian Andrzej Siewior <[email protected]> Signed-off-by: Peter Zijlstra (Intel) <[email protected]> Link: https://lkml.kernel.org/r/[email protected]
1 parent d14f9e9 commit 45f67f3

File tree

3 files changed

+6
-0
lines changed

3 files changed

+6
-0
lines changed

kernel/locking/rtmutex.c

+2
Original file line numberDiff line numberDiff line change
@@ -1784,6 +1784,8 @@ static int __sched rt_mutex_slowlock(struct rt_mutex_base *lock,
17841784
static __always_inline int __rt_mutex_lock(struct rt_mutex_base *lock,
17851785
unsigned int state)
17861786
{
1787+
lockdep_assert(!current->pi_blocked_on);
1788+
17871789
if (likely(rt_mutex_try_acquire(lock)))
17881790
return 0;
17891791

kernel/locking/rwbase_rt.c

+2
Original file line numberDiff line numberDiff line change
@@ -133,6 +133,8 @@ static int __sched __rwbase_read_lock(struct rwbase_rt *rwb,
133133
static __always_inline int rwbase_read_lock(struct rwbase_rt *rwb,
134134
unsigned int state)
135135
{
136+
lockdep_assert(!current->pi_blocked_on);
137+
136138
if (rwbase_read_trylock(rwb))
137139
return 0;
138140

kernel/locking/spinlock_rt.c

+2
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,8 @@
3737

3838
static __always_inline void rtlock_lock(struct rt_mutex_base *rtm)
3939
{
40+
lockdep_assert(!current->pi_blocked_on);
41+
4042
if (unlikely(!rt_mutex_cmpxchg_acquire(rtm, NULL, current)))
4143
rtlock_slowlock(rtm);
4244
}

0 commit comments

Comments
 (0)