Commit | Line | Data |
---|---|---|
f6c19f6e MD |
1 | /* |
2 | * Copyright (C) 2011 Mathieu Desnoyers (mathieu.desnoyers@efficios.com) | |
3 | * | |
4 | * Contains LTTng trace clock mapping to LTTng trace clock or mainline monotonic | |
5 | * clock. This wrapper depends on CONFIG_HIGH_RES_TIMERS=y. | |
6 | * | |
7 | * Dual LGPL v2.1/GPL v2 license. | |
8 | */ | |
9 | ||
a90917c3 MD |
10 | #ifndef _LTTNG_TRACE_CLOCK_H |
11 | #define _LTTNG_TRACE_CLOCK_H | |
f6c19f6e MD |
12 | |
13 | #ifdef CONFIG_HAVE_TRACE_CLOCK | |
14 | #include <linux/trace-clock.h> | |
15 | #else /* CONFIG_HAVE_TRACE_CLOCK */ | |
16 | ||
17 | #include <linux/hardirq.h> | |
18 | #include <linux/ktime.h> | |
19 | #include <linux/time.h> | |
20 | #include <linux/hrtimer.h> | |
a82c63f1 | 21 | #include "random.h" |
f6c19f6e MD |
22 | |
23 | static inline u64 trace_clock_monotonic_wrapper(void) | |
24 | { | |
25 | ktime_t ktime; | |
26 | ||
27 | /* | |
28 | * Refuse to trace from NMIs with this wrapper, because an NMI could | |
29 | * nest over the xtime write seqlock and deadlock. | |
30 | */ | |
31 | if (in_nmi()) | |
97ca2c54 | 32 | return (u64) -EIO; |
f6c19f6e MD |
33 | |
34 | ktime = ktime_get(); | |
35 | return (u64) ktime.tv64; | |
36 | } | |
37 | ||
38 | static inline u32 trace_clock_read32(void) | |
39 | { | |
40 | return (u32) trace_clock_monotonic_wrapper(); | |
41 | } | |
42 | ||
43 | static inline u64 trace_clock_read64(void) | |
44 | { | |
45 | return (u64) trace_clock_monotonic_wrapper(); | |
46 | } | |
47 | ||
a3ccff4f | 48 | static inline u64 trace_clock_freq(void) |
f6c19f6e | 49 | { |
a3ccff4f | 50 | return (u64) NSEC_PER_SEC; |
f6c19f6e MD |
51 | } |
52 | ||
a82c63f1 | 53 | static inline int trace_clock_uuid(char *uuid) |
f6c19f6e | 54 | { |
a82c63f1 | 55 | return wrapper_get_bootid(uuid); |
f6c19f6e MD |
56 | } |
57 | ||
58 | static inline int get_trace_clock(void) | |
59 | { | |
22f8d33a MD |
60 | /* |
61 | * LTTng: Using mainline kernel monotonic clock. NMIs will not be | |
62 | * traced, and expect significant performance degradation compared to | |
63 | * the LTTng trace clocks. Integration of the LTTng 0.x trace clocks | |
64 | * into LTTng 2.0 is planned in a near future. | |
65 | */ | |
f6c19f6e MD |
66 | printk(KERN_WARNING "LTTng: Using mainline kernel monotonic clock.\n"); |
67 | printk(KERN_WARNING " * NMIs will not be traced,\n"); | |
68 | printk(KERN_WARNING " * expect significant performance degradation compared to the\n"); | |
69 | printk(KERN_WARNING " LTTng trace clocks.\n"); | |
cff67ebe MD |
70 | printk(KERN_WARNING "Integration of the LTTng 0.x trace clocks into LTTng 2.0 is planned\n"); |
71 | printk(KERN_WARNING "in a near future.\n"); | |
f3bc08c5 | 72 | |
f6c19f6e MD |
73 | return 0; |
74 | } | |
75 | ||
76 | static inline void put_trace_clock(void) | |
77 | { | |
78 | } | |
79 | ||
80 | #endif /* CONFIG_HAVE_TRACE_CLOCK */ | |
81 | ||
a90917c3 | 82 | #endif /* _LTTNG_TRACE_CLOCK_H */ |