linuxppc-dev.lists.ozlabs.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 1/4] powerpc: Hide some system call labels from profile tools
@ 2012-04-05  4:23 Anton Blanchard
  2012-04-05  4:24 ` [PATCH 2/4] powerpc: No need to save XER in a system call Anton Blanchard
                   ` (2 more replies)
  0 siblings, 3 replies; 5+ messages in thread
From: Anton Blanchard @ 2012-04-05  4:23 UTC (permalink / raw)
  To: benh, paulus, linuxppc-dev


syscall_dotrace_cont and syscall_error_cont tend to complicate perf
output so make them local.

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

Index: linux-build/arch/powerpc/kernel/entry_64.S
===================================================================
--- linux-build.orig/arch/powerpc/kernel/entry_64.S	2012-03-22 22:41:21.209137690 +1100
+++ linux-build/arch/powerpc/kernel/entry_64.S	2012-03-22 22:47:04.479314599 +1100
@@ -154,7 +154,7 @@ END_FW_FTR_SECTION_IFSET(FW_FEATURE_SPLP
 	ld	r10,TI_FLAGS(r11)
 	andi.	r11,r10,_TIF_SYSCALL_T_OR_A
 	bne-	syscall_dotrace
-syscall_dotrace_cont:
+.Lsyscall_dotrace_cont:
 	cmpldi	0,r0,NR_syscalls
 	bge-	syscall_enosys
 
@@ -211,7 +211,7 @@ syscall_exit:
 	cmpld	r3,r11
 	ld	r5,_CCR(r1)
 	bge-	syscall_error
-syscall_error_cont:
+.Lsyscall_error_cont:
 	ld	r7,_NIP(r1)
 BEGIN_FTR_SECTION
 	stdcx.	r0,0,r1			/* to clear the reservation */
@@ -246,7 +246,7 @@ syscall_error:
 	oris	r5,r5,0x1000	/* Set SO bit in CR */
 	neg	r3,r3
 	std	r5,_CCR(r1)
-	b	syscall_error_cont
+	b	.Lsyscall_error_cont
 	
 /* Traced system call support */
 syscall_dotrace:
@@ -268,7 +268,7 @@ syscall_dotrace:
 	addi	r9,r1,STACK_FRAME_OVERHEAD
 	clrrdi	r10,r1,THREAD_SHIFT
 	ld	r10,TI_FLAGS(r10)
-	b	syscall_dotrace_cont
+	b	.Lsyscall_dotrace_cont
 
 syscall_enosys:
 	li	r3,-ENOSYS

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

* [PATCH 2/4] powerpc: No need to save XER in a system call
  2012-04-05  4:23 [PATCH 1/4] powerpc: Hide some system call labels from profile tools Anton Blanchard
@ 2012-04-05  4:24 ` Anton Blanchard
  2012-04-05  4:25 ` [PATCH 3/4] powerpc: Better scheduling of CR save code in system call path Anton Blanchard
  2012-04-05  4:26 ` [PATCH 4/4] powerpc: No need to preserve count register across system call Anton Blanchard
  2 siblings, 0 replies; 5+ messages in thread
From: Anton Blanchard @ 2012-04-05  4:24 UTC (permalink / raw)
  To: benh, paulus; +Cc: linuxppc-dev


The XER is a volatile register so there is no need to save and restore
it over a system call - zero it out in the exception stack frame
instead.

This should fix a 5 cycle stall of the mfxer/std seen on POWER7.

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

Index: linux-build/arch/powerpc/kernel/entry_64.S
===================================================================
--- linux-build.orig/arch/powerpc/kernel/entry_64.S	2012-03-22 22:47:04.479314599 +1100
+++ linux-build/arch/powerpc/kernel/entry_64.S	2012-03-22 22:47:08.379384827 +1100
@@ -82,6 +82,7 @@ system_call_common:
 	std	r11,GPR10(r1)
 	std	r11,GPR11(r1)
 	std	r11,GPR12(r1)
+	std	r11,_XER(r1)
 	std	r9,GPR13(r1)
 	mfcr	r9
 	mflr	r10
@@ -89,9 +90,7 @@ system_call_common:
 	std	r9,_CCR(r1)
 	std	r10,_LINK(r1)
 	std	r11,_TRAP(r1)
-	mfxer	r9
 	mfctr	r10
-	std	r9,_XER(r1)
 	std	r10,_CTR(r1)
 	std	r3,ORIG_GPR3(r1)
 	ld	r2,PACATOC(r13)

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

* [PATCH 3/4] powerpc: Better scheduling of CR save code in system call path
  2012-04-05  4:23 [PATCH 1/4] powerpc: Hide some system call labels from profile tools Anton Blanchard
  2012-04-05  4:24 ` [PATCH 2/4] powerpc: No need to save XER in a system call Anton Blanchard
@ 2012-04-05  4:25 ` Anton Blanchard
  2012-04-05 13:44   ` [PATCH 3/4 v2] " Anton Blanchard
  2012-04-05  4:26 ` [PATCH 4/4] powerpc: No need to preserve count register across system call Anton Blanchard
  2 siblings, 1 reply; 5+ messages in thread
From: Anton Blanchard @ 2012-04-05  4:25 UTC (permalink / raw)
  To: benh, paulus; +Cc: linuxppc-dev


At the moment system call entry looks like:

crclr	so
...
mfcr	r9
...
std	r9,_CCR(r1)

commit bd19c8994a82 ([POWERPC] system call micro optimisation) put
some space between the crclr and mfcr in order to avoid a stall.

There is still a stall seen between the mfcr and std. We can avoid
the crclr by doing it in a GPR with rlwinm which gives us more room
to better schedule the sequence.

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

Index: linux-build/arch/powerpc/kernel/entry_64.S
===================================================================
--- linux-build.orig/arch/powerpc/kernel/entry_64.S	2012-03-22 22:47:08.379384827 +1100
+++ linux-build/arch/powerpc/kernel/entry_64.S	2012-03-22 22:47:15.023504471 +1100
@@ -63,15 +63,9 @@ system_call_common:
 	std	r0,GPR0(r1)
 	std	r10,GPR1(r1)
 	ACCOUNT_CPU_USER_ENTRY(r10, r11)
-	/*
-	 * This "crclr so" clears CR0.SO, which is the error indication on
-	 * return from this system call.  There must be no cmp instruction
-	 * between it and the "mfcr r9" below, otherwise if XER.SO is set,
-	 * CR0.SO will get set, causing all system calls to appear to fail.
-	 */
-	crclr	so
 	std	r2,GPR2(r1)
 	std	r3,GPR3(r1)
+	mfcr	r2
 	std	r4,GPR4(r1)
 	std	r5,GPR5(r1)
 	std	r6,GPR6(r1)
@@ -84,15 +78,19 @@ system_call_common:
 	std	r11,GPR12(r1)
 	std	r11,_XER(r1)
 	std	r9,GPR13(r1)
-	mfcr	r9
 	mflr	r10
 	li	r11,0xc01
-	std	r9,_CCR(r1)
+	/*
+	 * This clears CR0.SO, which is the error indication on return
+	 * from this system call.
+	 */
+	rlwinm	r2,r2,0,4,2
 	std	r10,_LINK(r1)
 	std	r11,_TRAP(r1)
 	mfctr	r10
 	std	r10,_CTR(r1)
 	std	r3,ORIG_GPR3(r1)
+	std	r2,_CCR(r1)
 	ld	r2,PACATOC(r13)
 	addi	r9,r1,STACK_FRAME_OVERHEAD
 	ld	r11,exception_marker@toc(r2)

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

* [PATCH 4/4] powerpc: No need to preserve count register across system call
  2012-04-05  4:23 [PATCH 1/4] powerpc: Hide some system call labels from profile tools Anton Blanchard
  2012-04-05  4:24 ` [PATCH 2/4] powerpc: No need to save XER in a system call Anton Blanchard
  2012-04-05  4:25 ` [PATCH 3/4] powerpc: Better scheduling of CR save code in system call path Anton Blanchard
@ 2012-04-05  4:26 ` Anton Blanchard
  2 siblings, 0 replies; 5+ messages in thread
From: Anton Blanchard @ 2012-04-05  4:26 UTC (permalink / raw)
  To: benh, paulus; +Cc: linuxppc-dev


The count register is volatile so we don't need to preserve it.
Store zero to the entry in the exception frame.

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

Index: linux-build/arch/powerpc/kernel/entry_64.S
===================================================================
--- linux-build.orig/arch/powerpc/kernel/entry_64.S	2012-03-22 22:47:15.023504471 +1100
+++ linux-build/arch/powerpc/kernel/entry_64.S	2012-03-22 22:47:17.899556262 +1100
@@ -77,6 +77,7 @@ system_call_common:
 	std	r11,GPR11(r1)
 	std	r11,GPR12(r1)
 	std	r11,_XER(r1)
+	std	r11,_CTR(r1)
 	std	r9,GPR13(r1)
 	mflr	r10
 	li	r11,0xc01
@@ -87,8 +88,6 @@ system_call_common:
 	rlwinm	r2,r2,0,4,2
 	std	r10,_LINK(r1)
 	std	r11,_TRAP(r1)
-	mfctr	r10
-	std	r10,_CTR(r1)
 	std	r3,ORIG_GPR3(r1)
 	std	r2,_CCR(r1)
 	ld	r2,PACATOC(r13)

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

* [PATCH 3/4 v2] powerpc: Better scheduling of CR save code in system call path
  2012-04-05  4:25 ` [PATCH 3/4] powerpc: Better scheduling of CR save code in system call path Anton Blanchard
@ 2012-04-05 13:44   ` Anton Blanchard
  0 siblings, 0 replies; 5+ messages in thread
From: Anton Blanchard @ 2012-04-05 13:44 UTC (permalink / raw)
  To: benh, paulus; +Cc: linuxppc-dev


At the moment system call entry looks like:

crclr	so
...
mfcr	r9
...
std	r9,_CCR(r1)

commit bd19c8994a82 ([POWERPC] system call micro optimisation) put
some space between the crclr and mfcr in order to avoid a stall.

There is still a stall seen between the mfcr and std. We can avoid
the crclr by doing it in a GPR with rlwinm which gives us more room
to better schedule the sequence.

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

v2:

Milton pointed out that rlwinm copies the low 32bits into the top
32bits and this might confuse ptracers. We tossed around a few ideas
but his suggestion of using rldimi sounds good to me.

Index: linux-build/arch/powerpc/kernel/entry_64.S
===================================================================
--- linux-build.orig/arch/powerpc/kernel/entry_64.S	2012-04-05 14:03:05.123678148 +1000
+++ linux-build/arch/powerpc/kernel/entry_64.S	2012-04-05 23:38:09.182681076 +1000
@@ -63,15 +63,9 @@ system_call_common:
 	std	r0,GPR0(r1)
 	std	r10,GPR1(r1)
 	ACCOUNT_CPU_USER_ENTRY(r10, r11)
-	/*
-	 * This "crclr so" clears CR0.SO, which is the error indication on
-	 * return from this system call.  There must be no cmp instruction
-	 * between it and the "mfcr r9" below, otherwise if XER.SO is set,
-	 * CR0.SO will get set, causing all system calls to appear to fail.
-	 */
-	crclr	so
 	std	r2,GPR2(r1)
 	std	r3,GPR3(r1)
+	mfcr	r2
 	std	r4,GPR4(r1)
 	std	r5,GPR5(r1)
 	std	r6,GPR6(r1)
@@ -84,15 +78,19 @@ system_call_common:
 	std	r11,GPR12(r1)
 	std	r11,_XER(r1)
 	std	r9,GPR13(r1)
-	mfcr	r9
 	mflr	r10
+	/*
+	 * This clears CR0.SO (bit 28), which is the error indication on
+	 * return from this system call.
+	 */
+	rldimi	r2,r11,28,(63-28)
 	li	r11,0xc01
-	std	r9,_CCR(r1)
 	std	r10,_LINK(r1)
 	std	r11,_TRAP(r1)
 	mfctr	r10
 	std	r10,_CTR(r1)
 	std	r3,ORIG_GPR3(r1)
+	std	r2,_CCR(r1)
 	ld	r2,PACATOC(r13)
 	addi	r9,r1,STACK_FRAME_OVERHEAD
 	ld	r11,exception_marker@toc(r2)

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

end of thread, other threads:[~2012-04-05 13:44 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2012-04-05  4:23 [PATCH 1/4] powerpc: Hide some system call labels from profile tools Anton Blanchard
2012-04-05  4:24 ` [PATCH 2/4] powerpc: No need to save XER in a system call Anton Blanchard
2012-04-05  4:25 ` [PATCH 3/4] powerpc: Better scheduling of CR save code in system call path Anton Blanchard
2012-04-05 13:44   ` [PATCH 3/4 v2] " Anton Blanchard
2012-04-05  4:26 ` [PATCH 4/4] powerpc: No need to preserve count register across system call Anton Blanchard

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).