X-Git-Url: http://git.lttng.org./?a=blobdiff_plain;f=share%2Fkernelcompat.h;h=219ee11836c494e1c0fb3bfb8e0879f096bb7a12;hb=79cb25368d3d2069c7189c45ccb751c9f9fcc59d;hp=b0c77e0972a66f8d03235494f4e5be72fcbc281a;hpb=772030fed323e388da467735cf4b5e8781acb710;p=lttng-ust.git diff --git a/share/kernelcompat.h b/share/kernelcompat.h index b0c77e09..219ee118 100644 --- a/share/kernelcompat.h +++ b/share/kernelcompat.h @@ -150,6 +150,23 @@ static __inline__ int get_count_order(unsigned int count) /* TRACE CLOCK */ +/* There are two types of clocks that can be used. + - TSC based clock + - gettimeofday() clock + + Microbenchmarks on Linux 2.6.30 on Core2 Duo 3GHz (functions are inlined): + Calls (100000000) to tsc(): 4004035641 cycles or 40 cycles/call + Calls (100000000) to gettimeofday(): 9723158352 cycles or 97 cycles/call + + For merging traces with the kernel, a time source compatible with that of + the kernel is necessary. + +*/ + +#if 0 +/* 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. + */ static inline u64 trace_clock_read64(void) { uint32_t low; @@ -161,19 +178,20 @@ static inline u64 trace_clock_read64(void) retval <<= 32; return retval | low; } +#endif -//static inline u64 trace_clock_read64(void) -//{ -// struct timeval tv; -// u64 retval; -// -// gettimeofday(&tv, NULL); -// retval = tv.tv_sec; -// retval *= 1000000; -// retval += tv.tv_usec; -// -// return retval; -//} +static inline u64 trace_clock_read64(void) +{ + struct timeval tv; + u64 retval; + + gettimeofday(&tv, NULL); + retval = tv.tv_sec; + retval *= 1000000; + retval += tv.tv_usec; + + return retval; +} static inline u64 trace_clock_frequency(void) {