Skip to content

Commit 51711e8

Browse files
KAGA-KOKOIngo Molnar
authored and
Ingo Molnar
committed
locking/rtmutex: Prevent lockdep false positive with PI futexes
On PREEMPT_RT the futex hashbucket spinlock becomes 'sleeping' and rtmutex based. That causes a lockdep false positive because some of the futex functions invoke spin_unlock(&hb->lock) with the wait_lock of the rtmutex associated to the pi_futex held. spin_unlock() in turn takes wait_lock of the rtmutex on which the spinlock is based which makes lockdep notice a lock recursion. Give the futex/rtmutex wait_lock a separate key. Signed-off-by: Thomas Gleixner <[email protected]> Signed-off-by: Peter Zijlstra (Intel) <[email protected]> Signed-off-by: Ingo Molnar <[email protected]> Link: https://lore.kernel.org/r/[email protected]
1 parent 07d91ef commit 51711e8

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed

kernel/locking/rtmutex_api.c

+12
Original file line numberDiff line numberDiff line change
@@ -214,7 +214,19 @@ EXPORT_SYMBOL_GPL(__rt_mutex_init);
214214
void __sched rt_mutex_init_proxy_locked(struct rt_mutex_base *lock,
215215
struct task_struct *proxy_owner)
216216
{
217+
static struct lock_class_key pi_futex_key;
218+
217219
__rt_mutex_base_init(lock);
220+
/*
221+
* On PREEMPT_RT the futex hashbucket spinlock becomes 'sleeping'
222+
* and rtmutex based. That causes a lockdep false positive, because
223+
* some of the futex functions invoke spin_unlock(&hb->lock) with
224+
* the wait_lock of the rtmutex associated to the pi_futex held.
225+
* spin_unlock() in turn takes wait_lock of the rtmutex on which
226+
* the spinlock is based, which makes lockdep notice a lock
227+
* recursion. Give the futex/rtmutex wait_lock a separate key.
228+
*/
229+
lockdep_set_class(&lock->wait_lock, &pi_futex_key);
218230
rt_mutex_set_owner(lock, proxy_owner);
219231
}
220232

0 commit comments

Comments
 (0)