diff options
author | Steven Rostedt <rostedt@goodmis.org> | 2014-04-29 20:13:08 -0400 |
---|---|---|
committer | Steven Rostedt <rostedt@goodmis.org> | 2014-04-30 14:10:49 -0400 |
commit | 6ac6b24947da81cfc69a9e20de2fe461e636f4ab (patch) | |
tree | 7603dbc8dc8233c128b966cef302654ccdecacf9 | |
parent | aa065f79cd0820637854fc4c6f04d456f2e9d89f (diff) |
rt: Move migrate_disable up in trylocks
The changes to move the migrate_disable() down in the trylocks()
caused race conditions to appear in the cpu hotplug code. The
migrate disables must be done before any of the rtmutexes are
taken, otherwise a lock may be held that prevents hotplug from
moving forward.
Link: http://lkml.kernel.org/r/20140429201308.63292691@gandalf.local.home
Signed-off-by: Steven Rostedt <rostedt@goodmis.org>
Cc: Mike Galbraith <umgwanakikbuti@gmail.com>
Cc: Nicholas Mc Guire <der.herr@hofr.at>
Cc: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
Cc: linux-rt-users <linux-rt-users@vger.kernel.org>
Cc: Thomas Gleixner <tglx@linutronix.de>
Cc: John Kacur <jkacur@redhat.com>
Cc: Clark Williams <williams@redhat.com>
-rw-r--r-- | kernel/rt.c | 20 |
1 files changed, 12 insertions, 8 deletions
diff --git a/kernel/rt.c b/kernel/rt.c index 5d177272ffb4..5f44defabe02 100644 --- a/kernel/rt.c +++ b/kernel/rt.c @@ -180,12 +180,15 @@ EXPORT_SYMBOL(_mutex_unlock); */ int __lockfunc rt_write_trylock(rwlock_t *rwlock) { - int ret = rt_mutex_trylock(&rwlock->lock); + int ret; + + migrate_disable(); + ret = rt_mutex_trylock(&rwlock->lock); - if (ret) { + if (ret) rwlock_acquire(&rwlock->dep_map, 0, 1, _RET_IP_); - migrate_disable(); - } + else + migrate_enable(); return ret; } @@ -212,11 +215,12 @@ int __lockfunc rt_read_trylock(rwlock_t *rwlock) * write locked. */ if (rt_mutex_owner(lock) != current) { + migrate_disable(); ret = rt_mutex_trylock(lock); - if (ret) { + if (ret) rwlock_acquire(&rwlock->dep_map, 0, 1, _RET_IP_); - migrate_disable(); - } + else + migrate_enable(); } else if (!rwlock->read_depth) { ret = 0; } @@ -245,8 +249,8 @@ void __lockfunc rt_read_lock(rwlock_t *rwlock) */ if (rt_mutex_owner(lock) != current) { rwlock_acquire(&rwlock->dep_map, 0, 0, _RET_IP_); - __rt_spin_lock(lock); migrate_disable(); + __rt_spin_lock(lock); } rwlock->read_depth++; } |