public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Peter Zijlstra <peterz@infradead.org>
To: Viresh Kumar <viresh.kumar@linaro.org>
Cc: Ingo Molnar <mingo@redhat.com>,
	Thomas Gleixner <tglx@linutronix.de>,
	linaro-kernel@lists.linaro.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH 0/3] timers: Allocate per-cpu tvec_base's statically
Date: Mon, 30 Mar 2015 10:18:26 +0200	[thread overview]
Message-ID: <20150330081826.GN23123@twins.programming.kicks-ass.net> (raw)
In-Reply-To: <cover.1427691098.git.viresh.kumar@linaro.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 <peterz@infradead.org>
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) <peterz@infradead.org>
---
 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);
 }
 

  parent reply	other threads:[~2015-03-30  8:18 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-03-30  5:17 [PATCH 0/3] timers: Allocate per-cpu tvec_base's statically Viresh Kumar
2015-03-30  5:17 ` [PATCH 1/3] timer: " Viresh Kumar
2015-03-31  7:45   ` Ingo Molnar
2015-03-31 11:32     ` Viresh Kumar
2015-03-30  5:17 ` [PATCH 2/3] timer: Limit the scope of __tvec_bases to init_timers_cpu() Viresh Kumar
2015-03-30  5:17 ` [PATCH 3/3] timer: Don't initialize tvec_base on hotplug Viresh Kumar
2015-03-30  8:18 ` Peter Zijlstra [this message]
2015-03-30  9:55   ` [PATCH 0/3] timers: Allocate per-cpu tvec_base's statically Viresh Kumar
2015-03-30 10:27     ` Peter Zijlstra
2015-03-30 10:33       ` Viresh Kumar

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20150330081826.GN23123@twins.programming.kicks-ass.net \
    --to=peterz@infradead.org \
    --cc=linaro-kernel@lists.linaro.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mingo@redhat.com \
    --cc=tglx@linutronix.de \
    --cc=viresh.kumar@linaro.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox