Update kernel probes to more detailed match to kernel versions
[lttng-modules.git] / instrumentation / events / lttng-module / power.h
1 #undef TRACE_SYSTEM
2 #define TRACE_SYSTEM power
3
4 #if !defined(_TRACE_POWER_H) || defined(TRACE_HEADER_MULTI_READ)
5 #define _TRACE_POWER_H
6
7 #include <linux/ktime.h>
8 #include <linux/tracepoint.h>
9 #include <linux/version.h>
10
11 #if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,38))
12 DECLARE_EVENT_CLASS(cpu,
13
14 TP_PROTO(unsigned int state, unsigned int cpu_id),
15
16 TP_ARGS(state, cpu_id),
17
18 TP_STRUCT__entry(
19 __field( u32, state )
20 __field( u32, cpu_id )
21 ),
22
23 TP_fast_assign(
24 tp_assign(state, state)
25 tp_assign(cpu_id, cpu_id)
26 ),
27
28 TP_printk("state=%lu cpu_id=%lu", (unsigned long)__entry->state,
29 (unsigned long)__entry->cpu_id)
30 )
31
32 DEFINE_EVENT(cpu, cpu_idle,
33
34 TP_PROTO(unsigned int state, unsigned int cpu_id),
35
36 TP_ARGS(state, cpu_id)
37 )
38
39 /* This file can get included multiple times, TRACE_HEADER_MULTI_READ at top */
40 #ifndef _PWR_EVENT_AVOID_DOUBLE_DEFINING
41 #define _PWR_EVENT_AVOID_DOUBLE_DEFINING
42
43 #define PWR_EVENT_EXIT -1
44 #endif
45
46 DEFINE_EVENT(cpu, cpu_frequency,
47
48 TP_PROTO(unsigned int frequency, unsigned int cpu_id),
49
50 TP_ARGS(frequency, cpu_id)
51 )
52
53 TRACE_EVENT(machine_suspend,
54
55 TP_PROTO(unsigned int state),
56
57 TP_ARGS(state),
58
59 TP_STRUCT__entry(
60 __field( u32, state )
61 ),
62
63 TP_fast_assign(
64 tp_assign(state, state)
65 ),
66
67 TP_printk("state=%lu", (unsigned long)__entry->state)
68 )
69 #endif
70
71 #if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,5,0))
72 DECLARE_EVENT_CLASS(wakeup_source,
73
74 TP_PROTO(const char *name, unsigned int state),
75
76 TP_ARGS(name, state),
77
78 TP_STRUCT__entry(
79 __string( name, name )
80 __field( u64, state )
81 ),
82
83 TP_fast_assign(
84 tp_strcpy(name, name)
85 tp_assign(state, state)
86 ),
87
88 TP_printk("%s state=0x%lx", __get_str(name),
89 (unsigned long)__entry->state)
90 )
91
92 DEFINE_EVENT(wakeup_source, wakeup_source_activate,
93
94 TP_PROTO(const char *name, unsigned int state),
95
96 TP_ARGS(name, state)
97 )
98
99 DEFINE_EVENT(wakeup_source, wakeup_source_deactivate,
100
101 TP_PROTO(const char *name, unsigned int state),
102
103 TP_ARGS(name, state)
104 )
105 #endif
106
107 #if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,38))
108 #undef CONFIG_EVENT_POWER_TRACING_DEPRECATED
109 #define CONFIG_EVENT_POWER_TRACING_DEPRECATED
110 #define _PWR_EVENT_AVOID_DOUBLE_DEFINING_DEPRECATED
111 #endif
112
113 #ifdef CONFIG_EVENT_POWER_TRACING_DEPRECATED
114
115 /*
116 * The power events are used for cpuidle & suspend (power_start, power_end)
117 * and for cpufreq (power_frequency)
118 */
119 DECLARE_EVENT_CLASS(power,
120
121 #if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,36))
122 TP_PROTO(unsigned int type, unsigned int state, unsigned int cpu_id),
123
124 TP_ARGS(type, state, cpu_id),
125 #else
126 TP_PROTO(unsigned int type, unsigned int state),
127
128 TP_ARGS(type, state),
129 #endif
130
131 TP_STRUCT__entry(
132 __field( u64, type )
133 __field( u64, state )
134 #if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,36))
135 __field( u64, cpu_id )
136 #endif
137 ),
138
139 TP_fast_assign(
140 tp_assign(type, type)
141 tp_assign(state, state)
142 #if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,36))
143 tp_assign(cpu_id, cpu_id)
144 #endif
145 ),
146
147 #if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,36))
148 TP_printk("type=%lu state=%lu cpu_id=%lu", (unsigned long)__entry->type,
149 (unsigned long)__entry->state, (unsigned long)__entry->cpu_id)
150 #else
151 TP_printk("type=%lu state=%lu", (unsigned long)__entry->type,
152 (unsigned long)__entry->state)
153 #endif
154 )
155
156 DEFINE_EVENT(power, power_start,
157
158 #if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,36))
159 TP_PROTO(unsigned int type, unsigned int state, unsigned int cpu_id),
160
161 TP_ARGS(type, state, cpu_id)
162 #else
163 TP_PROTO(unsigned int type, unsigned int state),
164
165 TP_ARGS(type, state)
166 #endif
167 )
168
169 DEFINE_EVENT(power, power_frequency,
170
171 #if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,36))
172 TP_PROTO(unsigned int type, unsigned int state, unsigned int cpu_id),
173
174 TP_ARGS(type, state, cpu_id)
175 #else
176 TP_PROTO(unsigned int type, unsigned int state),
177
178 TP_ARGS(type, state)
179 #endif
180 )
181
182 TRACE_EVENT(power_end,
183
184 #if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,36))
185 TP_PROTO(unsigned int cpu_id),
186
187 TP_ARGS(cpu_id),
188 #else
189 TP_PROTO(int dummy),
190
191 TP_ARGS(dummy),
192 #endif
193
194 TP_STRUCT__entry(
195 #if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,36))
196 __field( u64, cpu_id )
197 #else
198 __field( u64, dummy )
199 #endif
200 ),
201
202 TP_fast_assign(
203 #if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,36))
204 tp_assign(cpu_id, cpu_id)
205 #else
206 tp_assign(dummy, 0xffff)
207 #endif
208 ),
209
210 #if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,36))
211 TP_printk("cpu_id=%lu", (unsigned long)__entry->cpu_id)
212 #else
213 TP_printk("dummy=%lu", (unsigned long)__entry->dummy)
214 #endif
215 )
216
217 /* Deprecated dummy functions must be protected against multi-declartion */
218 #ifndef _PWR_EVENT_AVOID_DOUBLE_DEFINING_DEPRECATED
219 #define _PWR_EVENT_AVOID_DOUBLE_DEFINING_DEPRECATED
220
221 enum {
222 POWER_NONE = 0,
223 POWER_CSTATE = 1,
224 POWER_PSTATE = 2,
225 };
226 #endif /* _PWR_EVENT_AVOID_DOUBLE_DEFINING_DEPRECATED */
227
228 #else /* CONFIG_EVENT_POWER_TRACING_DEPRECATED */
229
230 #ifndef _PWR_EVENT_AVOID_DOUBLE_DEFINING_DEPRECATED
231 #define _PWR_EVENT_AVOID_DOUBLE_DEFINING_DEPRECATED
232 enum {
233 POWER_NONE = 0,
234 POWER_CSTATE = 1,
235 POWER_PSTATE = 2,
236 };
237
238 /* These dummy declaration have to be ripped out when the deprecated
239 events get removed */
240 static inline void trace_power_start(u64 type, u64 state, u64 cpuid) {};
241 static inline void trace_power_end(u64 cpuid) {};
242 #if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,4,0))
243 static inline void trace_power_start_rcuidle(u64 type, u64 state, u64 cpuid) {};
244 static inline void trace_power_end_rcuidle(u64 cpuid) {};
245 #endif
246 static inline void trace_power_frequency(u64 type, u64 state, u64 cpuid) {};
247 #endif /* _PWR_EVENT_AVOID_DOUBLE_DEFINING_DEPRECATED */
248
249 #endif /* CONFIG_EVENT_POWER_TRACING_DEPRECATED */
250
251 #if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,37))
252 /*
253 * The clock events are used for clock enable/disable and for
254 * clock rate change
255 */
256 DECLARE_EVENT_CLASS(clock,
257
258 TP_PROTO(const char *name, unsigned int state, unsigned int cpu_id),
259
260 TP_ARGS(name, state, cpu_id),
261
262 TP_STRUCT__entry(
263 __string( name, name )
264 __field( u64, state )
265 __field( u64, cpu_id )
266 ),
267
268 TP_fast_assign(
269 tp_strcpy(name, name)
270 tp_assign(state, state)
271 tp_assign(cpu_id, cpu_id)
272 ),
273
274 TP_printk("%s state=%lu cpu_id=%lu", __get_str(name),
275 (unsigned long)__entry->state, (unsigned long)__entry->cpu_id)
276 )
277
278 DEFINE_EVENT(clock, clock_enable,
279
280 TP_PROTO(const char *name, unsigned int state, unsigned int cpu_id),
281
282 TP_ARGS(name, state, cpu_id)
283 )
284
285 DEFINE_EVENT(clock, clock_disable,
286
287 TP_PROTO(const char *name, unsigned int state, unsigned int cpu_id),
288
289 TP_ARGS(name, state, cpu_id)
290 )
291
292 DEFINE_EVENT(clock, clock_set_rate,
293
294 TP_PROTO(const char *name, unsigned int state, unsigned int cpu_id),
295
296 TP_ARGS(name, state, cpu_id)
297 )
298
299 /*
300 * The power domain events are used for power domains transitions
301 */
302 DECLARE_EVENT_CLASS(power_domain,
303
304 TP_PROTO(const char *name, unsigned int state, unsigned int cpu_id),
305
306 TP_ARGS(name, state, cpu_id),
307
308 TP_STRUCT__entry(
309 __string( name, name )
310 __field( u64, state )
311 __field( u64, cpu_id )
312 ),
313
314 TP_fast_assign(
315 tp_strcpy(name, name)
316 tp_assign(state, state)
317 tp_assign(cpu_id, cpu_id)
318 ),
319
320 TP_printk("%s state=%lu cpu_id=%lu", __get_str(name),
321 (unsigned long)__entry->state, (unsigned long)__entry->cpu_id)
322 )
323
324 DEFINE_EVENT(power_domain, power_domain_target,
325
326 TP_PROTO(const char *name, unsigned int state, unsigned int cpu_id),
327
328 TP_ARGS(name, state, cpu_id)
329 )
330 #endif
331
332 #endif /* _TRACE_POWER_H */
333
334 /* This part must be outside protection */
335 #include "../../../probes/define_trace.h"
This page took 0.036392 seconds and 4 git commands to generate.