diff options
author | Oleg Nesterov <oleg@tv-sign.ru> | 2008-08-20 19:46:04 -0400 |
---|---|---|
committer | Ingo Molnar <mingo@elte.hu> | 2008-08-21 07:34:54 -0400 |
commit | d82f0b0f6f1a0a25afc288fb7135b1601fe6df18 (patch) | |
tree | 29991ab508ccfbacec6f6b2a7df714ee9d5c5fb5 | |
parent | 6a55617ed5d1aa62b850de2cf66f5ede2eef4825 (diff) |
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: Oleg Nesterov <oleg@tv-sign.ru>
Acked-by: Steven Rostedt <srostedt@redhat.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Ingo Molnar <mingo@elte.hu>
-rw-r--r-- | kernel/hrtimer.c | 11 | ||||
-rw-r--r-- | kernel/timer.c | 11 |
2 files changed, 12 insertions, 10 deletions
diff --git a/kernel/hrtimer.c b/kernel/hrtimer.c index b8e4dce80a74..03ea1378c43b 100644 --- a/kernel/hrtimer.c +++ b/kernel/hrtimer.c | |||
@@ -1620,9 +1620,11 @@ static void migrate_hrtimers(int cpu) | |||
1620 | new_base = &get_cpu_var(hrtimer_bases); | 1620 | new_base = &get_cpu_var(hrtimer_bases); |
1621 | 1621 | ||
1622 | tick_cancel_sched_timer(cpu); | 1622 | tick_cancel_sched_timer(cpu); |
1623 | 1623 | /* | |
1624 | local_irq_disable(); | 1624 | * The caller is globally serialized and nobody else |
1625 | spin_lock(&new_base->lock); | 1625 | * takes two locks at once, deadlock is not possible. |
1626 | */ | ||
1627 | spin_lock_irq(&new_base->lock); | ||
1626 | spin_lock_nested(&old_base->lock, SINGLE_DEPTH_NESTING); | 1628 | spin_lock_nested(&old_base->lock, SINGLE_DEPTH_NESTING); |
1627 | 1629 | ||
1628 | for (i = 0; i < HRTIMER_MAX_CLOCK_BASES; i++) { | 1630 | for (i = 0; i < HRTIMER_MAX_CLOCK_BASES; i++) { |
@@ -1631,8 +1633,7 @@ static void migrate_hrtimers(int cpu) | |||
1631 | } | 1633 | } |
1632 | 1634 | ||
1633 | spin_unlock(&old_base->lock); | 1635 | spin_unlock(&old_base->lock); |
1634 | spin_unlock(&new_base->lock); | 1636 | spin_unlock_irq(&new_base->lock); |
1635 | local_irq_enable(); | ||
1636 | put_cpu_var(hrtimer_bases); | 1637 | put_cpu_var(hrtimer_bases); |
1637 | } | 1638 | } |
1638 | #endif /* CONFIG_HOTPLUG_CPU */ | 1639 | #endif /* CONFIG_HOTPLUG_CPU */ |
diff --git a/kernel/timer.c b/kernel/timer.c index 03bc7f1f1593..e8019cc3418d 100644 --- a/kernel/timer.c +++ b/kernel/timer.c | |||
@@ -1435,9 +1435,11 @@ static void __cpuinit migrate_timers(int cpu) | |||
1435 | BUG_ON(cpu_online(cpu)); | 1435 | BUG_ON(cpu_online(cpu)); |
1436 | old_base = per_cpu(tvec_bases, cpu); | 1436 | old_base = per_cpu(tvec_bases, cpu); |
1437 | new_base = get_cpu_var(tvec_bases); | 1437 | new_base = get_cpu_var(tvec_bases); |
1438 | 1438 | /* | |
1439 | local_irq_disable(); | 1439 | * The caller is globally serialized and nobody else |
1440 | spin_lock(&new_base->lock); | 1440 | * takes two locks at once, deadlock is not possible. |
1441 | */ | ||
1442 | spin_lock_irq(&new_base->lock); | ||
1441 | spin_lock_nested(&old_base->lock, SINGLE_DEPTH_NESTING); | 1443 | spin_lock_nested(&old_base->lock, SINGLE_DEPTH_NESTING); |
1442 | 1444 | ||
1443 | BUG_ON(old_base->running_timer); | 1445 | BUG_ON(old_base->running_timer); |
@@ -1452,8 +1454,7 @@ static void __cpuinit migrate_timers(int cpu) | |||
1452 | } | 1454 | } |
1453 | 1455 | ||
1454 | spin_unlock(&old_base->lock); | 1456 | spin_unlock(&old_base->lock); |
1455 | spin_unlock(&new_base->lock); | 1457 | spin_unlock_irq(&new_base->lock); |
1456 | local_irq_enable(); | ||
1457 | put_cpu_var(tvec_bases); | 1458 | put_cpu_var(tvec_bases); |
1458 | } | 1459 | } |
1459 | #endif /* CONFIG_HOTPLUG_CPU */ | 1460 | #endif /* CONFIG_HOTPLUG_CPU */ |