From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753297AbbC3ISh (ORCPT ); Mon, 30 Mar 2015 04:18:37 -0400 Received: from casper.infradead.org ([85.118.1.10]:59051 "EHLO casper.infradead.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753005AbbC3ISf (ORCPT ); Mon, 30 Mar 2015 04:18:35 -0400 Date: Mon, 30 Mar 2015 10:18:26 +0200 From: Peter Zijlstra To: Viresh Kumar Cc: Ingo Molnar , Thomas Gleixner , linaro-kernel@lists.linaro.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH 0/3] timers: Allocate per-cpu tvec_base's statically Message-ID: <20150330081826.GN23123@twins.programming.kicks-ass.net> References: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.5.21 (2012-12-30) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Mon, Mar 30, 2015 at 10:47:16AM +0530, Viresh Kumar wrote: > Hi Ingo/Thomas, > > Here are few cleanups around timer-core initialization. The first one is > suggested by Peter Zijlstra [1] and the other two make few more changes in order > to simplify it. I did the below on top; I'll sit on these patches for a wee while in the hope of the blackfin maintainer explaining his reasons for wrecking ____cacheline_aligned. --- Subject: timer: Further simplify SMP and HOTPLUG logic From: Peter Zijlstra Date: Mon Mar 30 10:09:19 CEST 2015 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) --- kernel/time/timer.c | 28 +++++++++++++--------------- 1 file changed, 13 insertions(+), 15 deletions(-) --- a/kernel/time/timer.c +++ b/kernel/time/timer.c @@ -1580,12 +1580,10 @@ static void migrate_timers(int cpu) spin_unlock_irq(&new_base->lock); put_cpu_var(tvec_bases); } -#endif /* CONFIG_HOTPLUG_CPU */ static int timer_cpu_notify(struct notifier_block *self, unsigned long action, void *hcpu) { -#ifdef CONFIG_HOTPLUG_CPU switch (action) { case CPU_DEAD: case CPU_DEAD_FROZEN: @@ -1594,18 +1592,17 @@ static int timer_cpu_notify(struct notif default: break; } -#endif + return NOTIFY_OK; } - -static struct notifier_block timers_nb = { - .notifier_call = timer_cpu_notify, -}; +#endif /* CONFIG_HOTPLUG_CPU */ static void __init init_timer_cpu(struct tvec_base *base, int cpu) { int j; + BUG_ON(base != tbase_get_base(base)); + base->cpu = cpu; per_cpu(tvec_bases, cpu) = base; spin_lock_init(&base->lock); @@ -1625,18 +1622,19 @@ static void __init init_timer_cpu(struct static void __init init_timer_cpus(void) { - /* Used for all CPUs, except boot CPU (which uses boot_tvec_bases) */ - static DEFINE_PER_CPU(struct tvec_base, __tvec_bases); - struct tvec_base *base; int local_cpu = smp_processor_id(); + struct tvec_base *base; int cpu; for_each_possible_cpu(cpu) { - if (likely(cpu != local_cpu)) - base = per_cpu_ptr(&__tvec_bases, cpu); - else + if (cpu == local_cpu) base = &boot_tvec_bases; - +#ifdef CONFIG_SMP + else { + static DEFINE_PER_CPU(struct tvec_base, __tvec_bases); + base = per_cpu_ptr(&__tvec_bases, cpu); + } +#endif init_timer_cpu(base, cpu); } } @@ -1648,7 +1646,7 @@ void __init init_timers(void) init_timer_cpus(); init_timer_stats(); - register_cpu_notifier(&timers_nb); + cpu_notifier(timer_cpu_notify, 0); open_softirq(TIMER_SOFTIRQ, run_timer_softirq); }