]> rtime.felk.cvut.cz Git - hercules2020/nv-tegra/linux-4.4.git/blob - rt-patches/0117-futex-Ensure-lock-unlock-symetry-versus-pi_lock-and-.patch
rt_patches: required rebase due to printk change
[hercules2020/nv-tegra/linux-4.4.git] / rt-patches / 0117-futex-Ensure-lock-unlock-symetry-versus-pi_lock-and-.patch
1 From 9f95e3260a37233228392a4e1ec4c7738ae9c956 Mon Sep 17 00:00:00 2001
2 From: Thomas Gleixner <tglx@linutronix.de>
3 Date: Fri, 1 Mar 2013 11:17:42 +0100
4 Subject: [PATCH 117/366] futex: Ensure lock/unlock symetry versus pi_lock and
5  hash bucket lock
6
7 In exit_pi_state_list() we have the following locking construct:
8
9    spin_lock(&hb->lock);
10    raw_spin_lock_irq(&curr->pi_lock);
11
12    ...
13    spin_unlock(&hb->lock);
14
15 In !RT this works, but on RT the migrate_enable() function which is
16 called from spin_unlock() sees atomic context due to the held pi_lock
17 and just decrements the migrate_disable_atomic counter of the
18 task. Now the next call to migrate_disable() sees the counter being
19 negative and issues a warning. That check should be in
20 migrate_enable() already.
21
22 Fix this by dropping pi_lock before unlocking hb->lock and reaquire
23 pi_lock after that again. This is safe as the loop code reevaluates
24 head again under the pi_lock.
25
26 Reported-by: Yong Zhang <yong.zhang@windriver.com>
27 Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
28 Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
29 ---
30  kernel/futex.c | 2 ++
31  1 file changed, 2 insertions(+)
32
33 diff --git a/kernel/futex.c b/kernel/futex.c
34 index 33ddc99..1ec060b 100644
35 --- a/kernel/futex.c
36 +++ b/kernel/futex.c
37 @@ -815,7 +815,9 @@ void exit_pi_state_list(struct task_struct *curr)
38                  * task still owns the PI-state:
39                  */
40                 if (head->next != next) {
41 +                       raw_spin_unlock_irq(&curr->pi_lock);
42                         spin_unlock(&hb->lock);
43 +                       raw_spin_lock_irq(&curr->pi_lock);
44                         continue;
45                 }
46  
47 -- 
48 1.9.1
49