X-Git-Url: http://git.lttng.org/?a=blobdiff_plain;f=include%2Fust%2Fclock.h;h=ae44becae58f8bbbd9521e1df54bc7867d1992ab;hb=d4419b81b243bc3a6bdd4a09b3ca2216d044a1c7;hp=5e8f755b9c08573d1fd7ec110156fe3ea71bdaf4;hpb=9edd34bd25f52dd39b354a84f02697254121aefd;p=lttng-ust.git diff --git a/include/ust/clock.h b/include/ust/clock.h index 5e8f755b..ae44beca 100644 --- a/include/ust/clock.h +++ b/include/ust/clock.h @@ -1,9 +1,11 @@ -/* Copyright (C) 2010 Pierre-Marc Fournier +/* + * Copyright (C) 2010 Pierre-Marc Fournier + * Copyright (C) 2011 Mathieu Desnoyers * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. + * License as published by the Free Software Foundation; version 2.1 of + * the License. * * This library is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of @@ -26,30 +28,10 @@ /* 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. - - Instead of gettimeofday(), we are now using clock_gettime for better - precision and monotonicity. -*/ - -/* Only available for x86 arch */ -#define CLOCK_TRACE_FREQ 14 -#define CLOCK_TRACE 15 -union lttng_timespec { - struct timespec ts; - uint64_t lttng_ts; -}; - -extern int ust_clock_source; +/* + * Currently using the kernel MONOTONIC clock, waiting for kernel-side + * LTTng to implement mmap'd trace clock. + */ /* Choosing correct trace clock */ @@ -57,39 +39,17 @@ static __inline__ uint64_t trace_clock_read64(void) { struct timespec ts; uint64_t retval; - union lttng_timespec *lts = (union lttng_timespec *) &ts; - clock_gettime(ust_clock_source, &ts); - /* - * Clock source can change when loading the binary (tracectl.c) - * so we must check if the clock source has changed before - * returning the correct value - */ - if (likely(ust_clock_source == CLOCK_TRACE)) { - retval = lts->lttng_ts; - } else { /* CLOCK_MONOTONIC */ - retval = ts.tv_sec; - retval *= 1000000000; - retval += ts.tv_nsec; - } + clock_gettime(CLOCK_MONOTONIC, &ts); + retval = ts.tv_sec; + retval *= 1000000000; + retval += ts.tv_nsec; return retval; } #if __i386__ || __x86_64__ static __inline__ uint64_t trace_clock_frequency(void) -{ - struct timespec ts; - union lttng_timespec *lts = (union lttng_timespec *) &ts; - - if (likely(ust_clock_source == CLOCK_TRACE)) { - clock_gettime(CLOCK_TRACE_FREQ, &ts); - return lts->lttng_ts; - } - return 1000000000LL; -} -#else /* #if __i386__ || __x86_64__ */ -static __inline__ uint64_t trace_clock_frequency(void) { return 1000000000LL; }