d4b6a9ddc1e2768a219beed14d0c6336b4d58b13
1 /* Copyright (C) 2010 Pierre-Marc Fournier
3 * This library is free software; you can redistribute it and/or
4 * modify it under the terms of the GNU Lesser General Public
5 * License as published by the Free Software Foundation; either
6 * version 2.1 of the License, or (at your option) any later version.
8 * This library is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
11 * Lesser General Public License for more details.
13 * You should have received a copy of the GNU Lesser General Public
14 * License along with this library; if not, write to the Free Software
15 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
22 #include <ust/kcompat/kcompat.h>
26 /* There are two types of clocks that can be used.
28 - gettimeofday() clock
30 Microbenchmarks on Linux 2.6.30 on Core2 Duo 3GHz (functions are inlined):
31 Calls (100000000) to tsc(): 4004035641 cycles or 40 cycles/call
32 Calls (100000000) to gettimeofday(): 9723158352 cycles or 97 cycles/call
34 For merging traces with the kernel, a time source compatible with that of
35 the kernel is necessary.
39 #define TRACE_CLOCK_GENERIC
40 #ifdef TRACE_CLOCK_GENERIC
42 static __inline__ u64
trace_clock_read64(void)
47 gettimeofday(&tv
, NULL
);
57 #if __i386 || __x86_64
59 /* WARNING: Make sure to set frequency and scaling functions that will not
60 * result in lttv timestamps (sec.nsec) with seconds greater than 2**32-1.
62 static __inline__ u64
trace_clock_read64(void)
67 __asm__
volatile ("rdtsc\n" : "=a" (low
), "=d" (high
));
74 #endif /* __i386 || __x86_64 */
78 static __inline__ u64
trace_clock_read64(void)
90 "cmpw %[rhigh],%[rhigh2]\n\t"
92 : [rhigh
] "=r" (tb_h
), [rhigh2
] "=r" (tb_h2
), [rlow
] "=r" (tb_l
));
103 #endif /* ! UST_TRACE_CLOCK_GENERIC */
105 static __inline__ u64
trace_clock_frequency(void)
110 static __inline__ u32
trace_clock_freq_scale(void)
115 #endif /* UST_CLOCK_H */
This page took 0.057335 seconds and 4 git commands to generate.