rt_mutex: restore wait_lock init in __rt_mutex_init
Without the raw_spin_lock_init(), the wait_lock does not get properly initialized with CONFIG_DEBUG_SPINLOCK. This can manifest in a BUG() in the futex requeue_pi path when the pi_state->pi_mutex->wait_lock fails the magic test in rt_mutex_start_proxy_lock()->raw_spin_lock(&lock->wait_lock).
--- rtmutex.c | 1 + 1 file changed, 1 insertion(+)
kernel/rtmutex.c +1 -0
@@ -1277,6 +1277,7 @@ EXPORT_SYMBOL_GPL(rt_mutex_destroy);void __rt_mutex_init (struct rt_mutex *lock,const char *name) { lock->owner =NULL ; +raw_spin_lock_init (&lock->wait_lock);plist_head_init_raw (&lock->wait_list, &lock->wait_lock);debug_rt_mutex_init (lock, name);
Quoted 4 lines · Darren Hart
Without the
raw_spin_lock_init(), thewait_lockdoes not get properly initialized withCONFIG_DEBUG_SPINLOCK. This can manifest in aBUG()in the futexrequeue_pipath when thepi_state->pi_mutex->wait_lockfails the magic test in rt_mutex_start_proxy_lock()->raw_spin_lock(&lock->wait_lock).
That's actively wrong. You reinitialize the lock for all other cases which call this via rt_mutex_init(). There is a reason why I moved the spin lock initializer out of __rt_mutex_init() into rt_mutex_init(). The lock name stuff for lockdep ends up to be "lock->wait_lock" for all rt_mutexes, which is pretty useless when you have to analyze a lockdep splat. Thanks for finding it nevertheless.
So the correct fix is:
kernel/rtmutex.c +1 -1
@@ -1296,7 +1296,7 @@ EXPORT_SYMBOL_GPL(__rt_mutex_init);void rt_mutex_init_proxy_locked (struct rt_mutex *lock,struct task_struct *proxy_owner) { -__rt_mutex_init (lock,NULL ); +rt_mutex_init (lock);debug_rt_mutex_proxy_lock (lock, proxy_owner);rt_mutex_set_owner (lock, proxy_owner);rt_mutex_deadlock_account_lock (lock, proxy_owner);
Quoted 22 lines · Thomas Gleixner
Quoted 4 lines · Darren Hart
Without the
raw_spin_lock_init(), thewait_lockdoes not get properly initialized withCONFIG_DEBUG_SPINLOCK. This can manifest in aBUG()in the futexrequeue_pipath when thepi_state->pi_mutex->wait_lockfails the magic test in rt_mutex_start_proxy_lock()->raw_spin_lock(&lock->wait_lock).That's actively wrong. You reinitialize the lock for all other cases which call this via
rt_mutex_init(). There is a reason why I moved the spin lock initializer out of__rt_mutex_init()intort_mutex_init(). The lock name stuff for lockdep ends up to be "lock->wait_lock" for allrt_mutexes, which is pretty useless when you have to analyze a lockdep splat. Thanks for finding it nevertheless.So the correct fix is:
Index:
linux-2.6/kernel/rtmutex.c
===================================================================
kernel/rtmutex.c EXPORT_SYMBOL_GPL(__rt_mutex_init); · line 1302
Quoted 8 lines
kernel/rtmutex.c +1
-1@@ -1296,7 +1296,7 @@ EXPORT_SYMBOL_GPL(__rt_mutex_init);void rt_mutex_init_proxy_locked (struct rt_mutex *lock,struct task_struct *proxy_owner) { -__rt_mutex_init (lock,NULL ); +rt_mutex_init (lock);debug_rt_mutex_proxy_lock (lock, proxy_owner);rt_mutex_set_owner (lock, proxy_owner);rt_mutex_deadlock_account_lock (lock, proxy_owner);
Seems to work. I no longer get a warning from pulseaudio either. Also darren, at least on fedora 15 glibc supports requeue_pi. support for that is in nptl/sysdeps/unix/sysv/linux/x86_64/pthread_cond_*.S
Cheers,
Maarten
Quoted 11 lines · Maarten Lankhorst
Quoted 10 lines · Thomas Gleixner
Quoted 4 lines · Darren Hart
Without the
raw_spin_lock_init(), thewait_lockdoes not get properly initialized withCONFIG_DEBUG_SPINLOCK. This can manifest in aBUG()in the futexrequeue_pipath when thepi_state->pi_mutex->wait_lockfails the magic test in rt_mutex_start_proxy_lock()->raw_spin_lock(&lock->wait_lock).That's actively wrong. You reinitialize the lock for all other cases which call this via
rt_mutex_init(). There is a reason why I moved the spin lock initializer out of__rt_mutex_init()intort_mutex_init().
Ah... I didn't notice the move. I saw the change to the line after which add _raw and passed the wait_lock and thought it was expected that that call did the init (which it doesn't).
Quoted 3 lines
Quoted 3 lines
The lock name stuff for lockdep ends up to be "
lock->wait_lock" for allrt_mutexes, which is pretty useless when you have to analyze a lockdep splat. Thanks for finding it nevertheless.
Right, makes sense.
Quoted 12 lines
kernel/rtmutex.c EXPORT_SYMBOL_GPL(__rt_mutex_init); · line 1299
Quoted 12 lines
So the correct fix is:
Index:
linux-2.6/kernel/rtmutex.c
===================================================================kernel/rtmutex.c +1
-1@@ -1296,7 +1296,7 @@ EXPORT_SYMBOL_GPL(__rt_mutex_init);void rt_mutex_init_proxy_locked (struct rt_mutex *lock,struct task_struct *proxy_owner) { -__rt_mutex_init (lock,NULL ); +rt_mutex_init (lock);
So obvious now in hindsight :)
Quoted 6 lines
kernel/rtmutex.c EXPORT_SYMBOL_GPL(__rt_mutex_init); · line 1302
Quoted 5 lines
kernel/rtmutex.c +0
-0debug_rt_mutex_proxy_lock (lock, proxy_owner);rt_mutex_set_owner (lock, proxy_owner);rt_mutex_deadlock_account_lock (lock, proxy_owner);Seems to work. I no longer get a warning from pulseaudio either.
I still don't understand how pulseaudio ever caused this.
Quoted 2 lines
Also darren, at least on fedora 15 glibc supports
requeue_pi. support for that is innptl/sysdeps/unix/sysv/linux/x86_64/pthread_cond_*.S
Duh, sorry, wasn't thinking straight. The requeue_pi support went in a while ago - what is missing is PI aware condvars which complete requeue_pi support.
Thanks!
Signature · 3 lines
Darren Hart Intel Open Source Technology Center Yocto Project - Linux Kernel