blob: 042780563b04557717af5d6144e8fe0d4f44e827 [file] [log] [blame]
Li Zefand0b6e042009-07-13 10:33:21 +08001#undef TRACE_SYSTEM
2#define TRACE_SYSTEM sched
3
Steven Rostedtea20d922009-04-10 08:54:16 -04004#if !defined(_TRACE_SCHED_H) || defined(TRACE_HEADER_MULTI_READ)
Mathieu Desnoyers0a16b602008-07-18 12:16:17 -04005#define _TRACE_SCHED_H
6
7#include <linux/sched.h>
8#include <linux/tracepoint.h>
David Smith4ff16c22012-02-07 10:11:05 -06009#include <linux/binfmts.h>
Mathieu Desnoyers0a16b602008-07-18 12:16:17 -040010
Syed Rameez Mustafadddcab72016-09-07 16:18:27 -070011struct rq;
12
Steven Rostedtea20d922009-04-10 08:54:16 -040013/*
14 * Tracepoint for calling kthread_stop, performed to end a kthread:
15 */
16TRACE_EVENT(sched_kthread_stop,
17
18 TP_PROTO(struct task_struct *t),
19
20 TP_ARGS(t),
21
22 TP_STRUCT__entry(
23 __array( char, comm, TASK_COMM_LEN )
24 __field( pid_t, pid )
25 ),
26
27 TP_fast_assign(
28 memcpy(__entry->comm, t->comm, TASK_COMM_LEN);
29 __entry->pid = t->pid;
30 ),
31
Ingo Molnar434a83c2009-10-15 11:50:39 +020032 TP_printk("comm=%s pid=%d", __entry->comm, __entry->pid)
Steven Rostedtea20d922009-04-10 08:54:16 -040033);
34
35/*
36 * Tracepoint for the return value of the kthread stopping:
37 */
38TRACE_EVENT(sched_kthread_stop_ret,
39
40 TP_PROTO(int ret),
41
42 TP_ARGS(ret),
43
44 TP_STRUCT__entry(
45 __field( int, ret )
46 ),
47
48 TP_fast_assign(
49 __entry->ret = ret;
50 ),
51
Ingo Molnar434a83c2009-10-15 11:50:39 +020052 TP_printk("ret=%d", __entry->ret)
Steven Rostedtea20d922009-04-10 08:54:16 -040053);
54
55/*
Syed Rameez Mustafadddcab72016-09-07 16:18:27 -070056 * Tracepoint for task enqueue/dequeue:
57 */
58TRACE_EVENT(sched_enq_deq_task,
59
60 TP_PROTO(struct task_struct *p, bool enqueue, unsigned int cpus_allowed),
61
62 TP_ARGS(p, enqueue, cpus_allowed),
63
64 TP_STRUCT__entry(
65 __array( char, comm, TASK_COMM_LEN )
66 __field( pid_t, pid )
67 __field( int, prio )
68 __field( int, cpu )
69 __field( bool, enqueue )
70 __field(unsigned int, nr_running )
71 __field(unsigned long, cpu_load )
72 __field(unsigned int, rt_nr_running )
73 __field(unsigned int, cpus_allowed )
74#ifdef CONFIG_SCHED_HMP
75 __field(unsigned int, demand )
76 __field(unsigned int, pred_demand )
77#endif
78 ),
79
80 TP_fast_assign(
81 memcpy(__entry->comm, p->comm, TASK_COMM_LEN);
82 __entry->pid = p->pid;
83 __entry->prio = p->prio;
84 __entry->cpu = task_cpu(p);
85 __entry->enqueue = enqueue;
86 __entry->nr_running = task_rq(p)->nr_running;
87 __entry->cpu_load = task_rq(p)->cpu_load[0];
88 __entry->rt_nr_running = task_rq(p)->rt.rt_nr_running;
89 __entry->cpus_allowed = cpus_allowed;
90#ifdef CONFIG_SCHED_HMP
91 __entry->demand = p->ravg.demand;
92 __entry->pred_demand = p->ravg.pred_demand;
93#endif
94 ),
95
96 TP_printk("cpu=%d %s comm=%s pid=%d prio=%d nr_running=%u cpu_load=%lu rt_nr_running=%u affine=%x"
97#ifdef CONFIG_SCHED_HMP
98 " demand=%u pred_demand=%u"
99#endif
100 , __entry->cpu,
101 __entry->enqueue ? "enqueue" : "dequeue",
102 __entry->comm, __entry->pid,
103 __entry->prio, __entry->nr_running,
104 __entry->cpu_load, __entry->rt_nr_running, __entry->cpus_allowed
105#ifdef CONFIG_SCHED_HMP
106 , __entry->demand, __entry->pred_demand
107#endif
108 )
109);
110
111#ifdef CONFIG_SCHED_HMP
112
113struct group_cpu_time;
114struct migration_sum_data;
115extern const char *task_event_names[];
116extern const char *migrate_type_names[];
117
118TRACE_EVENT(sched_task_load,
119
120 TP_PROTO(struct task_struct *p, bool boost, int reason,
121 bool sync, bool need_idle, u32 flags, int best_cpu),
122
123 TP_ARGS(p, boost, reason, sync, need_idle, flags, best_cpu),
124
125 TP_STRUCT__entry(
126 __array( char, comm, TASK_COMM_LEN )
127 __field( pid_t, pid )
128 __field(unsigned int, demand )
129 __field( bool, boost )
130 __field( int, reason )
131 __field( bool, sync )
132 __field( bool, need_idle )
133 __field( u32, flags )
134 __field( int, best_cpu )
135 __field( u64, latency )
Syed Rameez Mustafa084075b2016-08-31 16:54:12 -0700136 __field( int, grp_id )
Srivatsa Vaddagirica00d552016-05-13 02:05:32 -0700137 __field( u64, avg_burst )
Srivatsa Vaddagiri52465c42016-09-09 19:50:27 +0530138 __field( u64, avg_sleep )
Syed Rameez Mustafadddcab72016-09-07 16:18:27 -0700139 ),
140
141 TP_fast_assign(
142 memcpy(__entry->comm, p->comm, TASK_COMM_LEN);
143 __entry->pid = p->pid;
144 __entry->demand = p->ravg.demand;
145 __entry->boost = boost;
146 __entry->reason = reason;
147 __entry->sync = sync;
148 __entry->need_idle = need_idle;
149 __entry->flags = flags;
150 __entry->best_cpu = best_cpu;
151 __entry->latency = p->state == TASK_WAKING ?
152 sched_ktime_clock() -
153 p->ravg.mark_start : 0;
Syed Rameez Mustafa084075b2016-08-31 16:54:12 -0700154 __entry->grp_id = p->grp ? p->grp->id : 0;
Srivatsa Vaddagirica00d552016-05-13 02:05:32 -0700155 __entry->avg_burst = p->ravg.avg_burst;
Srivatsa Vaddagiri52465c42016-09-09 19:50:27 +0530156 __entry->avg_sleep = p->ravg.avg_sleep_time;
Syed Rameez Mustafadddcab72016-09-07 16:18:27 -0700157 ),
158
Srivatsa Vaddagiri52465c42016-09-09 19:50:27 +0530159 TP_printk("%d (%s): demand=%u boost=%d reason=%d sync=%d need_idle=%d flags=%x grp=%d best_cpu=%d latency=%llu avg_burst=%llu avg_sleep=%llu",
Syed Rameez Mustafadddcab72016-09-07 16:18:27 -0700160 __entry->pid, __entry->comm, __entry->demand,
161 __entry->boost, __entry->reason, __entry->sync,
Syed Rameez Mustafa084075b2016-08-31 16:54:12 -0700162 __entry->need_idle, __entry->flags, __entry->grp_id,
Srivatsa Vaddagiri52465c42016-09-09 19:50:27 +0530163 __entry->best_cpu, __entry->latency, __entry->avg_burst,
164 __entry->avg_sleep)
Syed Rameez Mustafadddcab72016-09-07 16:18:27 -0700165);
166
167TRACE_EVENT(sched_set_preferred_cluster,
168
169 TP_PROTO(struct related_thread_group *grp, u64 total_demand),
170
171 TP_ARGS(grp, total_demand),
172
173 TP_STRUCT__entry(
Syed Rameez Mustafa084075b2016-08-31 16:54:12 -0700174 __field( int, id )
175 __field( u64, demand )
176 __field( int, cluster_first_cpu )
177 __array( char, comm, TASK_COMM_LEN )
178 __field( pid_t, pid )
179 __field(unsigned int, task_demand )
Syed Rameez Mustafadddcab72016-09-07 16:18:27 -0700180 ),
181
182 TP_fast_assign(
183 __entry->id = grp->id;
184 __entry->demand = total_demand;
185 __entry->cluster_first_cpu = grp->preferred_cluster ?
186 cluster_first_cpu(grp->preferred_cluster)
187 : -1;
188 ),
189
190 TP_printk("group_id %d total_demand %llu preferred_cluster_first_cpu %d",
191 __entry->id, __entry->demand,
192 __entry->cluster_first_cpu)
193);
194
195DECLARE_EVENT_CLASS(sched_cpu_load,
196
197 TP_PROTO(struct rq *rq, int idle, u64 irqload, unsigned int power_cost, int temp),
198
199 TP_ARGS(rq, idle, irqload, power_cost, temp),
200
201 TP_STRUCT__entry(
202 __field(unsigned int, cpu )
203 __field(unsigned int, idle )
204 __field(unsigned int, nr_running )
205 __field(unsigned int, nr_big_tasks )
206 __field(unsigned int, load_scale_factor )
207 __field(unsigned int, capacity )
208 __field( u64, cumulative_runnable_avg )
209 __field( u64, irqload )
210 __field(unsigned int, max_freq )
211 __field(unsigned int, power_cost )
212 __field( int, cstate )
213 __field( int, dstate )
214 __field( int, temp )
215 ),
216
217 TP_fast_assign(
218 __entry->cpu = rq->cpu;
219 __entry->idle = idle;
220 __entry->nr_running = rq->nr_running;
221 __entry->nr_big_tasks = rq->hmp_stats.nr_big_tasks;
222 __entry->load_scale_factor = cpu_load_scale_factor(rq->cpu);
223 __entry->capacity = cpu_capacity(rq->cpu);
224 __entry->cumulative_runnable_avg = rq->hmp_stats.cumulative_runnable_avg;
225 __entry->irqload = irqload;
226 __entry->max_freq = cpu_max_freq(rq->cpu);
227 __entry->power_cost = power_cost;
228 __entry->cstate = rq->cstate;
229 __entry->dstate = rq->cluster->dstate;
230 __entry->temp = temp;
231 ),
232
233 TP_printk("cpu %u idle %d nr_run %u nr_big %u lsf %u capacity %u cr_avg %llu irqload %llu fmax %u power_cost %u cstate %d dstate %d temp %d",
234 __entry->cpu, __entry->idle, __entry->nr_running, __entry->nr_big_tasks,
235 __entry->load_scale_factor, __entry->capacity,
236 __entry->cumulative_runnable_avg, __entry->irqload,
237 __entry->max_freq, __entry->power_cost, __entry->cstate,
238 __entry->dstate, __entry->temp)
239);
240
241DEFINE_EVENT(sched_cpu_load, sched_cpu_load_wakeup,
242 TP_PROTO(struct rq *rq, int idle, u64 irqload, unsigned int power_cost, int temp),
243 TP_ARGS(rq, idle, irqload, power_cost, temp)
244);
245
246DEFINE_EVENT(sched_cpu_load, sched_cpu_load_lb,
247 TP_PROTO(struct rq *rq, int idle, u64 irqload, unsigned int power_cost, int temp),
248 TP_ARGS(rq, idle, irqload, power_cost, temp)
249);
250
251DEFINE_EVENT(sched_cpu_load, sched_cpu_load_cgroup,
252 TP_PROTO(struct rq *rq, int idle, u64 irqload, unsigned int power_cost, int temp),
253 TP_ARGS(rq, idle, irqload, power_cost, temp)
254);
255
256TRACE_EVENT(sched_set_boost,
257
Syed Rameez Mustafa084075b2016-08-31 16:54:12 -0700258 TP_PROTO(int type),
Syed Rameez Mustafadddcab72016-09-07 16:18:27 -0700259
Syed Rameez Mustafa084075b2016-08-31 16:54:12 -0700260 TP_ARGS(type),
Syed Rameez Mustafadddcab72016-09-07 16:18:27 -0700261
262 TP_STRUCT__entry(
Syed Rameez Mustafa084075b2016-08-31 16:54:12 -0700263 __field(int, type )
Syed Rameez Mustafadddcab72016-09-07 16:18:27 -0700264 ),
265
266 TP_fast_assign(
Syed Rameez Mustafa084075b2016-08-31 16:54:12 -0700267 __entry->type = type;
Syed Rameez Mustafadddcab72016-09-07 16:18:27 -0700268 ),
269
Syed Rameez Mustafa084075b2016-08-31 16:54:12 -0700270 TP_printk("type %d", __entry->type)
Syed Rameez Mustafadddcab72016-09-07 16:18:27 -0700271);
272
Syed Rameez Mustafa60cef212016-05-09 16:28:07 -0700273#if defined(CREATE_TRACE_POINTS) && defined(CONFIG_SCHED_HMP)
274static inline void __window_data(u32 *dst, u32 *src)
275{
276 if (src)
277 memcpy(dst, src, nr_cpu_ids * sizeof(u32));
278 else
279 memset(dst, 0, nr_cpu_ids * sizeof(u32));
280}
281
282struct trace_seq;
283const char *__window_print(struct trace_seq *p, const u32 *buf, int buf_len)
284{
285 int i;
286 const char *ret = p->buffer + seq_buf_used(&p->seq);
287
288 for (i = 0; i < buf_len; i++)
289 trace_seq_printf(p, "%u ", buf[i]);
290
291 trace_seq_putc(p, 0);
292
293 return ret;
294}
Pavankumar Kondeti6deb2c42017-01-09 13:56:33 +0530295
296static inline s64 __rq_update_sum(struct rq *rq, bool curr, bool new)
297{
298 if (curr)
299 if (new)
300 return rq->nt_curr_runnable_sum;
301 else
302 return rq->curr_runnable_sum;
303 else
304 if (new)
305 return rq->nt_prev_runnable_sum;
306 else
307 return rq->prev_runnable_sum;
308}
309
310static inline s64 __grp_update_sum(struct rq *rq, bool curr, bool new)
311{
312 if (curr)
313 if (new)
314 return rq->grp_time.nt_curr_runnable_sum;
315 else
316 return rq->grp_time.curr_runnable_sum;
317 else
318 if (new)
319 return rq->grp_time.nt_prev_runnable_sum;
320 else
321 return rq->grp_time.prev_runnable_sum;
322}
323
324static inline s64
325__get_update_sum(struct rq *rq, enum migrate_types migrate_type,
326 bool src, bool new, bool curr)
327{
328 switch (migrate_type) {
329 case RQ_TO_GROUP:
330 if (src)
331 return __rq_update_sum(rq, curr, new);
332 else
333 return __grp_update_sum(rq, curr, new);
334 case GROUP_TO_RQ:
335 if (src)
336 return __grp_update_sum(rq, curr, new);
337 else
338 return __rq_update_sum(rq, curr, new);
339 default:
340 WARN_ON_ONCE(1);
341 return -1;
342 }
343}
Syed Rameez Mustafa60cef212016-05-09 16:28:07 -0700344#endif
345
Syed Rameez Mustafadddcab72016-09-07 16:18:27 -0700346TRACE_EVENT(sched_update_task_ravg,
347
348 TP_PROTO(struct task_struct *p, struct rq *rq, enum task_event evt,
349 u64 wallclock, u64 irqtime, u64 cycles, u64 exec_time,
350 struct group_cpu_time *cpu_time),
351
352 TP_ARGS(p, rq, evt, wallclock, irqtime, cycles, exec_time, cpu_time),
353
354 TP_STRUCT__entry(
355 __array( char, comm, TASK_COMM_LEN )
356 __field( pid_t, pid )
357 __field( pid_t, cur_pid )
358 __field(unsigned int, cur_freq )
359 __field( u64, wallclock )
360 __field( u64, mark_start )
361 __field( u64, delta_m )
362 __field( u64, win_start )
363 __field( u64, delta )
364 __field( u64, irqtime )
365 __field(enum task_event, evt )
366 __field(unsigned int, demand )
367 __field(unsigned int, sum )
368 __field( int, cpu )
369 __field(unsigned int, pred_demand )
370 __field( u64, rq_cs )
371 __field( u64, rq_ps )
372 __field( u64, grp_cs )
373 __field( u64, grp_ps )
Syed Rameez Mustafa60cef212016-05-09 16:28:07 -0700374 __field( u64, grp_nt_cs )
375 __field( u64, grp_nt_ps )
Syed Rameez Mustafadddcab72016-09-07 16:18:27 -0700376 __field( u32, curr_window )
377 __field( u32, prev_window )
Syed Rameez Mustafa60cef212016-05-09 16:28:07 -0700378 __dynamic_array(u32, curr_sum, nr_cpu_ids )
379 __dynamic_array(u32, prev_sum, nr_cpu_ids )
Syed Rameez Mustafadddcab72016-09-07 16:18:27 -0700380 __field( u64, nt_cs )
381 __field( u64, nt_ps )
382 __field( u32, active_windows )
Syed Rameez Mustafa59b5fb72016-05-31 16:40:45 -0700383 __field( u8, curr_top )
384 __field( u8, prev_top )
Syed Rameez Mustafadddcab72016-09-07 16:18:27 -0700385 ),
386
387 TP_fast_assign(
388 __entry->wallclock = wallclock;
389 __entry->win_start = rq->window_start;
390 __entry->delta = (wallclock - rq->window_start);
391 __entry->evt = evt;
392 __entry->cpu = rq->cpu;
393 __entry->cur_pid = rq->curr->pid;
394 __entry->cur_freq = cpu_cycles_to_freq(cycles, exec_time);
395 memcpy(__entry->comm, p->comm, TASK_COMM_LEN);
396 __entry->pid = p->pid;
397 __entry->mark_start = p->ravg.mark_start;
398 __entry->delta_m = (wallclock - p->ravg.mark_start);
399 __entry->demand = p->ravg.demand;
400 __entry->sum = p->ravg.sum;
401 __entry->irqtime = irqtime;
402 __entry->pred_demand = p->ravg.pred_demand;
403 __entry->rq_cs = rq->curr_runnable_sum;
404 __entry->rq_ps = rq->prev_runnable_sum;
405 __entry->grp_cs = cpu_time ? cpu_time->curr_runnable_sum : 0;
406 __entry->grp_ps = cpu_time ? cpu_time->prev_runnable_sum : 0;
407 __entry->grp_nt_cs = cpu_time ? cpu_time->nt_curr_runnable_sum : 0;
408 __entry->grp_nt_ps = cpu_time ? cpu_time->nt_prev_runnable_sum : 0;
409 __entry->curr_window = p->ravg.curr_window;
410 __entry->prev_window = p->ravg.prev_window;
Syed Rameez Mustafa60cef212016-05-09 16:28:07 -0700411 __window_data(__get_dynamic_array(curr_sum), p->ravg.curr_window_cpu);
412 __window_data(__get_dynamic_array(prev_sum), p->ravg.prev_window_cpu);
Syed Rameez Mustafadddcab72016-09-07 16:18:27 -0700413 __entry->nt_cs = rq->nt_curr_runnable_sum;
414 __entry->nt_ps = rq->nt_prev_runnable_sum;
415 __entry->active_windows = p->ravg.active_windows;
Syed Rameez Mustafa59b5fb72016-05-31 16:40:45 -0700416 __entry->curr_top = rq->curr_top;
417 __entry->prev_top = rq->prev_top;
Syed Rameez Mustafadddcab72016-09-07 16:18:27 -0700418 ),
419
Syed Rameez Mustafa59b5fb72016-05-31 16:40:45 -0700420 TP_printk("wc %llu ws %llu delta %llu event %s cpu %d cur_freq %u cur_pid %d task %d (%s) ms %llu delta %llu demand %u sum %u irqtime %llu pred_demand %u rq_cs %llu rq_ps %llu cur_window %u (%s) prev_window %u (%s) nt_cs %llu nt_ps %llu active_wins %u grp_cs %lld grp_ps %lld, grp_nt_cs %llu, grp_nt_ps: %llu curr_top %u prev_top %u",
421 __entry->wallclock, __entry->win_start, __entry->delta,
Syed Rameez Mustafadddcab72016-09-07 16:18:27 -0700422 task_event_names[__entry->evt], __entry->cpu,
423 __entry->cur_freq, __entry->cur_pid,
424 __entry->pid, __entry->comm, __entry->mark_start,
425 __entry->delta_m, __entry->demand,
426 __entry->sum, __entry->irqtime, __entry->pred_demand,
427 __entry->rq_cs, __entry->rq_ps, __entry->curr_window,
Syed Rameez Mustafa60cef212016-05-09 16:28:07 -0700428 __window_print(p, __get_dynamic_array(curr_sum), nr_cpu_ids),
429 __entry->prev_window,
430 __window_print(p, __get_dynamic_array(prev_sum), nr_cpu_ids),
431 __entry->nt_cs, __entry->nt_ps,
Syed Rameez Mustafadddcab72016-09-07 16:18:27 -0700432 __entry->active_windows, __entry->grp_cs,
Syed Rameez Mustafa59b5fb72016-05-31 16:40:45 -0700433 __entry->grp_ps, __entry->grp_nt_cs, __entry->grp_nt_ps,
434 __entry->curr_top, __entry->prev_top)
Syed Rameez Mustafadddcab72016-09-07 16:18:27 -0700435);
436
437TRACE_EVENT(sched_get_task_cpu_cycles,
438
439 TP_PROTO(int cpu, int event, u64 cycles, u64 exec_time),
440
441 TP_ARGS(cpu, event, cycles, exec_time),
442
443 TP_STRUCT__entry(
444 __field(int, cpu )
445 __field(int, event )
446 __field(u64, cycles )
447 __field(u64, exec_time )
448 __field(u32, freq )
449 __field(u32, legacy_freq )
450 ),
451
452 TP_fast_assign(
453 __entry->cpu = cpu;
454 __entry->event = event;
455 __entry->cycles = cycles;
456 __entry->exec_time = exec_time;
457 __entry->freq = cpu_cycles_to_freq(cycles, exec_time);
458 __entry->legacy_freq = cpu_cur_freq(cpu);
459 ),
460
461 TP_printk("cpu=%d event=%d cycles=%llu exec_time=%llu freq=%u legacy_freq=%u",
462 __entry->cpu, __entry->event, __entry->cycles,
463 __entry->exec_time, __entry->freq, __entry->legacy_freq)
464);
465
466TRACE_EVENT(sched_update_history,
467
468 TP_PROTO(struct rq *rq, struct task_struct *p, u32 runtime, int samples,
469 enum task_event evt),
470
471 TP_ARGS(rq, p, runtime, samples, evt),
472
473 TP_STRUCT__entry(
474 __array( char, comm, TASK_COMM_LEN )
475 __field( pid_t, pid )
476 __field(unsigned int, runtime )
477 __field( int, samples )
478 __field(enum task_event, evt )
479 __field(unsigned int, demand )
480 __field(unsigned int, pred_demand )
481 __array( u32, hist, RAVG_HIST_SIZE_MAX)
482 __field(unsigned int, nr_big_tasks )
483 __field( int, cpu )
484 ),
485
486 TP_fast_assign(
487 memcpy(__entry->comm, p->comm, TASK_COMM_LEN);
488 __entry->pid = p->pid;
489 __entry->runtime = runtime;
490 __entry->samples = samples;
491 __entry->evt = evt;
492 __entry->demand = p->ravg.demand;
493 __entry->pred_demand = p->ravg.pred_demand;
494 memcpy(__entry->hist, p->ravg.sum_history,
495 RAVG_HIST_SIZE_MAX * sizeof(u32));
496 __entry->nr_big_tasks = rq->hmp_stats.nr_big_tasks;
497 __entry->cpu = rq->cpu;
498 ),
499
500 TP_printk("%d (%s): runtime %u samples %d event %s demand %u pred_demand %u"
501 " (hist: %u %u %u %u %u) cpu %d nr_big %u",
502 __entry->pid, __entry->comm,
503 __entry->runtime, __entry->samples,
504 task_event_names[__entry->evt],
505 __entry->demand, __entry->pred_demand,
506 __entry->hist[0], __entry->hist[1],
507 __entry->hist[2], __entry->hist[3],
508 __entry->hist[4], __entry->cpu, __entry->nr_big_tasks)
509);
510
511TRACE_EVENT(sched_reset_all_window_stats,
512
513 TP_PROTO(u64 window_start, u64 window_size, u64 time_taken,
514 int reason, unsigned int old_val, unsigned int new_val),
515
516 TP_ARGS(window_start, window_size, time_taken,
517 reason, old_val, new_val),
518
519 TP_STRUCT__entry(
520 __field( u64, window_start )
521 __field( u64, window_size )
522 __field( u64, time_taken )
523 __field( int, reason )
524 __field(unsigned int, old_val )
525 __field(unsigned int, new_val )
526 ),
527
528 TP_fast_assign(
529 __entry->window_start = window_start;
530 __entry->window_size = window_size;
531 __entry->time_taken = time_taken;
532 __entry->reason = reason;
533 __entry->old_val = old_val;
534 __entry->new_val = new_val;
535 ),
536
537 TP_printk("time_taken %llu window_start %llu window_size %llu reason %s old_val %u new_val %u",
538 __entry->time_taken, __entry->window_start,
539 __entry->window_size,
540 sched_window_reset_reasons[__entry->reason],
541 __entry->old_val, __entry->new_val)
542);
543
544TRACE_EVENT(sched_update_pred_demand,
545
546 TP_PROTO(struct rq *rq, struct task_struct *p, u32 runtime, int pct,
547 unsigned int pred_demand),
548
549 TP_ARGS(rq, p, runtime, pct, pred_demand),
550
551 TP_STRUCT__entry(
552 __array( char, comm, TASK_COMM_LEN )
553 __field( pid_t, pid )
554 __field(unsigned int, runtime )
555 __field( int, pct )
556 __field(unsigned int, pred_demand )
557 __array( u8, bucket, NUM_BUSY_BUCKETS)
558 __field( int, cpu )
559 ),
560
561 TP_fast_assign(
562 memcpy(__entry->comm, p->comm, TASK_COMM_LEN);
563 __entry->pid = p->pid;
564 __entry->runtime = runtime;
565 __entry->pct = pct;
566 __entry->pred_demand = pred_demand;
567 memcpy(__entry->bucket, p->ravg.busy_buckets,
568 NUM_BUSY_BUCKETS * sizeof(u8));
569 __entry->cpu = rq->cpu;
570 ),
571
572 TP_printk("%d (%s): runtime %u pct %d cpu %d pred_demand %u (buckets: %u %u %u %u %u %u %u %u %u %u)",
573 __entry->pid, __entry->comm,
574 __entry->runtime, __entry->pct, __entry->cpu,
575 __entry->pred_demand, __entry->bucket[0], __entry->bucket[1],
576 __entry->bucket[2], __entry->bucket[3] ,__entry->bucket[4],
577 __entry->bucket[5], __entry->bucket[6], __entry->bucket[7],
578 __entry->bucket[8], __entry->bucket[9])
579);
580
581TRACE_EVENT(sched_migration_update_sum,
582
Pavankumar Kondeti6deb2c42017-01-09 13:56:33 +0530583 TP_PROTO(struct task_struct *p, enum migrate_types migrate_type, struct rq *rq),
Syed Rameez Mustafadddcab72016-09-07 16:18:27 -0700584
Pavankumar Kondeti6deb2c42017-01-09 13:56:33 +0530585 TP_ARGS(p, migrate_type, rq),
Syed Rameez Mustafadddcab72016-09-07 16:18:27 -0700586
587 TP_STRUCT__entry(
588 __field(int, tcpu )
589 __field(int, pid )
Syed Rameez Mustafadddcab72016-09-07 16:18:27 -0700590 __field(enum migrate_types, migrate_type )
591 __field( s64, src_cs )
592 __field( s64, src_ps )
593 __field( s64, dst_cs )
594 __field( s64, dst_ps )
595 __field( s64, src_nt_cs )
596 __field( s64, src_nt_ps )
597 __field( s64, dst_nt_cs )
598 __field( s64, dst_nt_ps )
599 ),
600
601 TP_fast_assign(
602 __entry->tcpu = task_cpu(p);
603 __entry->pid = p->pid;
604 __entry->migrate_type = migrate_type;
Pavankumar Kondeti6deb2c42017-01-09 13:56:33 +0530605 __entry->src_cs = __get_update_sum(rq, migrate_type,
606 true, false, true);
607 __entry->src_ps = __get_update_sum(rq, migrate_type,
608 true, false, false);
609 __entry->dst_cs = __get_update_sum(rq, migrate_type,
610 false, false, true);
611 __entry->dst_ps = __get_update_sum(rq, migrate_type,
612 false, false, false);
613 __entry->src_nt_cs = __get_update_sum(rq, migrate_type,
614 true, true, true);
615 __entry->src_nt_ps = __get_update_sum(rq, migrate_type,
616 true, true, false);
617 __entry->dst_nt_cs = __get_update_sum(rq, migrate_type,
618 false, true, true);
619 __entry->dst_nt_ps = __get_update_sum(rq, migrate_type,
620 false, true, false);
Syed Rameez Mustafadddcab72016-09-07 16:18:27 -0700621 ),
622
623 TP_printk("pid %d task_cpu %d migrate_type %s src_cs %llu src_ps %llu dst_cs %lld dst_ps %lld src_nt_cs %llu src_nt_ps %llu dst_nt_cs %lld dst_nt_ps %lld",
624 __entry->pid, __entry->tcpu, migrate_type_names[__entry->migrate_type],
625 __entry->src_cs, __entry->src_ps, __entry->dst_cs, __entry->dst_ps,
626 __entry->src_nt_cs, __entry->src_nt_ps, __entry->dst_nt_cs, __entry->dst_nt_ps)
627);
628
629TRACE_EVENT(sched_get_busy,
630
631 TP_PROTO(int cpu, u64 load, u64 nload, u64 pload, int early),
632
633 TP_ARGS(cpu, load, nload, pload, early),
634
635 TP_STRUCT__entry(
636 __field( int, cpu )
637 __field( u64, load )
638 __field( u64, nload )
639 __field( u64, pload )
640 __field( int, early )
641 ),
642
643 TP_fast_assign(
644 __entry->cpu = cpu;
645 __entry->load = load;
646 __entry->nload = nload;
647 __entry->pload = pload;
648 __entry->early = early;
649 ),
650
651 TP_printk("cpu %d load %lld new_task_load %lld predicted_load %lld early %d",
652 __entry->cpu, __entry->load, __entry->nload,
653 __entry->pload, __entry->early)
654);
655
656TRACE_EVENT(sched_freq_alert,
657
658 TP_PROTO(int cpu, int pd_notif, int check_groups, struct rq *rq,
659 u64 new_load),
660
661 TP_ARGS(cpu, pd_notif, check_groups, rq, new_load),
662
663 TP_STRUCT__entry(
664 __field( int, cpu )
665 __field( int, pd_notif )
666 __field( int, check_groups )
667 __field( u64, old_busy_time )
668 __field( u64, ps )
669 __field( u64, new_load )
670 __field( u64, old_pred )
671 __field( u64, new_pred )
672 ),
673
674 TP_fast_assign(
675 __entry->cpu = cpu;
676 __entry->pd_notif = pd_notif;
677 __entry->check_groups = check_groups;
678 __entry->old_busy_time = rq->old_busy_time;
679 __entry->ps = rq->prev_runnable_sum;
680 __entry->new_load = new_load;
681 __entry->old_pred = rq->old_estimated_time;
682 __entry->new_pred = rq->hmp_stats.pred_demands_sum;
683 ),
684
685 TP_printk("cpu %d pd_notif=%d check_groups %d old_busy_time=%llu prev_sum=%lld new_load=%llu old_pred=%llu new_pred=%llu",
686 __entry->cpu, __entry->pd_notif, __entry->check_groups,
687 __entry->old_busy_time, __entry->ps, __entry->new_load,
688 __entry->old_pred, __entry->new_pred)
689);
690
691#endif /* CONFIG_SCHED_HMP */
692
693/*
Steven Rostedtea20d922009-04-10 08:54:16 -0400694 * Tracepoint for waking up a task:
Steven Rostedtea20d922009-04-10 08:54:16 -0400695 */
Ingo Molnar091ad362009-11-26 09:04:55 +0100696DECLARE_EVENT_CLASS(sched_wakeup_template,
Steven Rostedtea20d922009-04-10 08:54:16 -0400697
Peter Zijlstrafbd705a2015-06-09 11:13:36 +0200698 TP_PROTO(struct task_struct *p),
Steven Rostedtea20d922009-04-10 08:54:16 -0400699
Peter Zijlstrafbd705a2015-06-09 11:13:36 +0200700 TP_ARGS(__perf_task(p)),
Steven Rostedtea20d922009-04-10 08:54:16 -0400701
702 TP_STRUCT__entry(
703 __array( char, comm, TASK_COMM_LEN )
704 __field( pid_t, pid )
705 __field( int, prio )
706 __field( int, success )
Ingo Molnar434a83c2009-10-15 11:50:39 +0200707 __field( int, target_cpu )
Steven Rostedtea20d922009-04-10 08:54:16 -0400708 ),
709
710 TP_fast_assign(
711 memcpy(__entry->comm, p->comm, TASK_COMM_LEN);
712 __entry->pid = p->pid;
713 __entry->prio = p->prio;
Peter Zijlstrafbd705a2015-06-09 11:13:36 +0200714 __entry->success = 1; /* rudiment, kill when possible */
Ingo Molnar434a83c2009-10-15 11:50:39 +0200715 __entry->target_cpu = task_cpu(p);
Steven Rostedtea20d922009-04-10 08:54:16 -0400716 ),
717
Peter Zijlstrafbd705a2015-06-09 11:13:36 +0200718 TP_printk("comm=%s pid=%d prio=%d target_cpu=%03d",
Steven Rostedtea20d922009-04-10 08:54:16 -0400719 __entry->comm, __entry->pid, __entry->prio,
Peter Zijlstrafbd705a2015-06-09 11:13:36 +0200720 __entry->target_cpu)
Steven Rostedtea20d922009-04-10 08:54:16 -0400721);
722
Peter Zijlstrafbd705a2015-06-09 11:13:36 +0200723/*
724 * Tracepoint called when waking a task; this tracepoint is guaranteed to be
725 * called from the waking context.
726 */
727DEFINE_EVENT(sched_wakeup_template, sched_waking,
728 TP_PROTO(struct task_struct *p),
729 TP_ARGS(p));
730
731/*
732 * Tracepoint called when the task is actually woken; p->state == TASK_RUNNNG.
733 * It it not always called from the waking context.
734 */
Steven Rostedt75ec29a2009-11-18 20:48:08 -0500735DEFINE_EVENT(sched_wakeup_template, sched_wakeup,
Peter Zijlstrafbd705a2015-06-09 11:13:36 +0200736 TP_PROTO(struct task_struct *p),
737 TP_ARGS(p));
Steven Rostedt75ec29a2009-11-18 20:48:08 -0500738
Steven Rostedtea20d922009-04-10 08:54:16 -0400739/*
740 * Tracepoint for waking up a new task:
Steven Rostedtea20d922009-04-10 08:54:16 -0400741 */
Steven Rostedt75ec29a2009-11-18 20:48:08 -0500742DEFINE_EVENT(sched_wakeup_template, sched_wakeup_new,
Peter Zijlstrafbd705a2015-06-09 11:13:36 +0200743 TP_PROTO(struct task_struct *p),
744 TP_ARGS(p));
Steven Rostedtea20d922009-04-10 08:54:16 -0400745
Peter Zijlstra02f72692010-05-31 18:13:25 +0200746#ifdef CREATE_TRACE_POINTS
Peter Zijlstrac73464b2015-09-28 18:06:56 +0200747static inline long __trace_sched_switch_state(bool preempt, struct task_struct *p)
Peter Zijlstra02f72692010-05-31 18:13:25 +0200748{
Oleg Nesterov8f9fbf02014-10-07 21:51:08 +0200749#ifdef CONFIG_SCHED_DEBUG
750 BUG_ON(p != current);
751#endif /* CONFIG_SCHED_DEBUG */
Peter Zijlstra02f72692010-05-31 18:13:25 +0200752
Peter Zijlstrac73464b2015-09-28 18:06:56 +0200753 /*
754 * Preemption ignores task state, therefore preempted tasks are always
755 * RUNNING (we will not have dequeued if state != RUNNING).
756 */
757 return preempt ? TASK_RUNNING | TASK_STATE_MAX : p->state;
Peter Zijlstra02f72692010-05-31 18:13:25 +0200758}
Oleg Nesterov8f9fbf02014-10-07 21:51:08 +0200759#endif /* CREATE_TRACE_POINTS */
Peter Zijlstra02f72692010-05-31 18:13:25 +0200760
Steven Rostedtea20d922009-04-10 08:54:16 -0400761/*
762 * Tracepoint for task switches, performed by the scheduler:
Steven Rostedtea20d922009-04-10 08:54:16 -0400763 */
764TRACE_EVENT(sched_switch,
765
Peter Zijlstrac73464b2015-09-28 18:06:56 +0200766 TP_PROTO(bool preempt,
767 struct task_struct *prev,
Steven Rostedtea20d922009-04-10 08:54:16 -0400768 struct task_struct *next),
769
Peter Zijlstrac73464b2015-09-28 18:06:56 +0200770 TP_ARGS(preempt, prev, next),
Steven Rostedtea20d922009-04-10 08:54:16 -0400771
772 TP_STRUCT__entry(
773 __array( char, prev_comm, TASK_COMM_LEN )
774 __field( pid_t, prev_pid )
775 __field( int, prev_prio )
Steven Rostedt937cdb92009-05-15 10:51:13 -0400776 __field( long, prev_state )
Steven Rostedtea20d922009-04-10 08:54:16 -0400777 __array( char, next_comm, TASK_COMM_LEN )
778 __field( pid_t, next_pid )
779 __field( int, next_prio )
780 ),
781
782 TP_fast_assign(
783 memcpy(__entry->next_comm, next->comm, TASK_COMM_LEN);
784 __entry->prev_pid = prev->pid;
785 __entry->prev_prio = prev->prio;
Peter Zijlstrac73464b2015-09-28 18:06:56 +0200786 __entry->prev_state = __trace_sched_switch_state(preempt, prev);
Steven Rostedtea20d922009-04-10 08:54:16 -0400787 memcpy(__entry->prev_comm, prev->comm, TASK_COMM_LEN);
788 __entry->next_pid = next->pid;
789 __entry->next_prio = next->prio;
790 ),
791
Peter Zijlstra557ab422011-09-16 11:16:43 +0200792 TP_printk("prev_comm=%s prev_pid=%d prev_prio=%d prev_state=%s%s ==> next_comm=%s next_pid=%d next_prio=%d",
Steven Rostedtea20d922009-04-10 08:54:16 -0400793 __entry->prev_comm, __entry->prev_pid, __entry->prev_prio,
Peter Zijlstra557ab422011-09-16 11:16:43 +0200794 __entry->prev_state & (TASK_STATE_MAX-1) ?
795 __print_flags(__entry->prev_state & (TASK_STATE_MAX-1), "|",
Steven Rostedt937cdb92009-05-15 10:51:13 -0400796 { 1, "S"} , { 2, "D" }, { 4, "T" }, { 8, "t" },
797 { 16, "Z" }, { 32, "X" }, { 64, "x" },
Peter Zijlstra80ed87c2015-05-08 14:23:45 +0200798 { 128, "K" }, { 256, "W" }, { 512, "P" },
799 { 1024, "N" }) : "R",
Peter Zijlstra557ab422011-09-16 11:16:43 +0200800 __entry->prev_state & TASK_STATE_MAX ? "+" : "",
Steven Rostedtea20d922009-04-10 08:54:16 -0400801 __entry->next_comm, __entry->next_pid, __entry->next_prio)
802);
803
804/*
805 * Tracepoint for a task being migrated:
806 */
807TRACE_EVENT(sched_migrate_task,
808
Syed Rameez Mustafadddcab72016-09-07 16:18:27 -0700809 TP_PROTO(struct task_struct *p, int dest_cpu, unsigned int load),
Steven Rostedtea20d922009-04-10 08:54:16 -0400810
Syed Rameez Mustafadddcab72016-09-07 16:18:27 -0700811 TP_ARGS(p, dest_cpu, load),
Steven Rostedtea20d922009-04-10 08:54:16 -0400812
813 TP_STRUCT__entry(
814 __array( char, comm, TASK_COMM_LEN )
815 __field( pid_t, pid )
816 __field( int, prio )
Syed Rameez Mustafadddcab72016-09-07 16:18:27 -0700817 __field(unsigned int, load )
Steven Rostedtea20d922009-04-10 08:54:16 -0400818 __field( int, orig_cpu )
819 __field( int, dest_cpu )
820 ),
821
822 TP_fast_assign(
823 memcpy(__entry->comm, p->comm, TASK_COMM_LEN);
824 __entry->pid = p->pid;
825 __entry->prio = p->prio;
Syed Rameez Mustafadddcab72016-09-07 16:18:27 -0700826 __entry->load = load;
Mathieu Desnoyersde1d7282009-05-05 16:49:59 +0800827 __entry->orig_cpu = task_cpu(p);
Steven Rostedtea20d922009-04-10 08:54:16 -0400828 __entry->dest_cpu = dest_cpu;
829 ),
830
Syed Rameez Mustafadddcab72016-09-07 16:18:27 -0700831 TP_printk("comm=%s pid=%d prio=%d load=%d orig_cpu=%d dest_cpu=%d",
832 __entry->comm, __entry->pid, __entry->prio, __entry->load,
Steven Rostedtea20d922009-04-10 08:54:16 -0400833 __entry->orig_cpu, __entry->dest_cpu)
834);
835
Syed Rameez Mustafadddcab72016-09-07 16:18:27 -0700836/*
837 * Tracepoint for a CPU going offline/online:
838 */
839TRACE_EVENT(sched_cpu_hotplug,
840
841 TP_PROTO(int affected_cpu, int error, int status),
842
843 TP_ARGS(affected_cpu, error, status),
844
845 TP_STRUCT__entry(
846 __field( int, affected_cpu )
847 __field( int, error )
848 __field( int, status )
849 ),
850
851 TP_fast_assign(
852 __entry->affected_cpu = affected_cpu;
853 __entry->error = error;
854 __entry->status = status;
855 ),
856
857 TP_printk("cpu %d %s error=%d", __entry->affected_cpu,
858 __entry->status ? "online" : "offline", __entry->error)
859);
860
861/*
862 * Tracepoint for load balancing:
863 */
864#if NR_CPUS > 32
865#error "Unsupported NR_CPUS for lb tracepoint."
866#endif
867TRACE_EVENT(sched_load_balance,
868
869 TP_PROTO(int cpu, enum cpu_idle_type idle, int balance,
870 unsigned long group_mask, int busiest_nr_running,
871 unsigned long imbalance, unsigned int env_flags, int ld_moved,
872 unsigned int balance_interval),
873
874 TP_ARGS(cpu, idle, balance, group_mask, busiest_nr_running,
875 imbalance, env_flags, ld_moved, balance_interval),
876
877 TP_STRUCT__entry(
878 __field( int, cpu)
879 __field( enum cpu_idle_type, idle)
880 __field( int, balance)
881 __field( unsigned long, group_mask)
882 __field( int, busiest_nr_running)
883 __field( unsigned long, imbalance)
884 __field( unsigned int, env_flags)
885 __field( int, ld_moved)
886 __field( unsigned int, balance_interval)
887 ),
888
889 TP_fast_assign(
890 __entry->cpu = cpu;
891 __entry->idle = idle;
892 __entry->balance = balance;
893 __entry->group_mask = group_mask;
894 __entry->busiest_nr_running = busiest_nr_running;
895 __entry->imbalance = imbalance;
896 __entry->env_flags = env_flags;
897 __entry->ld_moved = ld_moved;
898 __entry->balance_interval = balance_interval;
899 ),
900
901 TP_printk("cpu=%d state=%s balance=%d group=%#lx busy_nr=%d imbalance=%ld flags=%#x ld_moved=%d bal_int=%d",
902 __entry->cpu,
903 __entry->idle == CPU_IDLE ? "idle" :
904 (__entry->idle == CPU_NEWLY_IDLE ? "newly_idle" : "busy"),
905 __entry->balance,
906 __entry->group_mask, __entry->busiest_nr_running,
907 __entry->imbalance, __entry->env_flags, __entry->ld_moved,
908 __entry->balance_interval)
909);
910
Ingo Molnar091ad362009-11-26 09:04:55 +0100911DECLARE_EVENT_CLASS(sched_process_template,
Steven Rostedtea20d922009-04-10 08:54:16 -0400912
913 TP_PROTO(struct task_struct *p),
914
915 TP_ARGS(p),
916
917 TP_STRUCT__entry(
918 __array( char, comm, TASK_COMM_LEN )
919 __field( pid_t, pid )
920 __field( int, prio )
921 ),
922
923 TP_fast_assign(
924 memcpy(__entry->comm, p->comm, TASK_COMM_LEN);
925 __entry->pid = p->pid;
926 __entry->prio = p->prio;
927 ),
928
Ingo Molnar434a83c2009-10-15 11:50:39 +0200929 TP_printk("comm=%s pid=%d prio=%d",
Steven Rostedtea20d922009-04-10 08:54:16 -0400930 __entry->comm, __entry->pid, __entry->prio)
931);
932
933/*
Steven Rostedt75ec29a2009-11-18 20:48:08 -0500934 * Tracepoint for freeing a task:
935 */
936DEFINE_EVENT(sched_process_template, sched_process_free,
937 TP_PROTO(struct task_struct *p),
938 TP_ARGS(p));
Riley Andrews9de15b42015-10-02 00:39:53 -0700939
Steven Rostedt75ec29a2009-11-18 20:48:08 -0500940
941/*
Steven Rostedtea20d922009-04-10 08:54:16 -0400942 * Tracepoint for a task exiting:
943 */
Steven Rostedt75ec29a2009-11-18 20:48:08 -0500944DEFINE_EVENT(sched_process_template, sched_process_exit,
945 TP_PROTO(struct task_struct *p),
946 TP_ARGS(p));
Steven Rostedtea20d922009-04-10 08:54:16 -0400947
948/*
Li Zefan210f7662010-05-24 16:23:35 +0800949 * Tracepoint for waiting on task to unschedule:
950 */
951DEFINE_EVENT(sched_process_template, sched_wait_task,
952 TP_PROTO(struct task_struct *p),
953 TP_ARGS(p));
954
955/*
Steven Rostedtea20d922009-04-10 08:54:16 -0400956 * Tracepoint for a waiting task:
957 */
958TRACE_EVENT(sched_process_wait,
959
960 TP_PROTO(struct pid *pid),
961
962 TP_ARGS(pid),
963
964 TP_STRUCT__entry(
965 __array( char, comm, TASK_COMM_LEN )
966 __field( pid_t, pid )
967 __field( int, prio )
968 ),
969
970 TP_fast_assign(
971 memcpy(__entry->comm, current->comm, TASK_COMM_LEN);
972 __entry->pid = pid_nr(pid);
973 __entry->prio = current->prio;
974 ),
975
Ingo Molnar434a83c2009-10-15 11:50:39 +0200976 TP_printk("comm=%s pid=%d prio=%d",
Steven Rostedtea20d922009-04-10 08:54:16 -0400977 __entry->comm, __entry->pid, __entry->prio)
978);
979
980/*
981 * Tracepoint for do_fork:
982 */
983TRACE_EVENT(sched_process_fork,
984
985 TP_PROTO(struct task_struct *parent, struct task_struct *child),
986
987 TP_ARGS(parent, child),
988
989 TP_STRUCT__entry(
990 __array( char, parent_comm, TASK_COMM_LEN )
991 __field( pid_t, parent_pid )
992 __array( char, child_comm, TASK_COMM_LEN )
993 __field( pid_t, child_pid )
994 ),
995
996 TP_fast_assign(
997 memcpy(__entry->parent_comm, parent->comm, TASK_COMM_LEN);
998 __entry->parent_pid = parent->pid;
999 memcpy(__entry->child_comm, child->comm, TASK_COMM_LEN);
1000 __entry->child_pid = child->pid;
1001 ),
1002
Ingo Molnar434a83c2009-10-15 11:50:39 +02001003 TP_printk("comm=%s pid=%d child_comm=%s child_pid=%d",
Steven Rostedtea20d922009-04-10 08:54:16 -04001004 __entry->parent_comm, __entry->parent_pid,
1005 __entry->child_comm, __entry->child_pid)
1006);
1007
1008/*
David Smith4ff16c22012-02-07 10:11:05 -06001009 * Tracepoint for exec:
1010 */
1011TRACE_EVENT(sched_process_exec,
1012
1013 TP_PROTO(struct task_struct *p, pid_t old_pid,
1014 struct linux_binprm *bprm),
1015
1016 TP_ARGS(p, old_pid, bprm),
1017
1018 TP_STRUCT__entry(
1019 __string( filename, bprm->filename )
1020 __field( pid_t, pid )
1021 __field( pid_t, old_pid )
1022 ),
1023
1024 TP_fast_assign(
1025 __assign_str(filename, bprm->filename);
1026 __entry->pid = p->pid;
Oleg Nesterov63081912012-03-30 18:26:36 +02001027 __entry->old_pid = old_pid;
David Smith4ff16c22012-02-07 10:11:05 -06001028 ),
1029
1030 TP_printk("filename=%s pid=%d old_pid=%d", __get_str(filename),
1031 __entry->pid, __entry->old_pid)
1032);
1033
1034/*
Peter Zijlstra768d0c22009-07-23 20:13:26 +02001035 * XXX the below sched_stat tracepoints only apply to SCHED_OTHER/BATCH/IDLE
1036 * adding sched_stat support to SCHED_FIFO/RR would be welcome.
1037 */
Ingo Molnar091ad362009-11-26 09:04:55 +01001038DECLARE_EVENT_CLASS(sched_stat_template,
Peter Zijlstra768d0c22009-07-23 20:13:26 +02001039
1040 TP_PROTO(struct task_struct *tsk, u64 delay),
1041
Oleg Nesterov12473962013-08-06 18:08:44 +02001042 TP_ARGS(__perf_task(tsk), __perf_count(delay)),
Peter Zijlstra768d0c22009-07-23 20:13:26 +02001043
1044 TP_STRUCT__entry(
1045 __array( char, comm, TASK_COMM_LEN )
1046 __field( pid_t, pid )
1047 __field( u64, delay )
1048 ),
1049
1050 TP_fast_assign(
1051 memcpy(__entry->comm, tsk->comm, TASK_COMM_LEN);
1052 __entry->pid = tsk->pid;
1053 __entry->delay = delay;
Peter Zijlstra768d0c22009-07-23 20:13:26 +02001054 ),
1055
Ingo Molnar434a83c2009-10-15 11:50:39 +02001056 TP_printk("comm=%s pid=%d delay=%Lu [ns]",
Peter Zijlstra768d0c22009-07-23 20:13:26 +02001057 __entry->comm, __entry->pid,
1058 (unsigned long long)__entry->delay)
1059);
1060
Steven Rostedt75ec29a2009-11-18 20:48:08 -05001061
1062/*
1063 * Tracepoint for accounting wait time (time the task is runnable
1064 * but not actually running due to scheduler contention).
1065 */
1066DEFINE_EVENT(sched_stat_template, sched_stat_wait,
1067 TP_PROTO(struct task_struct *tsk, u64 delay),
1068 TP_ARGS(tsk, delay));
1069
1070/*
1071 * Tracepoint for accounting sleep time (time the task is not runnable,
1072 * including iowait, see below).
1073 */
Li Zefan470dda742009-11-26 15:08:01 +08001074DEFINE_EVENT(sched_stat_template, sched_stat_sleep,
1075 TP_PROTO(struct task_struct *tsk, u64 delay),
1076 TP_ARGS(tsk, delay));
Steven Rostedt75ec29a2009-11-18 20:48:08 -05001077
1078/*
1079 * Tracepoint for accounting iowait time (time the task is not runnable
1080 * due to waiting on IO to complete).
1081 */
Li Zefan470dda742009-11-26 15:08:01 +08001082DEFINE_EVENT(sched_stat_template, sched_stat_iowait,
1083 TP_PROTO(struct task_struct *tsk, u64 delay),
1084 TP_ARGS(tsk, delay));
Steven Rostedt75ec29a2009-11-18 20:48:08 -05001085
Peter Zijlstra768d0c22009-07-23 20:13:26 +02001086/*
Andrew Vaginb781a602011-11-28 12:03:35 +03001087 * Tracepoint for accounting blocked time (time the task is in uninterruptible).
1088 */
1089DEFINE_EVENT(sched_stat_template, sched_stat_blocked,
1090 TP_PROTO(struct task_struct *tsk, u64 delay),
1091 TP_ARGS(tsk, delay));
1092
1093/*
Riley Andrews9de15b42015-10-02 00:39:53 -07001094 * Tracepoint for recording the cause of uninterruptible sleep.
1095 */
1096TRACE_EVENT(sched_blocked_reason,
1097
1098 TP_PROTO(struct task_struct *tsk),
1099
1100 TP_ARGS(tsk),
1101
1102 TP_STRUCT__entry(
1103 __field( pid_t, pid )
1104 __field( void*, caller )
1105 __field( bool, io_wait )
1106 ),
1107
1108 TP_fast_assign(
1109 __entry->pid = tsk->pid;
1110 __entry->caller = (void*)get_wchan(tsk);
1111 __entry->io_wait = tsk->in_iowait;
1112 ),
1113
1114 TP_printk("pid=%d iowait=%d caller=%pS", __entry->pid, __entry->io_wait, __entry->caller)
1115);
1116
1117/*
Ingo Molnarf977bb42009-09-13 18:15:54 +02001118 * Tracepoint for accounting runtime (time the task is executing
1119 * on a CPU).
1120 */
Oleg Nesterov36009d072013-08-06 18:08:41 +02001121DECLARE_EVENT_CLASS(sched_stat_runtime,
Ingo Molnarf977bb42009-09-13 18:15:54 +02001122
1123 TP_PROTO(struct task_struct *tsk, u64 runtime, u64 vruntime),
1124
Oleg Nesterov12473962013-08-06 18:08:44 +02001125 TP_ARGS(tsk, __perf_count(runtime), vruntime),
Ingo Molnarf977bb42009-09-13 18:15:54 +02001126
1127 TP_STRUCT__entry(
1128 __array( char, comm, TASK_COMM_LEN )
1129 __field( pid_t, pid )
1130 __field( u64, runtime )
1131 __field( u64, vruntime )
1132 ),
1133
1134 TP_fast_assign(
1135 memcpy(__entry->comm, tsk->comm, TASK_COMM_LEN);
1136 __entry->pid = tsk->pid;
1137 __entry->runtime = runtime;
1138 __entry->vruntime = vruntime;
Ingo Molnarf977bb42009-09-13 18:15:54 +02001139 ),
1140
Ingo Molnar434a83c2009-10-15 11:50:39 +02001141 TP_printk("comm=%s pid=%d runtime=%Lu [ns] vruntime=%Lu [ns]",
Ingo Molnarf977bb42009-09-13 18:15:54 +02001142 __entry->comm, __entry->pid,
1143 (unsigned long long)__entry->runtime,
1144 (unsigned long long)__entry->vruntime)
1145);
1146
Oleg Nesterov36009d072013-08-06 18:08:41 +02001147DEFINE_EVENT(sched_stat_runtime, sched_stat_runtime,
1148 TP_PROTO(struct task_struct *tsk, u64 runtime, u64 vruntime),
1149 TP_ARGS(tsk, runtime, vruntime));
1150
Steven Rostedta8027072010-09-20 15:13:34 -04001151/*
1152 * Tracepoint for showing priority inheritance modifying a tasks
1153 * priority.
1154 */
1155TRACE_EVENT(sched_pi_setprio,
1156
1157 TP_PROTO(struct task_struct *tsk, int newprio),
1158
1159 TP_ARGS(tsk, newprio),
1160
1161 TP_STRUCT__entry(
1162 __array( char, comm, TASK_COMM_LEN )
1163 __field( pid_t, pid )
1164 __field( int, oldprio )
1165 __field( int, newprio )
1166 ),
1167
1168 TP_fast_assign(
1169 memcpy(__entry->comm, tsk->comm, TASK_COMM_LEN);
1170 __entry->pid = tsk->pid;
1171 __entry->oldprio = tsk->prio;
1172 __entry->newprio = newprio;
1173 ),
1174
1175 TP_printk("comm=%s pid=%d oldprio=%d newprio=%d",
1176 __entry->comm, __entry->pid,
1177 __entry->oldprio, __entry->newprio)
1178);
1179
Oleg Nesterov6a716c92013-10-19 18:18:28 +02001180#ifdef CONFIG_DETECT_HUNG_TASK
1181TRACE_EVENT(sched_process_hang,
1182 TP_PROTO(struct task_struct *tsk),
1183 TP_ARGS(tsk),
1184
1185 TP_STRUCT__entry(
1186 __array( char, comm, TASK_COMM_LEN )
1187 __field( pid_t, pid )
1188 ),
1189
1190 TP_fast_assign(
1191 memcpy(__entry->comm, tsk->comm, TASK_COMM_LEN);
1192 __entry->pid = tsk->pid;
1193 ),
1194
1195 TP_printk("comm=%s pid=%d", __entry->comm, __entry->pid)
1196);
1197#endif /* CONFIG_DETECT_HUNG_TASK */
1198
Mel Gorman286549d2014-01-21 15:51:03 -08001199DECLARE_EVENT_CLASS(sched_move_task_template,
1200
1201 TP_PROTO(struct task_struct *tsk, int src_cpu, int dst_cpu),
1202
1203 TP_ARGS(tsk, src_cpu, dst_cpu),
1204
1205 TP_STRUCT__entry(
1206 __field( pid_t, pid )
1207 __field( pid_t, tgid )
1208 __field( pid_t, ngid )
1209 __field( int, src_cpu )
1210 __field( int, src_nid )
1211 __field( int, dst_cpu )
1212 __field( int, dst_nid )
1213 ),
1214
1215 TP_fast_assign(
1216 __entry->pid = task_pid_nr(tsk);
1217 __entry->tgid = task_tgid_nr(tsk);
1218 __entry->ngid = task_numa_group_id(tsk);
1219 __entry->src_cpu = src_cpu;
1220 __entry->src_nid = cpu_to_node(src_cpu);
1221 __entry->dst_cpu = dst_cpu;
1222 __entry->dst_nid = cpu_to_node(dst_cpu);
1223 ),
1224
1225 TP_printk("pid=%d tgid=%d ngid=%d src_cpu=%d src_nid=%d dst_cpu=%d dst_nid=%d",
1226 __entry->pid, __entry->tgid, __entry->ngid,
1227 __entry->src_cpu, __entry->src_nid,
1228 __entry->dst_cpu, __entry->dst_nid)
1229);
1230
1231/*
1232 * Tracks migration of tasks from one runqueue to another. Can be used to
1233 * detect if automatic NUMA balancing is bouncing between nodes
1234 */
1235DEFINE_EVENT(sched_move_task_template, sched_move_numa,
1236 TP_PROTO(struct task_struct *tsk, int src_cpu, int dst_cpu),
1237
1238 TP_ARGS(tsk, src_cpu, dst_cpu)
1239);
1240
1241DEFINE_EVENT(sched_move_task_template, sched_stick_numa,
1242 TP_PROTO(struct task_struct *tsk, int src_cpu, int dst_cpu),
1243
1244 TP_ARGS(tsk, src_cpu, dst_cpu)
1245);
1246
1247TRACE_EVENT(sched_swap_numa,
1248
1249 TP_PROTO(struct task_struct *src_tsk, int src_cpu,
1250 struct task_struct *dst_tsk, int dst_cpu),
1251
1252 TP_ARGS(src_tsk, src_cpu, dst_tsk, dst_cpu),
1253
1254 TP_STRUCT__entry(
1255 __field( pid_t, src_pid )
1256 __field( pid_t, src_tgid )
1257 __field( pid_t, src_ngid )
1258 __field( int, src_cpu )
1259 __field( int, src_nid )
1260 __field( pid_t, dst_pid )
1261 __field( pid_t, dst_tgid )
1262 __field( pid_t, dst_ngid )
1263 __field( int, dst_cpu )
1264 __field( int, dst_nid )
1265 ),
1266
1267 TP_fast_assign(
1268 __entry->src_pid = task_pid_nr(src_tsk);
1269 __entry->src_tgid = task_tgid_nr(src_tsk);
1270 __entry->src_ngid = task_numa_group_id(src_tsk);
1271 __entry->src_cpu = src_cpu;
1272 __entry->src_nid = cpu_to_node(src_cpu);
1273 __entry->dst_pid = task_pid_nr(dst_tsk);
1274 __entry->dst_tgid = task_tgid_nr(dst_tsk);
1275 __entry->dst_ngid = task_numa_group_id(dst_tsk);
1276 __entry->dst_cpu = dst_cpu;
1277 __entry->dst_nid = cpu_to_node(dst_cpu);
1278 ),
1279
1280 TP_printk("src_pid=%d src_tgid=%d src_ngid=%d src_cpu=%d src_nid=%d dst_pid=%d dst_tgid=%d dst_ngid=%d dst_cpu=%d dst_nid=%d",
1281 __entry->src_pid, __entry->src_tgid, __entry->src_ngid,
1282 __entry->src_cpu, __entry->src_nid,
1283 __entry->dst_pid, __entry->dst_tgid, __entry->dst_ngid,
1284 __entry->dst_cpu, __entry->dst_nid)
1285);
Andy Lutomirskidfc68f22014-06-04 10:31:15 -07001286
1287/*
1288 * Tracepoint for waking a polling cpu without an IPI.
1289 */
1290TRACE_EVENT(sched_wake_idle_without_ipi,
1291
1292 TP_PROTO(int cpu),
1293
1294 TP_ARGS(cpu),
1295
1296 TP_STRUCT__entry(
1297 __field( int, cpu )
1298 ),
1299
1300 TP_fast_assign(
1301 __entry->cpu = cpu;
1302 ),
1303
1304 TP_printk("cpu=%d", __entry->cpu)
1305);
Syed Rameez Mustafadddcab72016-09-07 16:18:27 -07001306
Juri Lelli0a942002015-11-09 12:06:24 +00001307TRACE_EVENT(sched_contrib_scale_f,
Juri Lelli0a942002015-11-09 12:06:24 +00001308 TP_PROTO(int cpu, unsigned long freq_scale_factor,
1309 unsigned long cpu_scale_factor),
Juri Lelli0a942002015-11-09 12:06:24 +00001310 TP_ARGS(cpu, freq_scale_factor, cpu_scale_factor),
Juri Lelli0a942002015-11-09 12:06:24 +00001311 TP_STRUCT__entry(
1312 __field(int, cpu)
1313 __field(unsigned long, freq_scale_factor)
1314 __field(unsigned long, cpu_scale_factor)
1315 ),
Juri Lelli0a942002015-11-09 12:06:24 +00001316 TP_fast_assign(
1317 __entry->cpu = cpu;
1318 __entry->freq_scale_factor = freq_scale_factor;
1319 __entry->cpu_scale_factor = cpu_scale_factor;
1320 ),
Juri Lelli0a942002015-11-09 12:06:24 +00001321 TP_printk("cpu=%d freq_scale_factor=%lu cpu_scale_factor=%lu",
1322 __entry->cpu, __entry->freq_scale_factor,
1323 __entry->cpu_scale_factor)
1324);
Juri Lellia4b0c3a2015-11-09 12:07:27 +00001325
Jeevan Shriram49f575e2017-03-02 16:52:44 -08001326#ifdef CONFIG_SMP
Juri Lellia4b0c3a2015-11-09 12:07:27 +00001327/*
1328 * Tracepoint for accounting sched averages for tasks.
1329 */
1330TRACE_EVENT(sched_load_avg_task,
Juri Lellia4b0c3a2015-11-09 12:07:27 +00001331 TP_PROTO(struct task_struct *tsk, struct sched_avg *avg),
Juri Lellia4b0c3a2015-11-09 12:07:27 +00001332 TP_ARGS(tsk, avg),
Juri Lellia4b0c3a2015-11-09 12:07:27 +00001333 TP_STRUCT__entry(
1334 __array( char, comm, TASK_COMM_LEN )
1335 __field( pid_t, pid )
1336 __field( int, cpu )
1337 __field( unsigned long, load_avg )
1338 __field( unsigned long, util_avg )
1339 __field( u64, load_sum )
1340 __field( u32, util_sum )
1341 __field( u32, period_contrib )
1342 ),
Juri Lellia4b0c3a2015-11-09 12:07:27 +00001343 TP_fast_assign(
1344 memcpy(__entry->comm, tsk->comm, TASK_COMM_LEN);
1345 __entry->pid = tsk->pid;
1346 __entry->cpu = task_cpu(tsk);
1347 __entry->load_avg = avg->load_avg;
1348 __entry->util_avg = avg->util_avg;
1349 __entry->load_sum = avg->load_sum;
1350 __entry->util_sum = avg->util_sum;
1351 __entry->period_contrib = avg->period_contrib;
1352 ),
Juri Lellia4b0c3a2015-11-09 12:07:27 +00001353 TP_printk("comm=%s pid=%d cpu=%d load_avg=%lu util_avg=%lu load_sum=%llu"
1354 " util_sum=%u period_contrib=%u",
1355 __entry->comm,
1356 __entry->pid,
1357 __entry->cpu,
1358 __entry->load_avg,
1359 __entry->util_avg,
1360 (u64)__entry->load_sum,
1361 (u32)__entry->util_sum,
1362 (u32)__entry->period_contrib)
1363);
Juri Lelli79478802015-11-09 12:07:48 +00001364/*
1365 * Tracepoint for accounting sched averages for cpus.
1366 */
1367TRACE_EVENT(sched_load_avg_cpu,
Juri Lelli79478802015-11-09 12:07:48 +00001368 TP_PROTO(int cpu, struct cfs_rq *cfs_rq),
Juri Lelli79478802015-11-09 12:07:48 +00001369 TP_ARGS(cpu, cfs_rq),
Juri Lelli79478802015-11-09 12:07:48 +00001370 TP_STRUCT__entry(
1371 __field( int, cpu )
1372 __field( unsigned long, load_avg )
1373 __field( unsigned long, util_avg )
1374 ),
Juri Lelli79478802015-11-09 12:07:48 +00001375 TP_fast_assign(
1376 __entry->cpu = cpu;
1377 __entry->load_avg = cfs_rq->avg.load_avg;
1378 __entry->util_avg = cfs_rq->avg.util_avg;
1379 ),
Juri Lelli79478802015-11-09 12:07:48 +00001380 TP_printk("cpu=%d load_avg=%lu util_avg=%lu",
1381 __entry->cpu, __entry->load_avg, __entry->util_avg)
1382);
Patrick Bellasi050dcb82015-06-22 13:49:07 +01001383/*
1384 * Tracepoint for sched_tune_config settings
1385 */
1386TRACE_EVENT(sched_tune_config,
Patrick Bellasi050dcb82015-06-22 13:49:07 +01001387 TP_PROTO(int boost),
Patrick Bellasi050dcb82015-06-22 13:49:07 +01001388 TP_ARGS(boost),
Patrick Bellasi050dcb82015-06-22 13:49:07 +01001389 TP_STRUCT__entry(
1390 __field( int, boost )
1391 ),
Patrick Bellasi050dcb82015-06-22 13:49:07 +01001392 TP_fast_assign(
1393 __entry->boost = boost;
1394 ),
Patrick Bellasi050dcb82015-06-22 13:49:07 +01001395 TP_printk("boost=%d ", __entry->boost)
1396);
Patrick Bellasicccead12015-06-22 13:51:07 +01001397/*
1398 * Tracepoint for accounting CPU boosted utilization
1399 */
1400TRACE_EVENT(sched_boost_cpu,
Srinath Sridharane71c4252016-07-28 17:28:55 +01001401 TP_PROTO(int cpu, unsigned long util, long margin),
Patrick Bellasicccead12015-06-22 13:51:07 +01001402 TP_ARGS(cpu, util, margin),
Patrick Bellasicccead12015-06-22 13:51:07 +01001403 TP_STRUCT__entry(
1404 __field( int, cpu )
1405 __field( unsigned long, util )
Srinath Sridharane71c4252016-07-28 17:28:55 +01001406 __field(long, margin )
Patrick Bellasicccead12015-06-22 13:51:07 +01001407 ),
Patrick Bellasicccead12015-06-22 13:51:07 +01001408 TP_fast_assign(
1409 __entry->cpu = cpu;
1410 __entry->util = util;
1411 __entry->margin = margin;
1412 ),
Srinath Sridharane71c4252016-07-28 17:28:55 +01001413 TP_printk("cpu=%d util=%lu margin=%ld",
Patrick Bellasicccead12015-06-22 13:51:07 +01001414 __entry->cpu,
1415 __entry->util,
1416 __entry->margin)
1417);
Patrick Bellasi953b1042015-06-24 15:36:08 +01001418/*
1419 * Tracepoint for schedtune_tasks_update
1420 */
1421TRACE_EVENT(sched_tune_tasks_update,
Patrick Bellasi953b1042015-06-24 15:36:08 +01001422 TP_PROTO(struct task_struct *tsk, int cpu, int tasks, int idx,
Srinath Sridharane71c4252016-07-28 17:28:55 +01001423 int boost, int max_boost),
Patrick Bellasi953b1042015-06-24 15:36:08 +01001424 TP_ARGS(tsk, cpu, tasks, idx, boost, max_boost),
Patrick Bellasi953b1042015-06-24 15:36:08 +01001425 TP_STRUCT__entry(
1426 __array( char, comm, TASK_COMM_LEN )
1427 __field( pid_t, pid )
1428 __field( int, cpu )
1429 __field( int, tasks )
1430 __field( int, idx )
Srinath Sridharane71c4252016-07-28 17:28:55 +01001431 __field( int, boost )
1432 __field( int, max_boost )
Patrick Bellasi953b1042015-06-24 15:36:08 +01001433 ),
Patrick Bellasi953b1042015-06-24 15:36:08 +01001434 TP_fast_assign(
1435 memcpy(__entry->comm, tsk->comm, TASK_COMM_LEN);
1436 __entry->pid = tsk->pid;
1437 __entry->cpu = cpu;
1438 __entry->tasks = tasks;
1439 __entry->idx = idx;
1440 __entry->boost = boost;
1441 __entry->max_boost = max_boost;
1442 ),
Patrick Bellasi953b1042015-06-24 15:36:08 +01001443 TP_printk("pid=%d comm=%s "
Srinath Sridharane71c4252016-07-28 17:28:55 +01001444 "cpu=%d tasks=%d idx=%d boost=%d max_boost=%d",
Patrick Bellasi953b1042015-06-24 15:36:08 +01001445 __entry->pid, __entry->comm,
1446 __entry->cpu, __entry->tasks, __entry->idx,
1447 __entry->boost, __entry->max_boost)
1448);
Patrick Bellasi953b1042015-06-24 15:36:08 +01001449/*
1450 * Tracepoint for schedtune_boostgroup_update
1451 */
1452TRACE_EVENT(sched_tune_boostgroup_update,
Patrick Bellasi953b1042015-06-24 15:36:08 +01001453 TP_PROTO(int cpu, int variation, int max_boost),
Patrick Bellasi953b1042015-06-24 15:36:08 +01001454 TP_ARGS(cpu, variation, max_boost),
Patrick Bellasi953b1042015-06-24 15:36:08 +01001455 TP_STRUCT__entry(
1456 __field( int, cpu )
1457 __field( int, variation )
1458 __field( int, max_boost )
1459 ),
Patrick Bellasi953b1042015-06-24 15:36:08 +01001460 TP_fast_assign(
1461 __entry->cpu = cpu;
1462 __entry->variation = variation;
1463 __entry->max_boost = max_boost;
1464 ),
Patrick Bellasi953b1042015-06-24 15:36:08 +01001465 TP_printk("cpu=%d variation=%d max_boost=%d",
1466 __entry->cpu, __entry->variation, __entry->max_boost)
1467);
Patrick Bellasiecccdb72016-01-14 18:43:37 +00001468/*
1469 * Tracepoint for accounting task boosted utilization
1470 */
1471TRACE_EVENT(sched_boost_task,
Srinath Sridharane71c4252016-07-28 17:28:55 +01001472 TP_PROTO(struct task_struct *tsk, unsigned long util, long margin),
Patrick Bellasiecccdb72016-01-14 18:43:37 +00001473 TP_ARGS(tsk, util, margin),
Patrick Bellasiecccdb72016-01-14 18:43:37 +00001474 TP_STRUCT__entry(
1475 __array( char, comm, TASK_COMM_LEN )
1476 __field( pid_t, pid )
1477 __field( unsigned long, util )
Srinath Sridharane71c4252016-07-28 17:28:55 +01001478 __field( long, margin )
Patrick Bellasiecccdb72016-01-14 18:43:37 +00001479 ),
Patrick Bellasiecccdb72016-01-14 18:43:37 +00001480 TP_fast_assign(
1481 memcpy(__entry->comm, tsk->comm, TASK_COMM_LEN);
1482 __entry->pid = tsk->pid;
1483 __entry->util = util;
1484 __entry->margin = margin;
1485 ),
Srinath Sridharane71c4252016-07-28 17:28:55 +01001486 TP_printk("comm=%s pid=%d util=%lu margin=%ld",
Patrick Bellasiecccdb72016-01-14 18:43:37 +00001487 __entry->comm, __entry->pid,
1488 __entry->util,
1489 __entry->margin)
1490);
Patrick Bellasi110441b2016-01-14 18:47:21 +00001491/*
1492 * Tracepoint for accounting sched group energy
1493 */
1494TRACE_EVENT(sched_energy_diff,
Patrick Bellasi110441b2016-01-14 18:47:21 +00001495 TP_PROTO(struct task_struct *tsk, int scpu, int dcpu, int udelta,
1496 int nrgb, int nrga, int nrgd, int capb, int capa, int capd,
1497 int nrgn, int nrgp),
Patrick Bellasi110441b2016-01-14 18:47:21 +00001498 TP_ARGS(tsk, scpu, dcpu, udelta,
1499 nrgb, nrga, nrgd, capb, capa, capd,
1500 nrgn, nrgp),
Patrick Bellasi110441b2016-01-14 18:47:21 +00001501 TP_STRUCT__entry(
1502 __array( char, comm, TASK_COMM_LEN )
1503 __field( pid_t, pid )
1504 __field( int, scpu )
1505 __field( int, dcpu )
1506 __field( int, udelta )
1507 __field( int, nrgb )
1508 __field( int, nrga )
1509 __field( int, nrgd )
1510 __field( int, capb )
1511 __field( int, capa )
1512 __field( int, capd )
1513 __field( int, nrgn )
1514 __field( int, nrgp )
1515 ),
Patrick Bellasi110441b2016-01-14 18:47:21 +00001516 TP_fast_assign(
1517 memcpy(__entry->comm, tsk->comm, TASK_COMM_LEN);
1518 __entry->pid = tsk->pid;
1519 __entry->scpu = scpu;
1520 __entry->dcpu = dcpu;
1521 __entry->udelta = udelta;
1522 __entry->nrgb = nrgb;
1523 __entry->nrga = nrga;
1524 __entry->nrgd = nrgd;
1525 __entry->capb = capb;
1526 __entry->capa = capa;
1527 __entry->capd = capd;
1528 __entry->nrgn = nrgn;
1529 __entry->nrgp = nrgp;
1530 ),
Patrick Bellasi110441b2016-01-14 18:47:21 +00001531 TP_printk("pid=%d comm=%s "
1532 "src_cpu=%d dst_cpu=%d usage_delta=%d "
1533 "nrg_before=%d nrg_after=%d nrg_diff=%d "
1534 "cap_before=%d cap_after=%d cap_delta=%d "
1535 "nrg_delta=%d nrg_payoff=%d",
1536 __entry->pid, __entry->comm,
1537 __entry->scpu, __entry->dcpu, __entry->udelta,
1538 __entry->nrgb, __entry->nrga, __entry->nrgd,
1539 __entry->capb, __entry->capa, __entry->capd,
1540 __entry->nrgn, __entry->nrgp)
1541);
Patrick Bellasi5824d982016-01-20 14:06:05 +00001542/*
1543 * Tracepoint for schedtune_tasks_update
1544 */
1545TRACE_EVENT(sched_tune_filter,
Patrick Bellasi5824d982016-01-20 14:06:05 +00001546 TP_PROTO(int nrg_delta, int cap_delta,
1547 int nrg_gain, int cap_gain,
1548 int payoff, int region),
Patrick Bellasi5824d982016-01-20 14:06:05 +00001549 TP_ARGS(nrg_delta, cap_delta, nrg_gain, cap_gain, payoff, region),
Patrick Bellasi5824d982016-01-20 14:06:05 +00001550 TP_STRUCT__entry(
1551 __field( int, nrg_delta )
1552 __field( int, cap_delta )
1553 __field( int, nrg_gain )
1554 __field( int, cap_gain )
1555 __field( int, payoff )
1556 __field( int, region )
1557 ),
Patrick Bellasi5824d982016-01-20 14:06:05 +00001558 TP_fast_assign(
1559 __entry->nrg_delta = nrg_delta;
1560 __entry->cap_delta = cap_delta;
1561 __entry->nrg_gain = nrg_gain;
1562 __entry->cap_gain = cap_gain;
1563 __entry->payoff = payoff;
1564 __entry->region = region;
1565 ),
Patrick Bellasi5824d982016-01-20 14:06:05 +00001566 TP_printk("nrg_delta=%d cap_delta=%d nrg_gain=%d cap_gain=%d payoff=%d region=%d",
1567 __entry->nrg_delta, __entry->cap_delta,
1568 __entry->nrg_gain, __entry->cap_gain,
1569 __entry->payoff, __entry->region)
1570);
Patrick Bellasi8e45d942016-02-10 09:24:36 +00001571/*
1572 * Tracepoint for system overutilized flag
1573 */
1574TRACE_EVENT(sched_overutilized,
Patrick Bellasi8e45d942016-02-10 09:24:36 +00001575 TP_PROTO(bool overutilized),
Patrick Bellasi8e45d942016-02-10 09:24:36 +00001576 TP_ARGS(overutilized),
Patrick Bellasi8e45d942016-02-10 09:24:36 +00001577 TP_STRUCT__entry(
1578 __field( bool, overutilized )
1579 ),
Patrick Bellasi8e45d942016-02-10 09:24:36 +00001580 TP_fast_assign(
1581 __entry->overutilized = overutilized;
1582 ),
Patrick Bellasi8e45d942016-02-10 09:24:36 +00001583 TP_printk("overutilized=%d",
1584 __entry->overutilized ? 1 : 0)
1585);
Jeevan Shriram49f575e2017-03-02 16:52:44 -08001586#endif
Srivatsa Vaddagiri26c21542016-05-31 09:08:38 -07001587
Syed Rameez Mustafadddcab72016-09-07 16:18:27 -07001588TRACE_EVENT(sched_get_nr_running_avg,
1589
1590 TP_PROTO(int avg, int big_avg, int iowait_avg),
1591
1592 TP_ARGS(avg, big_avg, iowait_avg),
1593
1594 TP_STRUCT__entry(
1595 __field( int, avg )
1596 __field( int, big_avg )
1597 __field( int, iowait_avg )
1598 ),
1599
1600 TP_fast_assign(
1601 __entry->avg = avg;
1602 __entry->big_avg = big_avg;
1603 __entry->iowait_avg = iowait_avg;
1604 ),
1605
1606 TP_printk("avg=%d big_avg=%d iowait_avg=%d",
1607 __entry->avg, __entry->big_avg, __entry->iowait_avg)
1608);
Olav Haugan39432ea2016-06-12 13:57:05 -07001609
Olav Haugan09bcc682016-09-02 17:12:20 -07001610TRACE_EVENT(core_ctl_eval_need,
1611
1612 TP_PROTO(unsigned int cpu, unsigned int old_need,
1613 unsigned int new_need, unsigned int updated),
1614 TP_ARGS(cpu, old_need, new_need, updated),
1615 TP_STRUCT__entry(
1616 __field(u32, cpu)
1617 __field(u32, old_need)
1618 __field(u32, new_need)
1619 __field(u32, updated)
1620 ),
1621 TP_fast_assign(
1622 __entry->cpu = cpu;
1623 __entry->old_need = old_need;
1624 __entry->new_need = new_need;
1625 __entry->updated = updated;
1626 ),
1627 TP_printk("cpu=%u, old_need=%u, new_need=%u, updated=%u", __entry->cpu,
1628 __entry->old_need, __entry->new_need, __entry->updated)
1629);
1630
1631TRACE_EVENT(core_ctl_set_busy,
1632
1633 TP_PROTO(unsigned int cpu, unsigned int busy,
1634 unsigned int old_is_busy, unsigned int is_busy),
1635 TP_ARGS(cpu, busy, old_is_busy, is_busy),
1636 TP_STRUCT__entry(
1637 __field(u32, cpu)
1638 __field(u32, busy)
1639 __field(u32, old_is_busy)
1640 __field(u32, is_busy)
1641 ),
1642 TP_fast_assign(
1643 __entry->cpu = cpu;
1644 __entry->busy = busy;
1645 __entry->old_is_busy = old_is_busy;
1646 __entry->is_busy = is_busy;
1647 ),
1648 TP_printk("cpu=%u, busy=%u, old_is_busy=%u, new_is_busy=%u",
1649 __entry->cpu, __entry->busy, __entry->old_is_busy,
1650 __entry->is_busy)
1651);
1652
Olav Haugana024f472016-10-13 10:34:11 -07001653TRACE_EVENT(core_ctl_set_boost,
1654
1655 TP_PROTO(u32 refcount, s32 ret),
1656 TP_ARGS(refcount, ret),
1657 TP_STRUCT__entry(
1658 __field(u32, refcount)
1659 __field(s32, ret)
1660 ),
1661 TP_fast_assign(
1662 __entry->refcount = refcount;
1663 __entry->ret = ret;
1664 ),
1665 TP_printk("refcount=%u, ret=%d", __entry->refcount, __entry->ret)
1666);
1667
Olav Haugan39432ea2016-06-12 13:57:05 -07001668/*
1669 * sched_isolate - called when cores are isolated/unisolated
1670 *
1671 * @acutal_mask: mask of cores actually isolated/unisolated
1672 * @req_mask: mask of cores requested isolated/unisolated
1673 * @online_mask: cpu online mask
1674 * @time: amount of time in us it took to isolate/unisolate
1675 * @isolate: 1 if isolating, 0 if unisolating
1676 *
1677 */
1678TRACE_EVENT(sched_isolate,
1679
1680 TP_PROTO(unsigned int requested_cpu, unsigned int isolated_cpus,
1681 u64 start_time, unsigned char isolate),
1682
1683 TP_ARGS(requested_cpu, isolated_cpus, start_time, isolate),
1684
1685 TP_STRUCT__entry(
1686 __field(u32, requested_cpu)
1687 __field(u32, isolated_cpus)
1688 __field(u32, time)
1689 __field(unsigned char, isolate)
1690 ),
1691
1692 TP_fast_assign(
1693 __entry->requested_cpu = requested_cpu;
1694 __entry->isolated_cpus = isolated_cpus;
1695 __entry->time = div64_u64(sched_clock() - start_time, 1000);
1696 __entry->isolate = isolate;
1697 ),
1698
1699 TP_printk("iso cpu=%u cpus=0x%x time=%u us isolated=%d",
1700 __entry->requested_cpu, __entry->isolated_cpus,
1701 __entry->time, __entry->isolate)
1702);
Steven Rostedtea20d922009-04-10 08:54:16 -04001703#endif /* _TRACE_SCHED_H */
Steven Rostedta8d154b2009-04-10 09:36:00 -04001704
1705/* This part must be outside protection */
1706#include <trace/define_trace.h>