Mass rename: ltt_*/ltt-* to LTTNG_*/LTTNG-*
[lttng-modules.git] / wrapper / trace-clock.h
CommitLineData
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>
21
22static inline u64 trace_clock_monotonic_wrapper(void)
23{
24 ktime_t ktime;
25
26 /*
27 * Refuse to trace from NMIs with this wrapper, because an NMI could
28 * nest over the xtime write seqlock and deadlock.
29 */
30 if (in_nmi())
97ca2c54 31 return (u64) -EIO;
f6c19f6e
MD
32
33 ktime = ktime_get();
34 return (u64) ktime.tv64;
35}
36
37static inline u32 trace_clock_read32(void)
38{
39 return (u32) trace_clock_monotonic_wrapper();
40}
41
42static inline u64 trace_clock_read64(void)
43{
44 return (u64) trace_clock_monotonic_wrapper();
45}
46
47static inline u64 trace_clock_frequency(void)
48{
49 return (u64)NSEC_PER_SEC;
50}
51
52static inline u32 trace_clock_freq_scale(void)
53{
54 return 1;
55}
56
57static inline int get_trace_clock(void)
58{
59 printk(KERN_WARNING "LTTng: Using mainline kernel monotonic clock.\n");
60 printk(KERN_WARNING " * NMIs will not be traced,\n");
61 printk(KERN_WARNING " * expect significant performance degradation compared to the\n");
62 printk(KERN_WARNING " LTTng trace clocks.\n");
cff67ebe
MD
63 printk(KERN_WARNING "Integration of the LTTng 0.x trace clocks into LTTng 2.0 is planned\n");
64 printk(KERN_WARNING "in a near future.\n");
f3bc08c5 65
cff67ebe 66#warning "LTTng: Using mainline kernel monotonic clock. NMIs will not be traced, and expect significant performance degradation compared to the LTTng trace clocks. Integration of the LTTng 0.x trace clocks into LTTng 2.0 is planned in a near future."
f3bc08c5 67
f6c19f6e
MD
68 return 0;
69}
70
71static inline void put_trace_clock(void)
72{
73}
74
75#endif /* CONFIG_HAVE_TRACE_CLOCK */
76
a90917c3 77#endif /* _LTTNG_TRACE_CLOCK_H */
This page took 0.026462 seconds and 4 git commands to generate.