2020-10-12 12:52:06 +00:00
|
|
|
From 6eafea725b5f152e852f61bc367309f61e586217 Mon Sep 17 00:00:00 2001
|
|
|
|
Message-Id: <6eafea725b5f152e852f61bc367309f61e586217.1601675152.git.zanussi@kernel.org>
|
|
|
|
In-Reply-To: <5b5a156f9808b1acf1205606e03da117214549ea.1601675151.git.zanussi@kernel.org>
|
|
|
|
References: <5b5a156f9808b1acf1205606e03da117214549ea.1601675151.git.zanussi@kernel.org>
|
2018-08-27 14:32:32 +00:00
|
|
|
From: Thomas Gleixner <tglx@linutronix.de>
|
|
|
|
Date: Fri, 1 Mar 2013 11:17:42 +0100
|
2020-09-04 20:10:21 +00:00
|
|
|
Subject: [PATCH 131/333] futex: Ensure lock/unlock symetry versus pi_lock and
|
2019-04-08 23:49:20 +00:00
|
|
|
hash bucket lock
|
2020-10-12 12:52:06 +00:00
|
|
|
Origin: https://www.kernel.org/pub/linux/kernel/projects/rt/4.19/older/patches-4.19.148-rt64.tar.xz
|
2018-08-27 14:32:32 +00:00
|
|
|
|
|
|
|
In exit_pi_state_list() we have the following locking construct:
|
|
|
|
|
|
|
|
spin_lock(&hb->lock);
|
|
|
|
raw_spin_lock_irq(&curr->pi_lock);
|
|
|
|
|
|
|
|
...
|
|
|
|
spin_unlock(&hb->lock);
|
|
|
|
|
|
|
|
In !RT this works, but on RT the migrate_enable() function which is
|
|
|
|
called from spin_unlock() sees atomic context due to the held pi_lock
|
|
|
|
and just decrements the migrate_disable_atomic counter of the
|
|
|
|
task. Now the next call to migrate_disable() sees the counter being
|
|
|
|
negative and issues a warning. That check should be in
|
|
|
|
migrate_enable() already.
|
|
|
|
|
|
|
|
Fix this by dropping pi_lock before unlocking hb->lock and reaquire
|
|
|
|
pi_lock after that again. This is safe as the loop code reevaluates
|
|
|
|
head again under the pi_lock.
|
|
|
|
|
|
|
|
Reported-by: Yong Zhang <yong.zhang@windriver.com>
|
|
|
|
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
|
|
|
|
Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
|
|
|
|
---
|
2019-04-08 23:49:20 +00:00
|
|
|
kernel/futex.c | 2 ++
|
2018-08-27 14:32:32 +00:00
|
|
|
1 file changed, 2 insertions(+)
|
|
|
|
|
2019-04-08 23:49:20 +00:00
|
|
|
diff --git a/kernel/futex.c b/kernel/futex.c
|
2020-04-21 20:13:52 +00:00
|
|
|
index c922e994f524..cde7ff6f9a48 100644
|
2018-08-27 14:32:32 +00:00
|
|
|
--- a/kernel/futex.c
|
|
|
|
+++ b/kernel/futex.c
|
2020-04-21 20:13:52 +00:00
|
|
|
@@ -938,7 +938,9 @@ void exit_pi_state_list(struct task_struct *curr)
|
2018-08-27 14:32:32 +00:00
|
|
|
if (head->next != next) {
|
|
|
|
/* retain curr->pi_lock for the loop invariant */
|
|
|
|
raw_spin_unlock(&pi_state->pi_mutex.wait_lock);
|
|
|
|
+ raw_spin_unlock_irq(&curr->pi_lock);
|
|
|
|
spin_unlock(&hb->lock);
|
|
|
|
+ raw_spin_lock_irq(&curr->pi_lock);
|
|
|
|
put_pi_state(pi_state);
|
|
|
|
continue;
|
|
|
|
}
|
2020-01-03 23:36:11 +00:00
|
|
|
--
|
2020-06-22 13:14:16 +00:00
|
|
|
2.17.1
|
2020-01-03 23:36:11 +00:00
|
|
|
|