Mirror of the lttng-dev mailing list
 help / color / mirror / Atom feed
* [ltt-dev] [URCU PATCH] Optimize caa_get_cycles() for PowerPC64
@ 2011-09-08 16:02 Tulio Magno Quites Machado Filho
  2011-09-09  5:34 ` Mathieu Desnoyers
  0 siblings, 1 reply; 2+ messages in thread
From: Tulio Magno Quites Machado Filho @ 2011-09-08 16:02 UTC (permalink / raw)


Make caa_get_cycles() read from the Time Base register with only 1 instruction.

Signed-off-by: Tulio Magno Quites Machado Filho <tuliom at linux.vnet.ibm.com>
---
 urcu/arch/ppc.h |   11 +++++++++++
 1 files changed, 11 insertions(+), 0 deletions(-)

diff --git a/urcu/arch/ppc.h b/urcu/arch/ppc.h
index d7317bb..2b606d0 100644
--- a/urcu/arch/ppc.h
+++ b/urcu/arch/ppc.h
@@ -48,10 +48,20 @@ extern "C" {
 		rval;					\
 	})
 
+#define mftb()						\
+	({						\
+		unsigned long long rval;		\
+		asm volatile("mftb %0" : "=r" (rval));	\
+		rval;					\
+	})
+
 typedef unsigned long long cycles_t;
 
 static inline cycles_t caa_get_cycles (void)
 {
+#ifdef __powerpc64__
+	return (cycles_t) mftb();
+#else
 	long h, l;
 
 	for (;;) {
@@ -62,6 +72,7 @@ static inline cycles_t caa_get_cycles (void)
 		if (mftbu() == h)
 			return (((cycles_t) h) << 32) + l;
 	}
+#endif
 }
 
 #ifdef __cplusplus 
-- 
1.7.4.4





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

* [ltt-dev] [URCU PATCH] Optimize caa_get_cycles() for PowerPC64
  2011-09-08 16:02 [ltt-dev] [URCU PATCH] Optimize caa_get_cycles() for PowerPC64 Tulio Magno Quites Machado Filho
@ 2011-09-09  5:34 ` Mathieu Desnoyers
  0 siblings, 0 replies; 2+ messages in thread
From: Mathieu Desnoyers @ 2011-09-09  5:34 UTC (permalink / raw)


* Tulio Magno Quites Machado Filho (tuliom at linux.vnet.ibm.com) wrote:
> Make caa_get_cycles() read from the Time Base register with only 1 instruction.

Merged,

I did a small coding style change to the patch, turning the
#if/#else/#endif into multiple function implementations rather than
affecting the cody of the same function.

Thanks!

Mathieu

> 
> Signed-off-by: Tulio Magno Quites Machado Filho <tuliom at linux.vnet.ibm.com>
> ---
>  urcu/arch/ppc.h |   11 +++++++++++
>  1 files changed, 11 insertions(+), 0 deletions(-)
> 
> diff --git a/urcu/arch/ppc.h b/urcu/arch/ppc.h
> index d7317bb..2b606d0 100644
> --- a/urcu/arch/ppc.h
> +++ b/urcu/arch/ppc.h
> @@ -48,10 +48,20 @@ extern "C" {
>  		rval;					\
>  	})
>  
> +#define mftb()						\
> +	({						\
> +		unsigned long long rval;		\
> +		asm volatile("mftb %0" : "=r" (rval));	\
> +		rval;					\
> +	})
> +
>  typedef unsigned long long cycles_t;
>  
>  static inline cycles_t caa_get_cycles (void)
>  {
> +#ifdef __powerpc64__
> +	return (cycles_t) mftb();
> +#else
>  	long h, l;
>  
>  	for (;;) {
> @@ -62,6 +72,7 @@ static inline cycles_t caa_get_cycles (void)
>  		if (mftbu() == h)
>  			return (((cycles_t) h) << 32) + l;
>  	}
> +#endif
>  }
>  
>  #ifdef __cplusplus 
> -- 
> 1.7.4.4
> 
> 
> _______________________________________________
> ltt-dev mailing list
> ltt-dev at lists.casi.polymtl.ca
> http://lists.casi.polymtl.ca/cgi-bin/mailman/listinfo/ltt-dev
> 

-- 
Mathieu Desnoyers
Operating System Efficiency R&D Consultant
EfficiOS Inc.
http://www.efficios.com




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

end of thread, other threads:[~2011-09-09  5:34 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2011-09-08 16:02 [ltt-dev] [URCU PATCH] Optimize caa_get_cycles() for PowerPC64 Tulio Magno Quites Machado Filho
2011-09-09  5:34 ` Mathieu Desnoyers

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox