Commit | Line | Data |
---|---|---|
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) | |
10 | #define _TRACE_LOCK_H | |
11 | #endif | |
12 | #endif | |
b283666f PW |
13 | |
14 | #if !defined(_TRACE_LOCK_H) || defined(TRACE_HEADER_MULTI_READ) | |
15 | #define _TRACE_LOCK_H | |
16 | ||
17 | #include <linux/lockdep.h> | |
18 | #include <linux/tracepoint.h> | |
19 | ||
20 | #ifdef CONFIG_LOCKDEP | |
21 | ||
22 | TRACE_EVENT(lock_acquire, | |
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 | ||
b283666f PW |
58 | DECLARE_EVENT_CLASS(lock, |
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 | ||
77 | DEFINE_EVENT(lock, lock_release, | |
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 | ||
86 | DEFINE_EVENT(lock, lock_contended, | |
87 | ||
88 | TP_PROTO(struct lockdep_map *lock, unsigned long ip), | |
89 | ||
90 | TP_ARGS(lock, ip) | |
91 | ) | |
92 | ||
93 | DEFINE_EVENT(lock, lock_acquired, | |
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 | ||
104 | TRACE_EVENT(lock_release, | |
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 | ||
133 | TRACE_EVENT(lock_contended, | |
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 | ||
160 | TRACE_EVENT(lock_acquired, | |
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 | ||
204 | #endif /* _TRACE_LOCK_H */ | |
205 | ||
206 | /* This part must be outside protection */ | |
207 | #include "../../../probes/define_trace.h" |