[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20230815111430.488430699@infradead.org>
Date: Tue, 15 Aug 2023 13:01:27 +0200
From: Peter Zijlstra <peterz@...radead.org>
To: bigeasy@...utronix.de, tglx@...utronix.de
Cc: linux-kernel@...r.kernel.org, peterz@...radead.org,
bsegall@...gle.com, boqun.feng@...il.com, swood@...hat.com,
bristot@...hat.com, dietmar.eggemann@....com, mingo@...hat.com,
jstultz@...gle.com, juri.lelli@...hat.com, mgorman@...e.de,
rostedt@...dmis.org, vschneid@...hat.com,
vincent.guittot@...aro.org, longman@...hat.com, will@...nel.org
Subject: [PATCH 6/6] locking/rtmutex: Add a lockdep assert to catch potential nested blocking
From: Thomas Gleixner <tglx@...utronix.de>
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 <swood@...hat.com>
Signed-off-by: Thomas Gleixner <tglx@...utronix.de>
Signed-off-by: Sebastian Andrzej Siewior <bigeasy@...utronix.de>
Signed-off-by: Peter Zijlstra (Intel) <peterz@...radead.org>
Link: https://lkml.kernel.org/r/20230427111937.2745231-5-bigeasy@linutronix.de
---
kernel/locking/rtmutex.c | 2 ++
kernel/locking/rwbase_rt.c | 2 ++
kernel/locking/spinlock_rt.c | 2 ++
3 files changed, 6 insertions(+)
--- a/kernel/locking/rtmutex.c
+++ b/kernel/locking/rtmutex.c
@@ -1774,6 +1774,8 @@ static int __sched rt_mutex_slowlock(str
static __always_inline int __rt_mutex_lock(struct rt_mutex_base *lock,
unsigned int state)
{
+ lockdep_assert(!current->pi_blocked_on);
+
if (likely(rt_mutex_try_acquire(lock)))
return 0;
--- a/kernel/locking/rwbase_rt.c
+++ b/kernel/locking/rwbase_rt.c
@@ -131,6 +131,8 @@ static int __sched __rwbase_read_lock(st
static __always_inline int rwbase_read_lock(struct rwbase_rt *rwb,
unsigned int state)
{
+ lockdep_assert(!current->pi_blocked_on);
+
if (rwbase_read_trylock(rwb))
return 0;
--- a/kernel/locking/spinlock_rt.c
+++ b/kernel/locking/spinlock_rt.c
@@ -37,6 +37,8 @@
static __always_inline void rtlock_lock(struct rt_mutex_base *rtm)
{
+ lockdep_assert(!current->pi_blocked_on);
+
if (unlikely(!rt_mutex_cmpxchg_acquire(rtm, NULL, current)))
rtlock_slowlock(rtm);
}
Powered by blists - more mailing lists