mirror of https://gitee.com/openkylin/linux.git
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>
This commit is contained in:
parent
8def906044
commit
3650b57fdf
|
@ -101,7 +101,6 @@ struct tvec_base {
|
||||||
*/
|
*/
|
||||||
struct tvec_base boot_tvec_bases;
|
struct tvec_base boot_tvec_bases;
|
||||||
EXPORT_SYMBOL(boot_tvec_bases);
|
EXPORT_SYMBOL(boot_tvec_bases);
|
||||||
static DEFINE_PER_CPU(struct tvec_base, __tvec_bases);
|
|
||||||
|
|
||||||
static DEFINE_PER_CPU(struct tvec_base *, tvec_bases) = &boot_tvec_bases;
|
static DEFINE_PER_CPU(struct tvec_base *, tvec_bases) = &boot_tvec_bases;
|
||||||
|
|
||||||
|
@ -1038,6 +1037,8 @@ int try_to_del_timer_sync(struct timer_list *timer)
|
||||||
EXPORT_SYMBOL(try_to_del_timer_sync);
|
EXPORT_SYMBOL(try_to_del_timer_sync);
|
||||||
|
|
||||||
#ifdef CONFIG_SMP
|
#ifdef CONFIG_SMP
|
||||||
|
static DEFINE_PER_CPU(struct tvec_base, __tvec_bases);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* del_timer_sync - deactivate a timer and wait for the handler to finish.
|
* del_timer_sync - deactivate a timer and wait for the handler to finish.
|
||||||
* @timer: the timer to be deactivated
|
* @timer: the timer to be deactivated
|
||||||
|
@ -1591,12 +1592,10 @@ static void migrate_timers(int cpu)
|
||||||
spin_unlock_irq(&new_base->lock);
|
spin_unlock_irq(&new_base->lock);
|
||||||
put_cpu_var(tvec_bases);
|
put_cpu_var(tvec_bases);
|
||||||
}
|
}
|
||||||
#endif /* CONFIG_HOTPLUG_CPU */
|
|
||||||
|
|
||||||
static int timer_cpu_notify(struct notifier_block *self,
|
static int timer_cpu_notify(struct notifier_block *self,
|
||||||
unsigned long action, void *hcpu)
|
unsigned long action, void *hcpu)
|
||||||
{
|
{
|
||||||
#ifdef CONFIG_HOTPLUG_CPU
|
|
||||||
switch (action) {
|
switch (action) {
|
||||||
case CPU_DEAD:
|
case CPU_DEAD:
|
||||||
case CPU_DEAD_FROZEN:
|
case CPU_DEAD_FROZEN:
|
||||||
|
@ -1605,18 +1604,24 @@ static int timer_cpu_notify(struct notifier_block *self,
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
return NOTIFY_OK;
|
return NOTIFY_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
static struct notifier_block timers_nb = {
|
static inline void timer_register_cpu_notifier(void)
|
||||||
.notifier_call = timer_cpu_notify,
|
{
|
||||||
};
|
cpu_notifier(timer_cpu_notify, 0);
|
||||||
|
}
|
||||||
|
#else
|
||||||
|
static inline void timer_register_cpu_notifier(void) { }
|
||||||
|
#endif /* CONFIG_HOTPLUG_CPU */
|
||||||
|
|
||||||
static void __init init_timer_cpu(struct tvec_base *base, int cpu)
|
static void __init init_timer_cpu(struct tvec_base *base, int cpu)
|
||||||
{
|
{
|
||||||
int j;
|
int j;
|
||||||
|
|
||||||
|
BUG_ON(base != tbase_get_base(base));
|
||||||
|
|
||||||
base->cpu = cpu;
|
base->cpu = cpu;
|
||||||
per_cpu(tvec_bases, cpu) = base;
|
per_cpu(tvec_bases, cpu) = base;
|
||||||
spin_lock_init(&base->lock);
|
spin_lock_init(&base->lock);
|
||||||
|
@ -1643,8 +1648,10 @@ static void __init init_timer_cpus(void)
|
||||||
for_each_possible_cpu(cpu) {
|
for_each_possible_cpu(cpu) {
|
||||||
if (cpu == local_cpu)
|
if (cpu == local_cpu)
|
||||||
base = &boot_tvec_bases;
|
base = &boot_tvec_bases;
|
||||||
|
#ifdef CONFIG_SMP
|
||||||
else
|
else
|
||||||
base = per_cpu_ptr(&__tvec_bases, cpu);
|
base = per_cpu_ptr(&__tvec_bases, cpu);
|
||||||
|
#endif
|
||||||
|
|
||||||
init_timer_cpu(base, cpu);
|
init_timer_cpu(base, cpu);
|
||||||
}
|
}
|
||||||
|
@ -1657,7 +1664,7 @@ void __init init_timers(void)
|
||||||
|
|
||||||
init_timer_cpus();
|
init_timer_cpus();
|
||||||
init_timer_stats();
|
init_timer_stats();
|
||||||
register_cpu_notifier(&timers_nb);
|
timer_register_cpu_notifier();
|
||||||
open_softirq(TIMER_SOFTIRQ, run_timer_softirq);
|
open_softirq(TIMER_SOFTIRQ, run_timer_softirq);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue