[ltt-dev] [PATCH] We now rely on the lib userspace rcu API for the trace_clock_read64 function that will now use get_cycles which is architecture _aware_
David Goulet
david.goulet at polymtl.ca
Thu Jul 22 12:40:01 EDT 2010
---
include/ust/clock.h | 72 +++++----------------------------------------------
1 files changed, 7 insertions(+), 65 deletions(-)
diff --git a/include/ust/clock.h b/include/ust/clock.h
index cb8a663..27279b6 100644
--- a/include/ust/clock.h
+++ b/include/ust/clock.h
@@ -18,8 +18,6 @@
#ifndef UST_CLOCK_H
#define UST_CLOCK_H
-#include <time.h>
-#include <sys/time.h>
#include <ust/kcompat/kcompat.h>
/* TRACE CLOCK */
@@ -35,77 +33,21 @@
For merging traces with the kernel, a time source compatible with that of
the kernel is necessary.
- Instead of gettimeofday(), we are now using clock_gettime for better
- precision and monotonicity.
-
+ We now use the lib userspace RCU API for clock read.
*/
-#define TRACE_CLOCK_GENERIC
-#ifdef TRACE_CLOCK_GENERIC
-
-static __inline__ u64 trace_clock_read64(void)
-{
- struct timespec ts;
- u64 retval;
-
- clock_gettime(CLOCK_MONOTONIC, &ts);
- retval = ts.tv_sec;
- retval *= 1000000000;
- retval += ts.tv_nsec;
-
- return retval;
-}
-
-#else
-
-#if __i386 || __x86_64
-
-/* WARNING: Make sure to set frequency and scaling functions that will not
- * result in lttv timestamps (sec.nsec) with seconds greater than 2**32-1.
+/*
+ * Generic trace_clock_read64 function
*/
static __inline__ u64 trace_clock_read64(void)
{
- uint32_t low;
- uint32_t high;
- uint64_t retval;
- __asm__ volatile ("rdtsc\n" : "=a" (low), "=d" (high));
+ cycles_t retval;
- retval = high;
- retval <<= 32;
- return retval | low;
+ /* Lib urcu API for cycles count */
+ retval = get_cycles();
+ return (u64)retval;
}
-#endif /* __i386 || __x86_64 */
-
-#ifdef __PPC__
-
-static __inline__ u64 trace_clock_read64(void)
-{
- unsigned long tb_l;
- unsigned long tb_h;
- unsigned long tb_h2;
- u64 tb;
-
- __asm__ (
- "1:\n\t"
- "mftbu %[rhigh]\n\t"
- "mftb %[rlow]\n\t"
- "mftbu %[rhigh2]\n\t"
- "cmpw %[rhigh],%[rhigh2]\n\t"
- "bne 1b\n\t"
- : [rhigh] "=r" (tb_h), [rhigh2] "=r" (tb_h2), [rlow] "=r" (tb_l));
-
- tb = tb_h;
- tb <<= 32;
- tb |= tb_l;
-
- return tb;
-}
-
-#endif /* __PPC__ */
-
-#endif /* ! UST_TRACE_CLOCK_GENERIC */
-
static __inline__ u64 trace_clock_frequency(void)
{
return 1000000000LL;
--
1.7.0.4
More information about the lttng-dev
mailing list