Update kernel probes to more detailed match to kernel versions
[lttng-modules.git] / instrumentation / events / lttng-module / power.h
CommitLineData
b283666f
PW
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>
7c68b363 9#include <linux/version.h>
b283666f 10
7c68b363 11#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,38))
b283666f
PW
12DECLARE_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(
d3ac4d63
PW
24 tp_assign(state, state)
25 tp_assign(cpu_id, cpu_id)
b283666f
PW
26 ),
27
28 TP_printk("state=%lu cpu_id=%lu", (unsigned long)__entry->state,
29 (unsigned long)__entry->cpu_id)
30)
31
32DEFINE_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
46DEFINE_EVENT(cpu, cpu_frequency,
47
48 TP_PROTO(unsigned int frequency, unsigned int cpu_id),
49
50 TP_ARGS(frequency, cpu_id)
51)
52
53TRACE_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(
d3ac4d63 64 tp_assign(state, state)
b283666f
PW
65 ),
66
67 TP_printk("state=%lu", (unsigned long)__entry->state)
68)
7c68b363
AG
69#endif
70
71#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,5,0))
72DECLARE_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
92DEFINE_EVENT(wakeup_source, wakeup_source_activate,
93
94 TP_PROTO(const char *name, unsigned int state),
95
96 TP_ARGS(name, state)
97)
98
99DEFINE_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
b283666f 112
b283666f
PW
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 */
119DECLARE_EVENT_CLASS(power,
120
7c68b363 121#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,36))
b283666f
PW
122 TP_PROTO(unsigned int type, unsigned int state, unsigned int cpu_id),
123
124 TP_ARGS(type, state, cpu_id),
7c68b363
AG
125#else
126 TP_PROTO(unsigned int type, unsigned int state),
127
128 TP_ARGS(type, state),
129#endif
b283666f
PW
130
131 TP_STRUCT__entry(
132 __field( u64, type )
133 __field( u64, state )
7c68b363 134#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,36))
b283666f 135 __field( u64, cpu_id )
7c68b363 136#endif
b283666f
PW
137 ),
138
139 TP_fast_assign(
d3ac4d63
PW
140 tp_assign(type, type)
141 tp_assign(state, state)
7c68b363 142#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,36))
d3ac4d63 143 tp_assign(cpu_id, cpu_id)
7c68b363 144#endif
b283666f
PW
145 ),
146
7c68b363 147#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,36))
b283666f
PW
148 TP_printk("type=%lu state=%lu cpu_id=%lu", (unsigned long)__entry->type,
149 (unsigned long)__entry->state, (unsigned long)__entry->cpu_id)
7c68b363
AG
150#else
151 TP_printk("type=%lu state=%lu", (unsigned long)__entry->type,
152 (unsigned long)__entry->state)
153#endif
b283666f
PW
154)
155
156DEFINE_EVENT(power, power_start,
157
7c68b363 158#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,36))
b283666f
PW
159 TP_PROTO(unsigned int type, unsigned int state, unsigned int cpu_id),
160
161 TP_ARGS(type, state, cpu_id)
7c68b363
AG
162#else
163 TP_PROTO(unsigned int type, unsigned int state),
164
165 TP_ARGS(type, state)
166#endif
b283666f
PW
167)
168
169DEFINE_EVENT(power, power_frequency,
170
7c68b363 171#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,36))
b283666f
PW
172 TP_PROTO(unsigned int type, unsigned int state, unsigned int cpu_id),
173
174 TP_ARGS(type, state, cpu_id)
7c68b363
AG
175#else
176 TP_PROTO(unsigned int type, unsigned int state),
177
178 TP_ARGS(type, state)
179#endif
b283666f
PW
180)
181
182TRACE_EVENT(power_end,
183
7c68b363 184#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,36))
b283666f
PW
185 TP_PROTO(unsigned int cpu_id),
186
187 TP_ARGS(cpu_id),
7c68b363
AG
188#else
189 TP_PROTO(int dummy),
190
191 TP_ARGS(dummy),
192#endif
b283666f
PW
193
194 TP_STRUCT__entry(
7c68b363 195#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,36))
b283666f 196 __field( u64, cpu_id )
7c68b363
AG
197#else
198 __field( u64, dummy )
199#endif
b283666f
PW
200 ),
201
202 TP_fast_assign(
7c68b363 203#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,36))
d3ac4d63 204 tp_assign(cpu_id, cpu_id)
7c68b363
AG
205#else
206 tp_assign(dummy, 0xffff)
207#endif
b283666f
PW
208 ),
209
7c68b363 210#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,36))
b283666f 211 TP_printk("cpu_id=%lu", (unsigned long)__entry->cpu_id)
7c68b363
AG
212#else
213 TP_printk("dummy=%lu", (unsigned long)__entry->dummy)
214#endif
b283666f
PW
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
221enum {
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
232enum {
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 */
240static inline void trace_power_start(u64 type, u64 state, u64 cpuid) {};
241static inline void trace_power_end(u64 cpuid) {};
7c68b363
AG
242#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,4,0))
243static inline void trace_power_start_rcuidle(u64 type, u64 state, u64 cpuid) {};
244static inline void trace_power_end_rcuidle(u64 cpuid) {};
245#endif
b283666f
PW
246static 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
7c68b363 251#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,37))
b283666f
PW
252/*
253 * The clock events are used for clock enable/disable and for
254 * clock rate change
255 */
256DECLARE_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(
d3ac4d63
PW
269 tp_strcpy(name, name)
270 tp_assign(state, state)
271 tp_assign(cpu_id, cpu_id)
b283666f
PW
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
278DEFINE_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
285DEFINE_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
292DEFINE_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 */
302DECLARE_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(
d3ac4d63
PW
315 tp_strcpy(name, name)
316 tp_assign(state, state)
317 tp_assign(cpu_id, cpu_id)
b283666f
PW
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
324DEFINE_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)
7c68b363
AG
330#endif
331
b283666f
PW
332#endif /* _TRACE_POWER_H */
333
334/* This part must be outside protection */
335#include "../../../probes/define_trace.h"
This page took 0.035316 seconds and 4 git commands to generate.