0001
0002 #undef TRACE_SYSTEM
0003 #define TRACE_SYSTEM power
0004
0005 #if !defined(_TRACE_POWER_H) || defined(TRACE_HEADER_MULTI_READ)
0006 #define _TRACE_POWER_H
0007
0008 #include <linux/cpufreq.h>
0009 #include <linux/ktime.h>
0010 #include <linux/pm_qos.h>
0011 #include <linux/tracepoint.h>
0012 #include <linux/trace_events.h>
0013
0014 #define TPS(x) tracepoint_string(x)
0015
0016 DECLARE_EVENT_CLASS(cpu,
0017
0018 TP_PROTO(unsigned int state, unsigned int cpu_id),
0019
0020 TP_ARGS(state, cpu_id),
0021
0022 TP_STRUCT__entry(
0023 __field( u32, state )
0024 __field( u32, cpu_id )
0025 ),
0026
0027 TP_fast_assign(
0028 __entry->state = state;
0029 __entry->cpu_id = cpu_id;
0030 ),
0031
0032 TP_printk("state=%lu cpu_id=%lu", (unsigned long)__entry->state,
0033 (unsigned long)__entry->cpu_id)
0034 );
0035
0036 DEFINE_EVENT(cpu, cpu_idle,
0037
0038 TP_PROTO(unsigned int state, unsigned int cpu_id),
0039
0040 TP_ARGS(state, cpu_id)
0041 );
0042
0043 TRACE_EVENT(cpu_idle_miss,
0044
0045 TP_PROTO(unsigned int cpu_id, unsigned int state, bool below),
0046
0047 TP_ARGS(cpu_id, state, below),
0048
0049 TP_STRUCT__entry(
0050 __field(u32, cpu_id)
0051 __field(u32, state)
0052 __field(bool, below)
0053 ),
0054
0055 TP_fast_assign(
0056 __entry->cpu_id = cpu_id;
0057 __entry->state = state;
0058 __entry->below = below;
0059 ),
0060
0061 TP_printk("cpu_id=%lu state=%lu type=%s", (unsigned long)__entry->cpu_id,
0062 (unsigned long)__entry->state, (__entry->below)?"below":"above")
0063 );
0064
0065 TRACE_EVENT(powernv_throttle,
0066
0067 TP_PROTO(int chip_id, const char *reason, int pmax),
0068
0069 TP_ARGS(chip_id, reason, pmax),
0070
0071 TP_STRUCT__entry(
0072 __field(int, chip_id)
0073 __string(reason, reason)
0074 __field(int, pmax)
0075 ),
0076
0077 TP_fast_assign(
0078 __entry->chip_id = chip_id;
0079 __assign_str(reason, reason);
0080 __entry->pmax = pmax;
0081 ),
0082
0083 TP_printk("Chip %d Pmax %d %s", __entry->chip_id,
0084 __entry->pmax, __get_str(reason))
0085 );
0086
0087 TRACE_EVENT(pstate_sample,
0088
0089 TP_PROTO(u32 core_busy,
0090 u32 scaled_busy,
0091 u32 from,
0092 u32 to,
0093 u64 mperf,
0094 u64 aperf,
0095 u64 tsc,
0096 u32 freq,
0097 u32 io_boost
0098 ),
0099
0100 TP_ARGS(core_busy,
0101 scaled_busy,
0102 from,
0103 to,
0104 mperf,
0105 aperf,
0106 tsc,
0107 freq,
0108 io_boost
0109 ),
0110
0111 TP_STRUCT__entry(
0112 __field(u32, core_busy)
0113 __field(u32, scaled_busy)
0114 __field(u32, from)
0115 __field(u32, to)
0116 __field(u64, mperf)
0117 __field(u64, aperf)
0118 __field(u64, tsc)
0119 __field(u32, freq)
0120 __field(u32, io_boost)
0121 ),
0122
0123 TP_fast_assign(
0124 __entry->core_busy = core_busy;
0125 __entry->scaled_busy = scaled_busy;
0126 __entry->from = from;
0127 __entry->to = to;
0128 __entry->mperf = mperf;
0129 __entry->aperf = aperf;
0130 __entry->tsc = tsc;
0131 __entry->freq = freq;
0132 __entry->io_boost = io_boost;
0133 ),
0134
0135 TP_printk("core_busy=%lu scaled=%lu from=%lu to=%lu mperf=%llu aperf=%llu tsc=%llu freq=%lu io_boost=%lu",
0136 (unsigned long)__entry->core_busy,
0137 (unsigned long)__entry->scaled_busy,
0138 (unsigned long)__entry->from,
0139 (unsigned long)__entry->to,
0140 (unsigned long long)__entry->mperf,
0141 (unsigned long long)__entry->aperf,
0142 (unsigned long long)__entry->tsc,
0143 (unsigned long)__entry->freq,
0144 (unsigned long)__entry->io_boost
0145 )
0146
0147 );
0148
0149
0150 #ifndef _PWR_EVENT_AVOID_DOUBLE_DEFINING
0151 #define _PWR_EVENT_AVOID_DOUBLE_DEFINING
0152
0153 #define PWR_EVENT_EXIT -1
0154 #endif
0155
0156 #define pm_verb_symbolic(event) \
0157 __print_symbolic(event, \
0158 { PM_EVENT_SUSPEND, "suspend" }, \
0159 { PM_EVENT_RESUME, "resume" }, \
0160 { PM_EVENT_FREEZE, "freeze" }, \
0161 { PM_EVENT_QUIESCE, "quiesce" }, \
0162 { PM_EVENT_HIBERNATE, "hibernate" }, \
0163 { PM_EVENT_THAW, "thaw" }, \
0164 { PM_EVENT_RESTORE, "restore" }, \
0165 { PM_EVENT_RECOVER, "recover" })
0166
0167 DEFINE_EVENT(cpu, cpu_frequency,
0168
0169 TP_PROTO(unsigned int frequency, unsigned int cpu_id),
0170
0171 TP_ARGS(frequency, cpu_id)
0172 );
0173
0174 TRACE_EVENT(cpu_frequency_limits,
0175
0176 TP_PROTO(struct cpufreq_policy *policy),
0177
0178 TP_ARGS(policy),
0179
0180 TP_STRUCT__entry(
0181 __field(u32, min_freq)
0182 __field(u32, max_freq)
0183 __field(u32, cpu_id)
0184 ),
0185
0186 TP_fast_assign(
0187 __entry->min_freq = policy->min;
0188 __entry->max_freq = policy->max;
0189 __entry->cpu_id = policy->cpu;
0190 ),
0191
0192 TP_printk("min=%lu max=%lu cpu_id=%lu",
0193 (unsigned long)__entry->min_freq,
0194 (unsigned long)__entry->max_freq,
0195 (unsigned long)__entry->cpu_id)
0196 );
0197
0198 TRACE_EVENT(device_pm_callback_start,
0199
0200 TP_PROTO(struct device *dev, const char *pm_ops, int event),
0201
0202 TP_ARGS(dev, pm_ops, event),
0203
0204 TP_STRUCT__entry(
0205 __string(device, dev_name(dev))
0206 __string(driver, dev_driver_string(dev))
0207 __string(parent, dev->parent ? dev_name(dev->parent) : "none")
0208 __string(pm_ops, pm_ops ? pm_ops : "none ")
0209 __field(int, event)
0210 ),
0211
0212 TP_fast_assign(
0213 __assign_str(device, dev_name(dev));
0214 __assign_str(driver, dev_driver_string(dev));
0215 __assign_str(parent,
0216 dev->parent ? dev_name(dev->parent) : "none");
0217 __assign_str(pm_ops, pm_ops ? pm_ops : "none ");
0218 __entry->event = event;
0219 ),
0220
0221 TP_printk("%s %s, parent: %s, %s[%s]", __get_str(driver),
0222 __get_str(device), __get_str(parent), __get_str(pm_ops),
0223 pm_verb_symbolic(__entry->event))
0224 );
0225
0226 TRACE_EVENT(device_pm_callback_end,
0227
0228 TP_PROTO(struct device *dev, int error),
0229
0230 TP_ARGS(dev, error),
0231
0232 TP_STRUCT__entry(
0233 __string(device, dev_name(dev))
0234 __string(driver, dev_driver_string(dev))
0235 __field(int, error)
0236 ),
0237
0238 TP_fast_assign(
0239 __assign_str(device, dev_name(dev));
0240 __assign_str(driver, dev_driver_string(dev));
0241 __entry->error = error;
0242 ),
0243
0244 TP_printk("%s %s, err=%d",
0245 __get_str(driver), __get_str(device), __entry->error)
0246 );
0247
0248 TRACE_EVENT(suspend_resume,
0249
0250 TP_PROTO(const char *action, int val, bool start),
0251
0252 TP_ARGS(action, val, start),
0253
0254 TP_STRUCT__entry(
0255 __field(const char *, action)
0256 __field(int, val)
0257 __field(bool, start)
0258 ),
0259
0260 TP_fast_assign(
0261 __entry->action = action;
0262 __entry->val = val;
0263 __entry->start = start;
0264 ),
0265
0266 TP_printk("%s[%u] %s", __entry->action, (unsigned int)__entry->val,
0267 (__entry->start)?"begin":"end")
0268 );
0269
0270 DECLARE_EVENT_CLASS(wakeup_source,
0271
0272 TP_PROTO(const char *name, unsigned int state),
0273
0274 TP_ARGS(name, state),
0275
0276 TP_STRUCT__entry(
0277 __string( name, name )
0278 __field( u64, state )
0279 ),
0280
0281 TP_fast_assign(
0282 __assign_str(name, name);
0283 __entry->state = state;
0284 ),
0285
0286 TP_printk("%s state=0x%lx", __get_str(name),
0287 (unsigned long)__entry->state)
0288 );
0289
0290 DEFINE_EVENT(wakeup_source, wakeup_source_activate,
0291
0292 TP_PROTO(const char *name, unsigned int state),
0293
0294 TP_ARGS(name, state)
0295 );
0296
0297 DEFINE_EVENT(wakeup_source, wakeup_source_deactivate,
0298
0299 TP_PROTO(const char *name, unsigned int state),
0300
0301 TP_ARGS(name, state)
0302 );
0303
0304
0305
0306
0307
0308 DECLARE_EVENT_CLASS(clock,
0309
0310 TP_PROTO(const char *name, unsigned int state, unsigned int cpu_id),
0311
0312 TP_ARGS(name, state, cpu_id),
0313
0314 TP_STRUCT__entry(
0315 __string( name, name )
0316 __field( u64, state )
0317 __field( u64, cpu_id )
0318 ),
0319
0320 TP_fast_assign(
0321 __assign_str(name, name);
0322 __entry->state = state;
0323 __entry->cpu_id = cpu_id;
0324 ),
0325
0326 TP_printk("%s state=%lu cpu_id=%lu", __get_str(name),
0327 (unsigned long)__entry->state, (unsigned long)__entry->cpu_id)
0328 );
0329
0330 DEFINE_EVENT(clock, clock_enable,
0331
0332 TP_PROTO(const char *name, unsigned int state, unsigned int cpu_id),
0333
0334 TP_ARGS(name, state, cpu_id)
0335 );
0336
0337 DEFINE_EVENT(clock, clock_disable,
0338
0339 TP_PROTO(const char *name, unsigned int state, unsigned int cpu_id),
0340
0341 TP_ARGS(name, state, cpu_id)
0342 );
0343
0344 DEFINE_EVENT(clock, clock_set_rate,
0345
0346 TP_PROTO(const char *name, unsigned int state, unsigned int cpu_id),
0347
0348 TP_ARGS(name, state, cpu_id)
0349 );
0350
0351
0352
0353
0354 DECLARE_EVENT_CLASS(power_domain,
0355
0356 TP_PROTO(const char *name, unsigned int state, unsigned int cpu_id),
0357
0358 TP_ARGS(name, state, cpu_id),
0359
0360 TP_STRUCT__entry(
0361 __string( name, name )
0362 __field( u64, state )
0363 __field( u64, cpu_id )
0364 ),
0365
0366 TP_fast_assign(
0367 __assign_str(name, name);
0368 __entry->state = state;
0369 __entry->cpu_id = cpu_id;
0370 ),
0371
0372 TP_printk("%s state=%lu cpu_id=%lu", __get_str(name),
0373 (unsigned long)__entry->state, (unsigned long)__entry->cpu_id)
0374 );
0375
0376 DEFINE_EVENT(power_domain, power_domain_target,
0377
0378 TP_PROTO(const char *name, unsigned int state, unsigned int cpu_id),
0379
0380 TP_ARGS(name, state, cpu_id)
0381 );
0382
0383
0384
0385
0386 DECLARE_EVENT_CLASS(cpu_latency_qos_request,
0387
0388 TP_PROTO(s32 value),
0389
0390 TP_ARGS(value),
0391
0392 TP_STRUCT__entry(
0393 __field( s32, value )
0394 ),
0395
0396 TP_fast_assign(
0397 __entry->value = value;
0398 ),
0399
0400 TP_printk("CPU_DMA_LATENCY value=%d",
0401 __entry->value)
0402 );
0403
0404 DEFINE_EVENT(cpu_latency_qos_request, pm_qos_add_request,
0405
0406 TP_PROTO(s32 value),
0407
0408 TP_ARGS(value)
0409 );
0410
0411 DEFINE_EVENT(cpu_latency_qos_request, pm_qos_update_request,
0412
0413 TP_PROTO(s32 value),
0414
0415 TP_ARGS(value)
0416 );
0417
0418 DEFINE_EVENT(cpu_latency_qos_request, pm_qos_remove_request,
0419
0420 TP_PROTO(s32 value),
0421
0422 TP_ARGS(value)
0423 );
0424
0425
0426
0427
0428 DECLARE_EVENT_CLASS(pm_qos_update,
0429
0430 TP_PROTO(enum pm_qos_req_action action, int prev_value, int curr_value),
0431
0432 TP_ARGS(action, prev_value, curr_value),
0433
0434 TP_STRUCT__entry(
0435 __field( enum pm_qos_req_action, action )
0436 __field( int, prev_value )
0437 __field( int, curr_value )
0438 ),
0439
0440 TP_fast_assign(
0441 __entry->action = action;
0442 __entry->prev_value = prev_value;
0443 __entry->curr_value = curr_value;
0444 ),
0445
0446 TP_printk("action=%s prev_value=%d curr_value=%d",
0447 __print_symbolic(__entry->action,
0448 { PM_QOS_ADD_REQ, "ADD_REQ" },
0449 { PM_QOS_UPDATE_REQ, "UPDATE_REQ" },
0450 { PM_QOS_REMOVE_REQ, "REMOVE_REQ" }),
0451 __entry->prev_value, __entry->curr_value)
0452 );
0453
0454 DEFINE_EVENT(pm_qos_update, pm_qos_update_target,
0455
0456 TP_PROTO(enum pm_qos_req_action action, int prev_value, int curr_value),
0457
0458 TP_ARGS(action, prev_value, curr_value)
0459 );
0460
0461 DEFINE_EVENT_PRINT(pm_qos_update, pm_qos_update_flags,
0462
0463 TP_PROTO(enum pm_qos_req_action action, int prev_value, int curr_value),
0464
0465 TP_ARGS(action, prev_value, curr_value),
0466
0467 TP_printk("action=%s prev_value=0x%x curr_value=0x%x",
0468 __print_symbolic(__entry->action,
0469 { PM_QOS_ADD_REQ, "ADD_REQ" },
0470 { PM_QOS_UPDATE_REQ, "UPDATE_REQ" },
0471 { PM_QOS_REMOVE_REQ, "REMOVE_REQ" }),
0472 __entry->prev_value, __entry->curr_value)
0473 );
0474
0475 DECLARE_EVENT_CLASS(dev_pm_qos_request,
0476
0477 TP_PROTO(const char *name, enum dev_pm_qos_req_type type,
0478 s32 new_value),
0479
0480 TP_ARGS(name, type, new_value),
0481
0482 TP_STRUCT__entry(
0483 __string( name, name )
0484 __field( enum dev_pm_qos_req_type, type )
0485 __field( s32, new_value )
0486 ),
0487
0488 TP_fast_assign(
0489 __assign_str(name, name);
0490 __entry->type = type;
0491 __entry->new_value = new_value;
0492 ),
0493
0494 TP_printk("device=%s type=%s new_value=%d",
0495 __get_str(name),
0496 __print_symbolic(__entry->type,
0497 { DEV_PM_QOS_RESUME_LATENCY, "DEV_PM_QOS_RESUME_LATENCY" },
0498 { DEV_PM_QOS_FLAGS, "DEV_PM_QOS_FLAGS" }),
0499 __entry->new_value)
0500 );
0501
0502 DEFINE_EVENT(dev_pm_qos_request, dev_pm_qos_add_request,
0503
0504 TP_PROTO(const char *name, enum dev_pm_qos_req_type type,
0505 s32 new_value),
0506
0507 TP_ARGS(name, type, new_value)
0508 );
0509
0510 DEFINE_EVENT(dev_pm_qos_request, dev_pm_qos_update_request,
0511
0512 TP_PROTO(const char *name, enum dev_pm_qos_req_type type,
0513 s32 new_value),
0514
0515 TP_ARGS(name, type, new_value)
0516 );
0517
0518 DEFINE_EVENT(dev_pm_qos_request, dev_pm_qos_remove_request,
0519
0520 TP_PROTO(const char *name, enum dev_pm_qos_req_type type,
0521 s32 new_value),
0522
0523 TP_ARGS(name, type, new_value)
0524 );
0525
0526 TRACE_EVENT(guest_halt_poll_ns,
0527
0528 TP_PROTO(bool grow, unsigned int new, unsigned int old),
0529
0530 TP_ARGS(grow, new, old),
0531
0532 TP_STRUCT__entry(
0533 __field(bool, grow)
0534 __field(unsigned int, new)
0535 __field(unsigned int, old)
0536 ),
0537
0538 TP_fast_assign(
0539 __entry->grow = grow;
0540 __entry->new = new;
0541 __entry->old = old;
0542 ),
0543
0544 TP_printk("halt_poll_ns %u (%s %u)",
0545 __entry->new,
0546 __entry->grow ? "grow" : "shrink",
0547 __entry->old)
0548 );
0549
0550 #define trace_guest_halt_poll_ns_grow(new, old) \
0551 trace_guest_halt_poll_ns(true, new, old)
0552 #define trace_guest_halt_poll_ns_shrink(new, old) \
0553 trace_guest_halt_poll_ns(false, new, old)
0554 #endif
0555
0556
0557 #include <trace/define_trace.h>