Skip to contentSkip to conversation

powerpc: inline ppc64_runlatch_off

PATCH In review Anton Blanchard 3 participants 8 messages Aug 6, 2010 – Aug 9, 2010 PowerPC

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 powerpc: inline ppc64_runlatch_off

I'm sick of seeing ppc64_runlatch_off in our profiles, so inline the heavily used part of it into the callers. To avoid a mess of circular includes I didn't add it as an inline function.

---

arch/powerpc/include/asm/reg.h +8 -1
Index: powerpc.git/arch/powerpc/include/asm/reg.h
===================================================================
@@ -951,7 +951,14 @@
 #ifdef CONFIG_PPC64
 
 extern void ppc64_runlatch_on(void);
-extern void ppc64_runlatch_off(void);
+extern void __ppc64_runlatch_off(void);
+
+#define ppc64_runlatch_off()					\
+	do {							\
+		if (cpu_has_feature(CPU_FTR_CTRL) &&		\
+		    test_thread_flag(TIF_RUNLATCH))		\
+			__ppc64_runlatch_off();			\
+	} while (0);
 
 extern unsigned long scom970_read(unsigned int address);
 extern void scom970_write(unsigned int address, unsigned long value);
arch/powerpc/kernel/process.c +6 -8
Index: powerpc.git/arch/powerpc/kernel/process.c
===================================================================
@@ -1198,19 +1198,17 @@ void ppc64_runlatch_on(void)
 	}
 }
 
-void ppc64_runlatch_off(void)
+void __ppc64_runlatch_off(void)
 {
 	unsigned long ctrl;
 
-	if (cpu_has_feature(CPU_FTR_CTRL) && test_thread_flag(TIF_RUNLATCH)) {
-		HMT_medium();
+	HMT_medium();
 
-		clear_thread_flag(TIF_RUNLATCH);
+	clear_thread_flag(TIF_RUNLATCH);
 
-		ctrl = mfspr(SPRN_CTRLF);
-		ctrl &= ~CTRL_RUNLATCH;
-		mtspr(SPRN_CTRLT, ctrl);
-	}
+	ctrl = mfspr(SPRN_CTRLF);
+	ctrl &= ~CTRL_RUNLATCH;
+	mtspr(SPRN_CTRLT, ctrl);
 }
 #endif
 
#1 lore raw
Quoted 3 lines · Anton Blanchard

I'm sick of seeing ppc64_runlatch_off in our profiles, so inline the heavily used part of it into the callers. To avoid a mess of circular includes I didn't add it as an inline function.

Considering that it's just an asm instruction or two, should we make it inline asm and have it NOPed out instead using the feature sections ?

Cheers,
Ben.

Quoted 53 lines

---

Index: powerpc.git/arch/powerpc/include/asm/reg.h
===================================================================

arch/powerpc/include/asm/reg.h +8 -1
@@ -951,7 +951,14 @@
 #ifdef CONFIG_PPC64
 
 extern void ppc64_runlatch_on(void);
-extern void ppc64_runlatch_off(void);
+extern void __ppc64_runlatch_off(void);
+
+#define ppc64_runlatch_off()					\
+	do {							\
+		if (cpu_has_feature(CPU_FTR_CTRL) &&		\
+		    test_thread_flag(TIF_RUNLATCH))		\
+			__ppc64_runlatch_off();			\
+	} while (0);
 
 extern unsigned long scom970_read(unsigned int address);
 extern void scom970_write(unsigned int address, unsigned long value);

Index: powerpc.git/arch/powerpc/kernel/process.c
===================================================================

arch/powerpc/kernel/process.c +6 -8
@@ -1198,19 +1198,17 @@ void ppc64_runlatch_on(void)
 	}
 }
 
-void ppc64_runlatch_off(void)
+void __ppc64_runlatch_off(void)
 {
 	unsigned long ctrl;
 
-	if (cpu_has_feature(CPU_FTR_CTRL) && test_thread_flag(TIF_RUNLATCH)) {
-		HMT_medium();
+	HMT_medium();
 
-		clear_thread_flag(TIF_RUNLATCH);
+	clear_thread_flag(TIF_RUNLATCH);
 
-		ctrl = mfspr(SPRN_CTRLF);
-		ctrl &= ~CTRL_RUNLATCH;
-		mtspr(SPRN_CTRLT, ctrl);
-	}
+	ctrl = mfspr(SPRN_CTRLF);
+	ctrl &= ~CTRL_RUNLATCH;
+	mtspr(SPRN_CTRLT, ctrl);
 }
 #endif
 
#2 lore raw

Hi Ben,

Quoted 6 lines
Quoted 3 lines

I'm sick of seeing ppc64_runlatch_off in our profiles, so inline the heavily used part of it into the callers. To avoid a mess of circular includes I didn't add it as an inline function.

Considering that it's just an asm instruction or two, should we make it inline asm and have it NOPed out instead using the feature sections ?

Unfortunately we still need to prevent continual writes to it with a per thread flag because on some CPUs a write to the SPR in low priority mode will stall another SMT thread. So we could get rid of the cpu feature comparison but we would still need the thread bit check (or perhaps replace it with a per cpu variable).

Anton

#3 lore raw
Quoted 5 lines · Anton Blanchard

Unfortunately we still need to prevent continual writes to it with a per thread flag because on some CPUs a write to the SPR in low priority mode will stall another SMT thread. So we could get rid of the cpu feature comparison but we would still need the thread bit check (or perhaps replace it with a per cpu variable).

remind me why we need to do that runlatch thing on these CPUs at all ?

Cheers,
Ben.

#4 lore raw

Hi,

Quoted 1 line

remind me why we need to do that runlatch thing on these CPUs at all ?

The PMU uses it so events can be constructed that count only non idle cycles. I think the power management hardware on POWER6 and POWER7 also use the runlatch state to determine how busy a CPU is.

Anton

#5 lore raw
In reply to Anton Blanchard
Quoted 15 lines · Anton Blanchard

I'm sick of seeing ppc64_runlatch_off in our profiles, so inline the heavily used part of it into the callers. To avoid a mess of circular includes I didn't add it as an inline function.

---

Index: powerpc.git/arch/powerpc/include/asm/reg.h
===================================================================

arch/powerpc/include/asm/reg.h +0 -0
@@ -951,7 +951,14 @@
 #ifdef CONFIG_PPC64
 

arch/powerpc/include/asm/reg.h line 961

Quoted 10 lines
arch/powerpc/include/asm/reg.h +8 -1
 extern void ppc64_runlatch_on(void);
-extern void ppc64_runlatch_off(void);
+extern void __ppc64_runlatch_off(void);
+
+#define ppc64_runlatch_off()					\
+	do {							\
+		if (cpu_has_feature(CPU_FTR_CTRL) &&		\
+		    test_thread_flag(TIF_RUNLATCH))		\
+			__ppc64_runlatch_off();			\
+	} while (0);

No semicolon here.

-Olof

#6 lore raw

Hi Olof,

Quoted 1 line

No semicolon here.

Nice catch!

Anton

I'm sick of seeing ppc64_runlatch_off in our profiles, so inline it into the callers. To avoid a mess of circular includes I didn't add it as an inline function.

---

arch/powerpc/include/asm/reg.h +8 -1
Index: powerpc.git/arch/powerpc/include/asm/reg.h
===================================================================
@@ -951,7 +951,14 @@
 #ifdef CONFIG_PPC64
 
 extern void ppc64_runlatch_on(void);
-extern void ppc64_runlatch_off(void);
+extern void __ppc64_runlatch_off(void);
+
+#define ppc64_runlatch_off()					\
+	do {							\
+		if (cpu_has_feature(CPU_FTR_CTRL) &&		\
+		    test_thread_flag(TIF_RUNLATCH))		\
+			__ppc64_runlatch_off();			\
+	} while (0)
 
 extern unsigned long scom970_read(unsigned int address);
 extern void scom970_write(unsigned int address, unsigned long value);
arch/powerpc/kernel/process.c +6 -8
Index: powerpc.git/arch/powerpc/kernel/process.c
===================================================================
@@ -1198,19 +1198,17 @@ void ppc64_runlatch_on(void)
 	}
 }
 
-void ppc64_runlatch_off(void)
+void __ppc64_runlatch_off(void)
 {
 	unsigned long ctrl;
 
-	if (cpu_has_feature(CPU_FTR_CTRL) && test_thread_flag(TIF_RUNLATCH)) {
-		HMT_medium();
+	HMT_medium();
 
-		clear_thread_flag(TIF_RUNLATCH);
+	clear_thread_flag(TIF_RUNLATCH);
 
-		ctrl = mfspr(SPRN_CTRLF);
-		ctrl &= ~CTRL_RUNLATCH;
-		mtspr(SPRN_CTRLT, ctrl);
-	}
+	ctrl = mfspr(SPRN_CTRLF);
+	ctrl &= ~CTRL_RUNLATCH;
+	mtspr(SPRN_CTRLT, ctrl);
 }
 #endif