60 lines
1.6 KiB
Diff
60 lines
1.6 KiB
Diff
From 054879629df5abfef1ecfa85b12b14857d3ee6b3 Mon Sep 17 00:00:00 2001
|
|
From: Steven Rostedt <rostedt@goodmis.org>
|
|
Date: Tue, 29 Apr 2014 20:13:08 -0400
|
|
Subject: [PATCH] rwlock: disable migration before taking a lock
|
|
Origin: https://www.kernel.org/pub/linux/kernel/projects/rt/4.0/patches-4.0.5-rt3.tar.xz
|
|
|
|
If there's no complaints about it. I'm going to add this to the 3.12-rt
|
|
stable tree. As without it, it fails horribly with the cpu hotplug
|
|
stress test, and I wont release a stable kernel that does that.
|
|
|
|
Signed-off-by: Steven Rostedt <rostedt@goodmis.org>
|
|
---
|
|
kernel/locking/rt.c | 17 ++++++++++-------
|
|
1 file changed, 10 insertions(+), 7 deletions(-)
|
|
|
|
--- a/kernel/locking/rt.c
|
|
+++ b/kernel/locking/rt.c
|
|
@@ -180,12 +180,14 @@ EXPORT_SYMBOL(_mutex_unlock);
|
|
*/
|
|
int __lockfunc rt_write_trylock(rwlock_t *rwlock)
|
|
{
|
|
- int ret = rt_mutex_trylock(&rwlock->lock);
|
|
+ int ret;
|
|
|
|
- if (ret) {
|
|
+ migrate_disable();
|
|
+ ret = rt_mutex_trylock(&rwlock->lock);
|
|
+ if (ret)
|
|
rwlock_acquire(&rwlock->dep_map, 0, 1, _RET_IP_);
|
|
- migrate_disable();
|
|
- }
|
|
+ else
|
|
+ migrate_enable();
|
|
|
|
return ret;
|
|
}
|
|
@@ -212,9 +214,10 @@ int __lockfunc rt_read_trylock(rwlock_t
|
|
* write locked.
|
|
*/
|
|
if (rt_mutex_owner(lock) != current) {
|
|
+ migrate_disable();
|
|
ret = rt_mutex_trylock(lock);
|
|
- if (ret)
|
|
- migrate_disable();
|
|
+ if (!ret)
|
|
+ migrate_enable();
|
|
|
|
} else if (!rwlock->read_depth) {
|
|
ret = 0;
|
|
@@ -247,8 +250,8 @@ void __lockfunc rt_read_lock(rwlock_t *r
|
|
* recursive read locks succeed when current owns the lock
|
|
*/
|
|
if (rt_mutex_owner(lock) != current) {
|
|
- __rt_spin_lock(lock);
|
|
migrate_disable();
|
|
+ __rt_spin_lock(lock);
|
|
}
|
|
rwlock->read_depth++;
|
|
}
|