All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 1/4] powerpc/64s: context switch leave interrupts hard enabled for radix
@ 2017-06-08 15:36 Nicholas Piggin
  2017-06-08 15:36 ` [PATCH 2/4] powerpc/64: context switch avoid reservation-clearing instruction Nicholas Piggin
                   ` (3 more replies)
  0 siblings, 4 replies; 7+ messages in thread
From: Nicholas Piggin @ 2017-06-08 15:36 UTC (permalink / raw)
  To: linuxppc-dev; +Cc: Nicholas Piggin

Commit 4387e9ff25 ("[POWERPC] Fix PMU + soft interrupt disable bug")
hard disabled interrupts over the low level context switch, because
the SLB management can't cope with a PMU interrupt accesing the stack
in that window.

Radix based kernel mapping does not use the SLB so it does not require
interrupts hard disabled here.

This is worth 1-2% in context switch performance on POWER9.

Signed-off-by: Nicholas Piggin <npiggin@gmail.com>
---
 arch/powerpc/kernel/entry_64.S |  8 ++++++++
 arch/powerpc/kernel/process.c  | 14 ++++++++------
 2 files changed, 16 insertions(+), 6 deletions(-)

diff --git a/arch/powerpc/kernel/entry_64.S b/arch/powerpc/kernel/entry_64.S
index 6f70ea821a07..91f9fdc2d027 100644
--- a/arch/powerpc/kernel/entry_64.S
+++ b/arch/powerpc/kernel/entry_64.S
@@ -607,6 +607,14 @@ END_MMU_FTR_SECTION_IFSET(MMU_FTR_1T_SEGMENT)
 	   top of the kernel stack. */
 	addi	r7,r7,THREAD_SIZE-SWITCH_FRAME_SIZE
 
+	/*
+	 * PMU interrupts in radix may come in here. They will use r1, not
+	 * PACAKSAVE, so this stack switch will not cause a problem. They
+	 * will store to the process stack, which may then be migrated to
+	 * another CPU. However the rq lock release on this CPU paired with
+	 * the rq lock acquire on the new CPU before the stack becomes
+	 * active on the new CPU, will order those stores.
+	 */
 	mr	r1,r8		/* start using new stack pointer */
 	std	r7,PACAKSAVE(r13)
 
diff --git a/arch/powerpc/kernel/process.c b/arch/powerpc/kernel/process.c
index 5cbb8b1faf7e..45faa9a32a01 100644
--- a/arch/powerpc/kernel/process.c
+++ b/arch/powerpc/kernel/process.c
@@ -1199,12 +1199,14 @@ struct task_struct *__switch_to(struct task_struct *prev,
 
 	__switch_to_tm(prev, new);
 
-	/*
-	 * 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();
+	if (!radix_enabled()) {
+		/*
+		 * 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();
+	}
 
 	/*
 	 * Call restore_sprs() before calling _switch(). If we move it after
-- 
2.11.0

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

end of thread, other threads:[~2017-06-19 12:25 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2017-06-08 15:36 [PATCH 1/4] powerpc/64s: context switch leave interrupts hard enabled for radix Nicholas Piggin
2017-06-08 15:36 ` [PATCH 2/4] powerpc/64: context switch avoid reservation-clearing instruction Nicholas Piggin
2017-06-14 13:07   ` Michael Ellerman
2017-06-08 15:36 ` [PATCH 3/4] powerpc/64: context switch an hwsync instruction can be avoided Nicholas Piggin
2017-06-08 20:12   ` Peter Zijlstra
2017-06-08 15:36 ` [PATCH 4/4] powerpc/64s: context switch avoid cpabort Nicholas Piggin
2017-06-19 12:25 ` [1/4] powerpc/64s: context switch leave interrupts hard enabled for radix Michael Ellerman

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.