aboutsummaryrefslogtreecommitdiffstats
path: root/kernel/time
diff options
context:
space:
mode:
authorPeter Zijlstra <peterz@infradead.org>2015-03-31 11:19:02 -0400
committerIngo Molnar <mingo@kernel.org>2015-04-02 11:46:21 -0400
commit3650b57fdf208bc0e36cbe7b5e0744bd0e0cf34d (patch)
treee62223fe5b72899adc985709b716587e404cc61b /kernel/time
parent8def906044c02edcedac79aa3d6310ab4d90c4d8 (diff)
timer: Further simplify the SMP and HOTPLUG logic
Remove one CONFIG_HOTPLUG_CPU #ifdef in trade for introducing one CONFIG_SMP #ifdef. The CONFIG_SMP ifdef avoids declaring the per-CPU __tvec_bases storage on UP systems since they already have boot_tvec_bases. Also (re)add a runtime check on the base alignment -- for the paranoid amongst us :-) Signed-off-by: Peter Zijlstra (Intel) <peterz@infradead.org> Acked-by: Viresh Kumar <viresh.kumar@linaro.org> Cc: Thomas Gleixner <tglx@linutronix.de> Link: http://lkml.kernel.org/r/fdd2d35e169bdc554ffa3fe77f77716298c75ada.1427814611.git.viresh.kumar@linaro.org Signed-off-by: Ingo Molnar <mingo@kernel.org>
Diffstat (limited to 'kernel/time')
-rw-r--r--kernel/time/timer.c23
1 files changed, 15 insertions, 8 deletions
diff --git a/kernel/time/timer.c b/kernel/time/timer.c
index 1feb9c7035c0..2ece3aa5069c 100644
--- a/kernel/time/timer.c
+++ b/kernel/time/timer.c
@@ -101,7 +101,6 @@ struct tvec_base {
101 */ 101 */
102struct tvec_base boot_tvec_bases; 102struct tvec_base boot_tvec_bases;
103EXPORT_SYMBOL(boot_tvec_bases); 103EXPORT_SYMBOL(boot_tvec_bases);
104static DEFINE_PER_CPU(struct tvec_base, __tvec_bases);
105 104
106static DEFINE_PER_CPU(struct tvec_base *, tvec_bases) = &boot_tvec_bases; 105static DEFINE_PER_CPU(struct tvec_base *, tvec_bases) = &boot_tvec_bases;
107 106
@@ -1038,6 +1037,8 @@ int try_to_del_timer_sync(struct timer_list *timer)
1038EXPORT_SYMBOL(try_to_del_timer_sync); 1037EXPORT_SYMBOL(try_to_del_timer_sync);
1039 1038
1040#ifdef CONFIG_SMP 1039#ifdef CONFIG_SMP
1040static DEFINE_PER_CPU(struct tvec_base, __tvec_bases);
1041
1041/** 1042/**
1042 * del_timer_sync - deactivate a timer and wait for the handler to finish. 1043 * del_timer_sync - deactivate a timer and wait for the handler to finish.
1043 * @timer: the timer to be deactivated 1044 * @timer: the timer to be deactivated
@@ -1591,12 +1592,10 @@ static void migrate_timers(int cpu)
1591 spin_unlock_irq(&new_base->lock); 1592 spin_unlock_irq(&new_base->lock);
1592 put_cpu_var(tvec_bases); 1593 put_cpu_var(tvec_bases);
1593} 1594}
1594#endif /* CONFIG_HOTPLUG_CPU */
1595 1595
1596static int timer_cpu_notify(struct notifier_block *self, 1596static int timer_cpu_notify(struct notifier_block *self,
1597 unsigned long action, void *hcpu) 1597 unsigned long action, void *hcpu)
1598{ 1598{
1599#ifdef CONFIG_HOTPLUG_CPU
1600 switch (action) { 1599 switch (action) {
1601 case CPU_DEAD: 1600 case CPU_DEAD:
1602 case CPU_DEAD_FROZEN: 1601 case CPU_DEAD_FROZEN:
@@ -1605,18 +1604,24 @@ static int timer_cpu_notify(struct notifier_block *self,
1605 default: 1604 default:
1606 break; 1605 break;
1607 } 1606 }
1608#endif 1607
1609 return NOTIFY_OK; 1608 return NOTIFY_OK;
1610} 1609}
1611 1610
1612static struct notifier_block timers_nb = { 1611static inline void timer_register_cpu_notifier(void)
1613 .notifier_call = timer_cpu_notify, 1612{
1614}; 1613 cpu_notifier(timer_cpu_notify, 0);
1614}
1615#else
1616static inline void timer_register_cpu_notifier(void) { }
1617#endif /* CONFIG_HOTPLUG_CPU */
1615 1618
1616static void __init init_timer_cpu(struct tvec_base *base, int cpu) 1619static void __init init_timer_cpu(struct tvec_base *base, int cpu)
1617{ 1620{
1618 int j; 1621 int j;
1619 1622
1623 BUG_ON(base != tbase_get_base(base));
1624
1620 base->cpu = cpu; 1625 base->cpu = cpu;
1621 per_cpu(tvec_bases, cpu) = base; 1626 per_cpu(tvec_bases, cpu) = base;
1622 spin_lock_init(&base->lock); 1627 spin_lock_init(&base->lock);
@@ -1643,8 +1648,10 @@ static void __init init_timer_cpus(void)
1643 for_each_possible_cpu(cpu) { 1648 for_each_possible_cpu(cpu) {
1644 if (cpu == local_cpu) 1649 if (cpu == local_cpu)
1645 base = &boot_tvec_bases; 1650 base = &boot_tvec_bases;
1651#ifdef CONFIG_SMP
1646 else 1652 else
1647 base = per_cpu_ptr(&__tvec_bases, cpu); 1653 base = per_cpu_ptr(&__tvec_bases, cpu);
1654#endif
1648 1655
1649 init_timer_cpu(base, cpu); 1656 init_timer_cpu(base, cpu);
1650 } 1657 }
@@ -1657,7 +1664,7 @@ void __init init_timers(void)
1657 1664
1658 init_timer_cpus(); 1665 init_timer_cpus();
1659 init_timer_stats(); 1666 init_timer_stats();
1660 register_cpu_notifier(&timers_nb); 1667 timer_register_cpu_notifier();
1661 open_softirq(TIMER_SOFTIRQ, run_timer_softirq); 1668 open_softirq(TIMER_SOFTIRQ, run_timer_softirq);
1662} 1669}
1663 1670