linuxppc-dev.lists.ozlabs.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] Fix PMU + soft interrupt disable bug
@ 2008-03-17  4:27 Anton Blanchard
  2008-03-17  8:51 ` Benjamin Herrenschmidt
  2008-03-18  0:36 ` Olof Johansson
  0 siblings, 2 replies; 3+ messages in thread
From: Anton Blanchard @ 2008-03-17  4:27 UTC (permalink / raw)
  To: linuxppc-dev; +Cc: paulus


Since the PMU is an NMI now, it can come at any time we are only soft
disabled. We must hard disable around the two places we allow the kernel
stack SLB and r1 to go out of sync. Otherwise the PMU exception can
force a kernel stack SLB into another slot.

Signed-off-by: Anton Blanchard <anton@samba.org>
---

Index: kernel/arch/powerpc/mm/slb.c
===================================================================
--- kernel.orig/arch/powerpc/mm/slb.c	2007-11-05 11:22:03.000000000 -0600
+++ kernel/arch/powerpc/mm/slb.c	2007-11-05 18:09:45.000000000 -0600
@@ -113,6 +113,12 @@ void slb_flush_and_rebolt(void)
 		slb_shadow_update(get_paca()->kstack, lflags, 2);
 	}
 
+	/*
+	 * We can't take a PMU exception in the following code, so hard
+	 * disable interrupts.
+	 */
+	hard_irq_disable();
+
 	/* We need to do this all in asm, so we're sure we don't touch
 	 * the stack between the slbia and rebolting it. */
 	asm volatile("isync\n"
Index: kernel/arch/powerpc/kernel/process.c
===================================================================
--- kernel.orig/arch/powerpc/kernel/process.c	2007-11-05 18:10:44.000000000 -0600
+++ kernel/arch/powerpc/kernel/process.c	2007-11-05 18:10:46.000000000 -0600
@@ -331,6 +331,12 @@ struct task_struct *__switch_to(struct t
 	account_process_vtime(current);
 	calculate_steal_time();
 
+	/*
+	 * We can't take a PMU exception inside _switch() since there is a
+	 * window where the kernel stack SLB and the kernel stack are out
+	 * of sync. Hard disable here.
+	 */
+	hard_irq_disable();
 	last = _switch(old_thread, new_thread);
 
 	local_irq_restore(flags);

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] Fix PMU + soft interrupt disable bug
  2008-03-17  4:27 [PATCH] Fix PMU + soft interrupt disable bug Anton Blanchard
@ 2008-03-17  8:51 ` Benjamin Herrenschmidt
  2008-03-18  0:36 ` Olof Johansson
  1 sibling, 0 replies; 3+ messages in thread
From: Benjamin Herrenschmidt @ 2008-03-17  8:51 UTC (permalink / raw)
  To: Anton Blanchard; +Cc: linuxppc-dev, paulus


On Sun, 2008-03-16 at 23:27 -0500, Anton Blanchard wrote:
> Since the PMU is an NMI now, it can come at any time we are only soft
> disabled. We must hard disable around the two places we allow the kernel
> stack SLB and r1 to go out of sync. Otherwise the PMU exception can
> force a kernel stack SLB into another slot.
> 
> Signed-off-by: Anton Blanchard <anton@samba.org>

Acked-by: Benjamin Herrenschmidt <benh@kernel.crashing.org>
---

> ---
> 
> Index: kernel/arch/powerpc/mm/slb.c
> ===================================================================
> --- kernel.orig/arch/powerpc/mm/slb.c	2007-11-05 11:22:03.000000000 -0600
> +++ kernel/arch/powerpc/mm/slb.c	2007-11-05 18:09:45.000000000 -0600
> @@ -113,6 +113,12 @@ void slb_flush_and_rebolt(void)
>  		slb_shadow_update(get_paca()->kstack, lflags, 2);
>  	}
>  
> +	/*
> +	 * We can't take a PMU exception in the following code, so hard
> +	 * disable interrupts.
> +	 */
> +	hard_irq_disable();
> +
>  	/* We need to do this all in asm, so we're sure we don't touch
>  	 * the stack between the slbia and rebolting it. */
>  	asm volatile("isync\n"
> Index: kernel/arch/powerpc/kernel/process.c
> ===================================================================
> --- kernel.orig/arch/powerpc/kernel/process.c	2007-11-05 18:10:44.000000000 -0600
> +++ kernel/arch/powerpc/kernel/process.c	2007-11-05 18:10:46.000000000 -0600
> @@ -331,6 +331,12 @@ struct task_struct *__switch_to(struct t
>  	account_process_vtime(current);
>  	calculate_steal_time();
>  
> +	/*
> +	 * We can't take a PMU exception inside _switch() since there is a
> +	 * window where the kernel stack SLB and the kernel stack are out
> +	 * of sync. Hard disable here.
> +	 */
> +	hard_irq_disable();
>  	last = _switch(old_thread, new_thread);
>  
>  	local_irq_restore(flags);
> 
> 
> _______________________________________________
> Linuxppc-dev mailing list
> Linuxppc-dev@ozlabs.org
> https://ozlabs.org/mailman/listinfo/linuxppc-dev

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] Fix PMU + soft interrupt disable bug
  2008-03-17  4:27 [PATCH] Fix PMU + soft interrupt disable bug Anton Blanchard
  2008-03-17  8:51 ` Benjamin Herrenschmidt
@ 2008-03-18  0:36 ` Olof Johansson
  1 sibling, 0 replies; 3+ messages in thread
From: Olof Johansson @ 2008-03-18  0:36 UTC (permalink / raw)
  To: Anton Blanchard; +Cc: linuxppc-dev, paulus

On Sun, Mar 16, 2008 at 11:27:09PM -0500, Anton Blanchard wrote:
> 
> Since the PMU is an NMI now, it can come at any time we are only soft
> disabled. We must hard disable around the two places we allow the kernel
> stack SLB and r1 to go out of sync. Otherwise the PMU exception can
> force a kernel stack SLB into another slot.
> 
> Signed-off-by: Anton Blanchard <anton@samba.org>

Acked-by: Olof Johansson <olof@lixom.net>

This fixes some problems we've seen with multi-slb hits when running
oprofile.

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2008-03-18  0:29 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2008-03-17  4:27 [PATCH] Fix PMU + soft interrupt disable bug Anton Blanchard
2008-03-17  8:51 ` Benjamin Herrenschmidt
2008-03-18  0:36 ` Olof Johansson

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).