Commit d82f0b0f authored by Oleg Nesterov's avatar Oleg Nesterov Committed by Ingo Molnar

migrate_timers: add comment, use spinlock_irq()

Add the comment to explain why the double lock in migrate_timers()
can't deadlock.

Change the code to use spinlock_irq() instead of local_irq_disable()
+ spin_lock().
Signed-off-by: default avatarOleg Nesterov <oleg@tv-sign.ru>
Acked-by: default avatarSteven Rostedt <srostedt@redhat.com>
Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
Signed-off-by: default avatarIngo Molnar <mingo@elte.hu>
parent 6a55617e
...@@ -1620,9 +1620,11 @@ static void migrate_hrtimers(int cpu) ...@@ -1620,9 +1620,11 @@ static void migrate_hrtimers(int cpu)
new_base = &get_cpu_var(hrtimer_bases); new_base = &get_cpu_var(hrtimer_bases);
tick_cancel_sched_timer(cpu); tick_cancel_sched_timer(cpu);
/*
local_irq_disable(); * The caller is globally serialized and nobody else
spin_lock(&new_base->lock); * takes two locks at once, deadlock is not possible.
*/
spin_lock_irq(&new_base->lock);
spin_lock_nested(&old_base->lock, SINGLE_DEPTH_NESTING); spin_lock_nested(&old_base->lock, SINGLE_DEPTH_NESTING);
for (i = 0; i < HRTIMER_MAX_CLOCK_BASES; i++) { for (i = 0; i < HRTIMER_MAX_CLOCK_BASES; i++) {
...@@ -1631,8 +1633,7 @@ static void migrate_hrtimers(int cpu) ...@@ -1631,8 +1633,7 @@ static void migrate_hrtimers(int cpu)
} }
spin_unlock(&old_base->lock); spin_unlock(&old_base->lock);
spin_unlock(&new_base->lock); spin_unlock_irq(&new_base->lock);
local_irq_enable();
put_cpu_var(hrtimer_bases); put_cpu_var(hrtimer_bases);
} }
#endif /* CONFIG_HOTPLUG_CPU */ #endif /* CONFIG_HOTPLUG_CPU */
......
...@@ -1435,9 +1435,11 @@ static void __cpuinit migrate_timers(int cpu) ...@@ -1435,9 +1435,11 @@ static void __cpuinit migrate_timers(int cpu)
BUG_ON(cpu_online(cpu)); BUG_ON(cpu_online(cpu));
old_base = per_cpu(tvec_bases, cpu); old_base = per_cpu(tvec_bases, cpu);
new_base = get_cpu_var(tvec_bases); new_base = get_cpu_var(tvec_bases);
/*
local_irq_disable(); * The caller is globally serialized and nobody else
spin_lock(&new_base->lock); * takes two locks at once, deadlock is not possible.
*/
spin_lock_irq(&new_base->lock);
spin_lock_nested(&old_base->lock, SINGLE_DEPTH_NESTING); spin_lock_nested(&old_base->lock, SINGLE_DEPTH_NESTING);
BUG_ON(old_base->running_timer); BUG_ON(old_base->running_timer);
...@@ -1452,8 +1454,7 @@ static void __cpuinit migrate_timers(int cpu) ...@@ -1452,8 +1454,7 @@ static void __cpuinit migrate_timers(int cpu)
} }
spin_unlock(&old_base->lock); spin_unlock(&old_base->lock);
spin_unlock(&new_base->lock); spin_unlock_irq(&new_base->lock);
local_irq_enable();
put_cpu_var(tvec_bases); put_cpu_var(tvec_bases);
} }
#endif /* CONFIG_HOTPLUG_CPU */ #endif /* CONFIG_HOTPLUG_CPU */
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment