| 1 | #undef TRACE_SYSTEM |
| 2 | #define TRACE_SYSTEM power |
| 3 | |
| 4 | #if !defined(LTTNG_TRACE_POWER_H) || defined(TRACE_HEADER_MULTI_READ) |
| 5 | #define LTTNG_TRACE_POWER_H |
| 6 | |
| 7 | #include <probes/lttng-tracepoint-event.h> |
| 8 | #include <linux/ktime.h> |
| 9 | #include <linux/version.h> |
| 10 | |
| 11 | #if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,38)) |
| 12 | LTTNG_TRACEPOINT_EVENT_CLASS(power_cpu, |
| 13 | |
| 14 | TP_PROTO(unsigned int state, unsigned int cpu_id), |
| 15 | |
| 16 | TP_ARGS(state, cpu_id), |
| 17 | |
| 18 | TP_FIELDS( |
| 19 | ctf_integer(u32, state, state) |
| 20 | ctf_integer(u32, cpu_id, cpu_id) |
| 21 | ) |
| 22 | ) |
| 23 | |
| 24 | LTTNG_TRACEPOINT_EVENT_INSTANCE_MAP(power_cpu, cpu_idle, |
| 25 | |
| 26 | power_cpu_idle, |
| 27 | |
| 28 | TP_PROTO(unsigned int state, unsigned int cpu_id), |
| 29 | |
| 30 | TP_ARGS(state, cpu_id) |
| 31 | ) |
| 32 | |
| 33 | /* This file can get included multiple times, TRACE_HEADER_MULTI_READ at top */ |
| 34 | #ifndef _PWR_EVENT_AVOID_DOUBLE_DEFINING |
| 35 | #define _PWR_EVENT_AVOID_DOUBLE_DEFINING |
| 36 | |
| 37 | #define PWR_EVENT_EXIT -1 |
| 38 | #endif |
| 39 | |
| 40 | LTTNG_TRACEPOINT_EVENT_INSTANCE_MAP(power_cpu, cpu_frequency, |
| 41 | |
| 42 | power_cpu_frequency, |
| 43 | |
| 44 | TP_PROTO(unsigned int frequency, unsigned int cpu_id), |
| 45 | |
| 46 | TP_ARGS(frequency, cpu_id) |
| 47 | ) |
| 48 | |
| 49 | LTTNG_TRACEPOINT_EVENT_MAP(machine_suspend, |
| 50 | |
| 51 | power_machine_suspend, |
| 52 | |
| 53 | TP_PROTO(unsigned int state), |
| 54 | |
| 55 | TP_ARGS(state), |
| 56 | |
| 57 | TP_FIELDS( |
| 58 | ctf_integer(u32, state, state) |
| 59 | ) |
| 60 | ) |
| 61 | #endif |
| 62 | |
| 63 | #if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,5,0)) |
| 64 | LTTNG_TRACEPOINT_EVENT_CLASS(power_wakeup_source, |
| 65 | |
| 66 | TP_PROTO(const char *name, unsigned int state), |
| 67 | |
| 68 | TP_ARGS(name, state), |
| 69 | |
| 70 | TP_FIELDS( |
| 71 | ctf_string(name, name) |
| 72 | ctf_integer(u64, state, state) |
| 73 | ) |
| 74 | ) |
| 75 | |
| 76 | LTTNG_TRACEPOINT_EVENT_INSTANCE_MAP(power_wakeup_source, wakeup_source_activate, |
| 77 | |
| 78 | power_wakeup_source_activate, |
| 79 | |
| 80 | TP_PROTO(const char *name, unsigned int state), |
| 81 | |
| 82 | TP_ARGS(name, state) |
| 83 | ) |
| 84 | |
| 85 | LTTNG_TRACEPOINT_EVENT_INSTANCE_MAP(power_wakeup_source, wakeup_source_deactivate, |
| 86 | |
| 87 | power_wakeup_source_deactivate, |
| 88 | |
| 89 | TP_PROTO(const char *name, unsigned int state), |
| 90 | |
| 91 | TP_ARGS(name, state) |
| 92 | ) |
| 93 | #endif |
| 94 | |
| 95 | #if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,38)) |
| 96 | #undef CONFIG_EVENT_POWER_TRACING_DEPRECATED |
| 97 | #define CONFIG_EVENT_POWER_TRACING_DEPRECATED |
| 98 | #define _PWR_EVENT_AVOID_DOUBLE_DEFINING_DEPRECATED |
| 99 | #endif |
| 100 | |
| 101 | #ifdef CONFIG_EVENT_POWER_TRACING_DEPRECATED |
| 102 | |
| 103 | /* |
| 104 | * The power events are used for cpuidle & suspend (power_start, power_end) |
| 105 | * and for cpufreq (power_frequency) |
| 106 | */ |
| 107 | LTTNG_TRACEPOINT_EVENT_CLASS(power, |
| 108 | |
| 109 | #if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,36)) |
| 110 | TP_PROTO(unsigned int type, unsigned int state, unsigned int cpu_id), |
| 111 | |
| 112 | TP_ARGS(type, state, cpu_id), |
| 113 | #else |
| 114 | TP_PROTO(unsigned int type, unsigned int state), |
| 115 | |
| 116 | TP_ARGS(type, state), |
| 117 | #endif |
| 118 | |
| 119 | TP_FIELDS( |
| 120 | ctf_integer(u64, type, type) |
| 121 | ctf_integer(u64, state, state) |
| 122 | #if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,36)) |
| 123 | ctf_integer(u64, cpu_id, cpu_id) |
| 124 | #endif |
| 125 | ) |
| 126 | ) |
| 127 | |
| 128 | LTTNG_TRACEPOINT_EVENT_INSTANCE(power, power_start, |
| 129 | |
| 130 | #if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,36)) |
| 131 | TP_PROTO(unsigned int type, unsigned int state, unsigned int cpu_id), |
| 132 | |
| 133 | TP_ARGS(type, state, cpu_id) |
| 134 | #else |
| 135 | TP_PROTO(unsigned int type, unsigned int state), |
| 136 | |
| 137 | TP_ARGS(type, state) |
| 138 | #endif |
| 139 | ) |
| 140 | |
| 141 | LTTNG_TRACEPOINT_EVENT_INSTANCE(power, power_frequency, |
| 142 | |
| 143 | #if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,36)) |
| 144 | TP_PROTO(unsigned int type, unsigned int state, unsigned int cpu_id), |
| 145 | |
| 146 | TP_ARGS(type, state, cpu_id) |
| 147 | #else |
| 148 | TP_PROTO(unsigned int type, unsigned int state), |
| 149 | |
| 150 | TP_ARGS(type, state) |
| 151 | #endif |
| 152 | ) |
| 153 | |
| 154 | LTTNG_TRACEPOINT_EVENT(power_end, |
| 155 | |
| 156 | #if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,36)) |
| 157 | TP_PROTO(unsigned int cpu_id), |
| 158 | |
| 159 | TP_ARGS(cpu_id), |
| 160 | #else |
| 161 | TP_PROTO(int dummy), |
| 162 | |
| 163 | TP_ARGS(dummy), |
| 164 | #endif |
| 165 | |
| 166 | TP_FIELDS( |
| 167 | #if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,36)) |
| 168 | ctf_integer(u64, cpu_id, cpu_id) |
| 169 | #else |
| 170 | ctf_integer(u64, dummy, 0xffff) |
| 171 | #endif |
| 172 | ) |
| 173 | ) |
| 174 | |
| 175 | /* Deprecated dummy functions must be protected against multi-declartion */ |
| 176 | #ifndef _PWR_EVENT_AVOID_DOUBLE_DEFINING_DEPRECATED |
| 177 | #define _PWR_EVENT_AVOID_DOUBLE_DEFINING_DEPRECATED |
| 178 | |
| 179 | enum { |
| 180 | POWER_NONE = 0, |
| 181 | POWER_CSTATE = 1, |
| 182 | POWER_PSTATE = 2, |
| 183 | }; |
| 184 | #endif /* _PWR_EVENT_AVOID_DOUBLE_DEFINING_DEPRECATED */ |
| 185 | |
| 186 | #else /* CONFIG_EVENT_POWER_TRACING_DEPRECATED */ |
| 187 | |
| 188 | #ifndef _PWR_EVENT_AVOID_DOUBLE_DEFINING_DEPRECATED |
| 189 | #define _PWR_EVENT_AVOID_DOUBLE_DEFINING_DEPRECATED |
| 190 | enum { |
| 191 | POWER_NONE = 0, |
| 192 | POWER_CSTATE = 1, |
| 193 | POWER_PSTATE = 2, |
| 194 | }; |
| 195 | |
| 196 | /* These dummy declaration have to be ripped out when the deprecated |
| 197 | events get removed */ |
| 198 | static inline void trace_power_start(u64 type, u64 state, u64 cpuid) {}; |
| 199 | static inline void trace_power_end(u64 cpuid) {}; |
| 200 | #if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,4,0)) |
| 201 | static inline void trace_power_start_rcuidle(u64 type, u64 state, u64 cpuid) {}; |
| 202 | static inline void trace_power_end_rcuidle(u64 cpuid) {}; |
| 203 | #endif |
| 204 | static inline void trace_power_frequency(u64 type, u64 state, u64 cpuid) {}; |
| 205 | #endif /* _PWR_EVENT_AVOID_DOUBLE_DEFINING_DEPRECATED */ |
| 206 | |
| 207 | #endif /* CONFIG_EVENT_POWER_TRACING_DEPRECATED */ |
| 208 | |
| 209 | #if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,37)) |
| 210 | /* |
| 211 | * The clock events are used for clock enable/disable and for |
| 212 | * clock rate change |
| 213 | */ |
| 214 | LTTNG_TRACEPOINT_EVENT_CLASS(power_clock, |
| 215 | |
| 216 | TP_PROTO(const char *name, unsigned int state, unsigned int cpu_id), |
| 217 | |
| 218 | TP_ARGS(name, state, cpu_id), |
| 219 | |
| 220 | TP_FIELDS( |
| 221 | ctf_string(name, name) |
| 222 | ctf_integer(u64, state, state) |
| 223 | ctf_integer(u64, cpu_id, cpu_id) |
| 224 | ) |
| 225 | ) |
| 226 | |
| 227 | LTTNG_TRACEPOINT_EVENT_INSTANCE_MAP(power_clock, clock_enable, |
| 228 | |
| 229 | power_clock_enable, |
| 230 | |
| 231 | TP_PROTO(const char *name, unsigned int state, unsigned int cpu_id), |
| 232 | |
| 233 | TP_ARGS(name, state, cpu_id) |
| 234 | ) |
| 235 | |
| 236 | LTTNG_TRACEPOINT_EVENT_INSTANCE_MAP(power_clock, clock_disable, |
| 237 | |
| 238 | power_clock_disable, |
| 239 | |
| 240 | TP_PROTO(const char *name, unsigned int state, unsigned int cpu_id), |
| 241 | |
| 242 | TP_ARGS(name, state, cpu_id) |
| 243 | ) |
| 244 | |
| 245 | LTTNG_TRACEPOINT_EVENT_INSTANCE_MAP(power_clock, clock_set_rate, |
| 246 | |
| 247 | power_clock_set_rate, |
| 248 | |
| 249 | TP_PROTO(const char *name, unsigned int state, unsigned int cpu_id), |
| 250 | |
| 251 | TP_ARGS(name, state, cpu_id) |
| 252 | ) |
| 253 | |
| 254 | /* |
| 255 | * The power domain events are used for power domains transitions |
| 256 | */ |
| 257 | LTTNG_TRACEPOINT_EVENT_CLASS(power_domain, |
| 258 | |
| 259 | TP_PROTO(const char *name, unsigned int state, unsigned int cpu_id), |
| 260 | |
| 261 | TP_ARGS(name, state, cpu_id), |
| 262 | |
| 263 | TP_FIELDS( |
| 264 | ctf_string(name, name) |
| 265 | ctf_integer(u64, state, state) |
| 266 | ctf_integer(u64, cpu_id, cpu_id) |
| 267 | ) |
| 268 | ) |
| 269 | |
| 270 | LTTNG_TRACEPOINT_EVENT_INSTANCE(power_domain, power_domain_target, |
| 271 | |
| 272 | TP_PROTO(const char *name, unsigned int state, unsigned int cpu_id), |
| 273 | |
| 274 | TP_ARGS(name, state, cpu_id) |
| 275 | ) |
| 276 | #endif |
| 277 | |
| 278 | #endif /* LTTNG_TRACE_POWER_H */ |
| 279 | |
| 280 | /* This part must be outside protection */ |
| 281 | #include <probes/define_trace.h> |