Patchwork [01/18] powerpc: Make decrementer interrupt robust against offlined CPUs

login
register
mail settings
Submitter Benjamin Herrenschmidt
Date March 8, 2011, 6:37 a.m.
Message ID <1299566250-10516-2-git-send-email-benh@kernel.crashing.org>
Download mbox | patch
Permalink /patch/85909/
State Accepted, archived
Headers show

Comments

Benjamin Herrenschmidt - March 8, 2011, 6:37 a.m.
With some implementations, it is possible that a timer interrupt
occurs every few seconds on an offline CPU. In this case, just
re-arm the decrementer and return immediately

Signed-off-by: Benjamin Herrenschmidt <benh@kernel.crashing.org>
---
 arch/powerpc/kernel/time.c |   15 +++++++++++----
 1 files changed, 11 insertions(+), 4 deletions(-)
Michael Ellerman - March 10, 2011, 8:01 a.m.
On Tue, 2011-03-08 at 17:37 +1100, Benjamin Herrenschmidt wrote:
> With some implementations, it is possible that a timer interrupt
> occurs every few seconds on an offline CPU. In this case, just
> re-arm the decrementer and return immediately
> 
> Signed-off-by: Benjamin Herrenschmidt <benh@kernel.crashing.org>
> ---
>  arch/powerpc/kernel/time.c |   15 +++++++++++----
>  1 files changed, 11 insertions(+), 4 deletions(-)
> 
> diff --git a/arch/powerpc/kernel/time.c b/arch/powerpc/kernel/time.c
> index 09d31db..ecebc7c 100644
> --- a/arch/powerpc/kernel/time.c
> +++ b/arch/powerpc/kernel/time.c
> @@ -577,14 +577,21 @@ void timer_interrupt(struct pt_regs * regs)
>  	struct clock_event_device *evt = &decrementer->event;
>  	u64 now;
>  
> +	/* Ensure a positive value is written to the decrementer, or else
> +	 * some CPUs will continuue to take decrementer exceptions
                                  ^

Seeing as you're moving it anyway, and maybe a full-stop.

cheers

Patch

diff --git a/arch/powerpc/kernel/time.c b/arch/powerpc/kernel/time.c
index 09d31db..ecebc7c 100644
--- a/arch/powerpc/kernel/time.c
+++ b/arch/powerpc/kernel/time.c
@@ -577,14 +577,21 @@  void timer_interrupt(struct pt_regs * regs)
 	struct clock_event_device *evt = &decrementer->event;
 	u64 now;
 
+	/* Ensure a positive value is written to the decrementer, or else
+	 * some CPUs will continuue to take decrementer exceptions
+	 */
+	set_dec(DECREMENTER_MAX);
+
+	/* Some implementations of hotplug will get timer interrupts while
+	 * offline, just ignore these
+	 */
+	if (!cpu_online(smp_processor_id()))
+		return;
+
 	trace_timer_interrupt_entry(regs);
 
 	__get_cpu_var(irq_stat).timer_irqs++;
 
-	/* Ensure a positive value is written to the decrementer, or else
-	 * some CPUs will continuue to take decrementer exceptions */
-	set_dec(DECREMENTER_MAX);
-
 #if defined(CONFIG_PPC32) && defined(CONFIG_PMAC)
 	if (atomic_read(&ppc_n_lost_interrupts) != 0)
 		do_IRQ(regs);