Rename LTTng instrumentation macros
[lttng-modules.git] / instrumentation / events / lttng-module / lock.h
CommitLineData
7c68b363
AG
1#include <linux/version.h>
2
b283666f 3#undef TRACE_SYSTEM
7c68b363 4#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,33))
b283666f 5#define TRACE_SYSTEM lock
7c68b363
AG
6#else
7#define TRACE_SYSTEM lockdep
8#define TRACE_INCLUDE_FILE lock
9#if defined(_TRACE_LOCKDEP_H)
3bc29f0a 10#define LTTNG_TRACE_LOCK_H
7c68b363
AG
11#endif
12#endif
b283666f 13
3bc29f0a
MD
14#if !defined(LTTNG_TRACE_LOCK_H) || defined(TRACE_HEADER_MULTI_READ)
15#define LTTNG_TRACE_LOCK_H
b283666f
PW
16
17#include <linux/lockdep.h>
3bc29f0a 18#include "../../../probes/lttng-tracepoint-event.h"
b283666f
PW
19
20#ifdef CONFIG_LOCKDEP
21
3bc29f0a 22LTTNG_TRACEPOINT_EVENT(lock_acquire,
b283666f
PW
23
24 TP_PROTO(struct lockdep_map *lock, unsigned int subclass,
25 int trylock, int read, int check,
26 struct lockdep_map *next_lock, unsigned long ip),
27
28 TP_ARGS(lock, subclass, trylock, read, check, next_lock, ip),
29
30 TP_STRUCT__entry(
31 __field(unsigned int, flags)
32 __string(name, lock->name)
7c68b363 33#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,34))
b283666f 34 __field(void *, lockdep_addr)
7c68b363 35#endif
b283666f
PW
36 ),
37
38 TP_fast_assign(
d3ac4d63
PW
39 tp_assign(flags, (trylock ? 1 : 0) | (read ? 2 : 0))
40 tp_strcpy(name, lock->name)
7c68b363 41#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,34))
d3ac4d63 42 tp_assign(lockdep_addr, lock)
7c68b363 43#endif
b283666f
PW
44 ),
45
7c68b363 46#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,34))
b283666f 47 TP_printk("%p %s%s%s", __entry->lockdep_addr,
7c68b363
AG
48#else
49 TP_printk("%s%s%s",
50#endif
b283666f
PW
51 (__entry->flags & 1) ? "try " : "",
52 (__entry->flags & 2) ? "read " : "",
53 __get_str(name))
54)
55
7c68b363
AG
56#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,35))
57
3bc29f0a 58LTTNG_TRACEPOINT_EVENT_CLASS(lock,
b283666f
PW
59
60 TP_PROTO(struct lockdep_map *lock, unsigned long ip),
61
62 TP_ARGS(lock, ip),
63
64 TP_STRUCT__entry(
65 __string( name, lock->name )
66 __field( void *, lockdep_addr )
67 ),
68
69 TP_fast_assign(
d3ac4d63
PW
70 tp_strcpy(name, lock->name)
71 tp_assign(lockdep_addr, lock)
b283666f
PW
72 ),
73
74 TP_printk("%p %s", __entry->lockdep_addr, __get_str(name))
75)
76
3bc29f0a 77LTTNG_TRACEPOINT_EVENT_INSTANCE(lock, lock_release,
b283666f
PW
78
79 TP_PROTO(struct lockdep_map *lock, unsigned long ip),
80
81 TP_ARGS(lock, ip)
82)
83
84#ifdef CONFIG_LOCK_STAT
85
3bc29f0a 86LTTNG_TRACEPOINT_EVENT_INSTANCE(lock, lock_contended,
b283666f
PW
87
88 TP_PROTO(struct lockdep_map *lock, unsigned long ip),
89
90 TP_ARGS(lock, ip)
91)
92
3bc29f0a 93LTTNG_TRACEPOINT_EVENT_INSTANCE(lock, lock_acquired,
b283666f
PW
94
95 TP_PROTO(struct lockdep_map *lock, unsigned long ip),
96
97 TP_ARGS(lock, ip)
98)
99
100#endif
7c68b363
AG
101
102#else /* #if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,35)) */
103
3bc29f0a 104LTTNG_TRACEPOINT_EVENT(lock_release,
7c68b363
AG
105
106 TP_PROTO(struct lockdep_map *lock, int nested, unsigned long ip),
107
108 TP_ARGS(lock, nested, ip),
109
110 TP_STRUCT__entry(
111 __string( name, lock->name )
112#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,34))
113 __field( void *, lockdep_addr )
114#endif
115 ),
116
117 TP_fast_assign(
118 tp_strcpy(name, lock->name)
119#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,34))
120 tp_assign(lockdep_addr, lock)
121#endif
122 ),
123
124#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,34))
125 TP_printk("%p %s", __entry->lockdep_addr, __get_str(name))
126#else
127 TP_printk("%s", __get_str(name))
128#endif
129)
130
131#ifdef CONFIG_LOCK_STAT
132
3bc29f0a 133LTTNG_TRACEPOINT_EVENT(lock_contended,
7c68b363
AG
134
135 TP_PROTO(struct lockdep_map *lock, unsigned long ip),
136
137 TP_ARGS(lock, ip),
138
139 TP_STRUCT__entry(
140 __string( name, lock->name )
141#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,34))
142 __field( void *, lockdep_addr )
143#endif
144 ),
145
146 TP_fast_assign(
147 tp_strcpy(name, lock->name)
148#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,34))
149 tp_assign(lockdep_addr, lock)
150#endif
151 ),
152
153#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,34))
154 TP_printk("%p %s", __entry->lockdep_addr, __get_str(name))
155#else
156 TP_printk("%s", __get_str(name))
157#endif
158)
159
3bc29f0a 160LTTNG_TRACEPOINT_EVENT(lock_acquired,
7c68b363
AG
161
162 TP_PROTO(struct lockdep_map *lock, unsigned long ip, s64 waittime),
163
164 TP_ARGS(lock, ip, waittime),
165
166 TP_STRUCT__entry(
167 __string( name, lock->name )
168#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,34))
169 __field( s64, wait_nsec )
170 __field( void *, lockdep_addr )
171#else
172 __field(unsigned long, wait_usec)
173 __field(unsigned long, wait_nsec_rem)
174#endif
175 ),
176
177 TP_fast_assign(
178 tp_strcpy(name, lock->name)
179#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,34))
180 tp_assign(wait_nsec, waittime)
181 tp_assign(lockdep_addr, lock)
182#else
183 tp_assign(wait_usec, (unsigned long)waittime)
184 tp_assign(wait_nsec_rem, do_div(waittime, NSEC_PER_USEC))
185#endif
186 ),
187
188#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,34))
189 TP_printk("%p %s (%llu ns)", __entry->lockdep_addr,
190 __get_str(name), __entry->wait_nsec)
191#else
192 TP_printk("%s (%lu.%03lu us)",
193 __get_str(name),
194 __entry->wait_usec, __entry->wait_nsec_rem)
195#endif
196)
197
198#endif
199
200#endif /* #if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,35)) */
201
b283666f
PW
202#endif
203
3bc29f0a 204#endif /* LTTNG_TRACE_LOCK_H */
b283666f
PW
205
206/* This part must be outside protection */
207#include "../../../probes/define_trace.h"
This page took 0.035322 seconds and 4 git commands to generate.