linuxppc-dev.lists.ozlabs.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] powerpc: inline ppc64_runlatch_off
@ 2010-08-06  4:53 Anton Blanchard
  2010-08-06  5:17 ` Benjamin Herrenschmidt
  2010-08-06  8:02 ` Olof Johansson
  0 siblings, 2 replies; 8+ messages in thread
From: Anton Blanchard @ 2010-08-06  4:53 UTC (permalink / raw)
  To: benh; +Cc: linuxppc-dev


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.

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

Index: powerpc.git/arch/powerpc/include/asm/reg.h
===================================================================
--- powerpc.git.orig/arch/powerpc/include/asm/reg.h	2010-08-04 19:55:38.910793475 +1000
+++ powerpc.git/arch/powerpc/include/asm/reg.h	2010-08-04 20:20:19.490751850 +1000
@@ -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
===================================================================
--- powerpc.git.orig/arch/powerpc/kernel/process.c	2010-08-04 19:55:38.890747120 +1000
+++ powerpc.git/arch/powerpc/kernel/process.c	2010-08-04 20:15:27.573241044 +1000
@@ -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
 

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

* Re: [PATCH] powerpc: inline ppc64_runlatch_off
  2010-08-06  4:53 [PATCH] powerpc: inline ppc64_runlatch_off Anton Blanchard
@ 2010-08-06  5:17 ` Benjamin Herrenschmidt
  2010-08-06  5:56   ` Anton Blanchard
  2010-08-06  8:02 ` Olof Johansson
  1 sibling, 1 reply; 8+ messages in thread
From: Benjamin Herrenschmidt @ 2010-08-06  5:17 UTC (permalink / raw)
  To: Anton Blanchard; +Cc: linuxppc-dev

On Fri, 2010-08-06 at 14:53 +1000, Anton Blanchard wrote:
> 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.

> Signed-off-by: Anton Blanchard <anton@samba.org>
> ---
> 
> Index: powerpc.git/arch/powerpc/include/asm/reg.h
> ===================================================================
> --- powerpc.git.orig/arch/powerpc/include/asm/reg.h	2010-08-04 19:55:38.910793475 +1000
> +++ powerpc.git/arch/powerpc/include/asm/reg.h	2010-08-04 20:20:19.490751850 +1000
> @@ -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
> ===================================================================
> --- powerpc.git.orig/arch/powerpc/kernel/process.c	2010-08-04 19:55:38.890747120 +1000
> +++ powerpc.git/arch/powerpc/kernel/process.c	2010-08-04 20:15:27.573241044 +1000
> @@ -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
>  

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

* Re: [PATCH] powerpc: inline ppc64_runlatch_off
  2010-08-06  5:17 ` Benjamin Herrenschmidt
@ 2010-08-06  5:56   ` Anton Blanchard
  2010-08-06  6:25     ` Benjamin Herrenschmidt
  0 siblings, 1 reply; 8+ messages in thread
From: Anton Blanchard @ 2010-08-06  5:56 UTC (permalink / raw)
  To: Benjamin Herrenschmidt; +Cc: linuxppc-dev


Hi Ben,

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

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

* Re: [PATCH] powerpc: inline ppc64_runlatch_off
  2010-08-06  5:56   ` Anton Blanchard
@ 2010-08-06  6:25     ` Benjamin Herrenschmidt
  2010-08-06  6:51       ` Anton Blanchard
  0 siblings, 1 reply; 8+ messages in thread
From: Benjamin Herrenschmidt @ 2010-08-06  6:25 UTC (permalink / raw)
  To: Anton Blanchard; +Cc: linuxppc-dev

On Fri, 2010-08-06 at 15:56 +1000, Anton Blanchard wrote:
> 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.

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

* Re: [PATCH] powerpc: inline ppc64_runlatch_off
  2010-08-06  6:25     ` Benjamin Herrenschmidt
@ 2010-08-06  6:51       ` Anton Blanchard
  0 siblings, 0 replies; 8+ messages in thread
From: Anton Blanchard @ 2010-08-06  6:51 UTC (permalink / raw)
  To: Benjamin Herrenschmidt; +Cc: linuxppc-dev


Hi,

> 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

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

* Re: [PATCH] powerpc: inline ppc64_runlatch_off
  2010-08-06  4:53 [PATCH] powerpc: inline ppc64_runlatch_off Anton Blanchard
  2010-08-06  5:17 ` Benjamin Herrenschmidt
@ 2010-08-06  8:02 ` Olof Johansson
  2010-08-06 13:28   ` Anton Blanchard
  1 sibling, 1 reply; 8+ messages in thread
From: Olof Johansson @ 2010-08-06  8:02 UTC (permalink / raw)
  To: Anton Blanchard; +Cc: linuxppc-dev

On Fri, Aug 06, 2010 at 02:53:15PM +1000, Anton Blanchard wrote:
> 
> 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.
> 
> Signed-off-by: Anton Blanchard <anton@samba.org>
> ---
> 
> Index: powerpc.git/arch/powerpc/include/asm/reg.h
> ===================================================================
> --- powerpc.git.orig/arch/powerpc/include/asm/reg.h	2010-08-04 19:55:38.910793475 +1000
> +++ powerpc.git/arch/powerpc/include/asm/reg.h	2010-08-04 20:20:19.490751850 +1000
> @@ -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);

No semicolon here.


-Olof

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

* Re: [PATCH] powerpc: inline ppc64_runlatch_off
  2010-08-06  8:02 ` Olof Johansson
@ 2010-08-06 13:28   ` Anton Blanchard
  2010-08-09  2:44     ` Olof Johansson
  0 siblings, 1 reply; 8+ messages in thread
From: Anton Blanchard @ 2010-08-06 13:28 UTC (permalink / raw)
  To: Olof Johansson; +Cc: linuxppc-dev

 
Hi Olof,

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

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

Index: powerpc.git/arch/powerpc/include/asm/reg.h
===================================================================
--- powerpc.git.orig/arch/powerpc/include/asm/reg.h	2010-08-04 19:55:38.910793475 +1000
+++ powerpc.git/arch/powerpc/include/asm/reg.h	2010-08-04 20:20:19.490751850 +1000
@@ -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
===================================================================
--- powerpc.git.orig/arch/powerpc/kernel/process.c	2010-08-04 19:55:38.890747120 +1000
+++ powerpc.git/arch/powerpc/kernel/process.c	2010-08-04 20:15:27.573241044 +1000
@@ -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
 

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

* Re: [PATCH] powerpc: inline ppc64_runlatch_off
  2010-08-06 13:28   ` Anton Blanchard
@ 2010-08-09  2:44     ` Olof Johansson
  0 siblings, 0 replies; 8+ messages in thread
From: Olof Johansson @ 2010-08-09  2:44 UTC (permalink / raw)
  To: Anton Blanchard; +Cc: linuxppc-dev

On Fri, Aug 06, 2010 at 11:28:19PM +1000, Anton Blanchard wrote:
>  
> Hi Olof,
> 
> > 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.
> 
> Signed-off-by: Anton Blanchard <anton@samba.org>

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


-Olof

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

end of thread, other threads:[~2010-08-09  2:44 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2010-08-06  4:53 [PATCH] powerpc: inline ppc64_runlatch_off Anton Blanchard
2010-08-06  5:17 ` Benjamin Herrenschmidt
2010-08-06  5:56   ` Anton Blanchard
2010-08-06  6:25     ` Benjamin Herrenschmidt
2010-08-06  6:51       ` Anton Blanchard
2010-08-06  8:02 ` Olof Johansson
2010-08-06 13:28   ` Anton Blanchard
2010-08-09  2:44     ` 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).