blob: da3cb045c8f5e976e333347f040f7362f827b72b [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
Joonwoo Parkf7d6cd42017-01-17 15:19:43 -0800111#ifdef CONFIG_SCHED_WALT
Syed Rameez Mustafadddcab72016-09-07 16:18:27 -0700112struct group_cpu_time;
Syed Rameez Mustafadddcab72016-09-07 16:18:27 -0700113extern const char *task_event_names[];
Syed Rameez Mustafadddcab72016-09-07 16:18:27 -0700114
Joonwoo Parkf7d6cd42017-01-17 15:19:43 -0800115#if defined(CREATE_TRACE_POINTS) && defined(CONFIG_SCHED_WALT)
Syed Rameez Mustafa60cef212016-05-09 16:28:07 -0700116static inline void __window_data(u32 *dst, u32 *src)
117{
118 if (src)
119 memcpy(dst, src, nr_cpu_ids * sizeof(u32));
120 else
121 memset(dst, 0, nr_cpu_ids * sizeof(u32));
122}
123
124struct trace_seq;
125const char *__window_print(struct trace_seq *p, const u32 *buf, int buf_len)
126{
127 int i;
128 const char *ret = p->buffer + seq_buf_used(&p->seq);
129
130 for (i = 0; i < buf_len; i++)
131 trace_seq_printf(p, "%u ", buf[i]);
132
133 trace_seq_putc(p, 0);
134
135 return ret;
136}
Pavankumar Kondeti6deb2c42017-01-09 13:56:33 +0530137
138static inline s64 __rq_update_sum(struct rq *rq, bool curr, bool new)
139{
140 if (curr)
141 if (new)
142 return rq->nt_curr_runnable_sum;
143 else
144 return rq->curr_runnable_sum;
145 else
146 if (new)
147 return rq->nt_prev_runnable_sum;
148 else
149 return rq->prev_runnable_sum;
150}
151
152static inline s64 __grp_update_sum(struct rq *rq, bool curr, bool new)
153{
154 if (curr)
155 if (new)
156 return rq->grp_time.nt_curr_runnable_sum;
157 else
158 return rq->grp_time.curr_runnable_sum;
159 else
160 if (new)
161 return rq->grp_time.nt_prev_runnable_sum;
162 else
163 return rq->grp_time.prev_runnable_sum;
164}
165
166static inline s64
167__get_update_sum(struct rq *rq, enum migrate_types migrate_type,
168 bool src, bool new, bool curr)
169{
170 switch (migrate_type) {
171 case RQ_TO_GROUP:
172 if (src)
173 return __rq_update_sum(rq, curr, new);
174 else
175 return __grp_update_sum(rq, curr, new);
176 case GROUP_TO_RQ:
177 if (src)
178 return __grp_update_sum(rq, curr, new);
179 else
180 return __rq_update_sum(rq, curr, new);
181 default:
182 WARN_ON_ONCE(1);
183 return -1;
184 }
185}
Syed Rameez Mustafa60cef212016-05-09 16:28:07 -0700186#endif
187
Joonwoo Parkf7d6cd42017-01-17 15:19:43 -0800188TRACE_EVENT(sched_update_pred_demand,
189
190 TP_PROTO(struct rq *rq, struct task_struct *p, u32 runtime, int pct,
191 unsigned int pred_demand),
192
193 TP_ARGS(rq, p, runtime, pct, pred_demand),
194
195 TP_STRUCT__entry(
196 __array( char, comm, TASK_COMM_LEN )
197 __field( pid_t, pid )
198 __field(unsigned int, runtime )
199 __field( int, pct )
200 __field(unsigned int, pred_demand )
201 __array( u8, bucket, NUM_BUSY_BUCKETS)
202 __field( int, cpu )
203 ),
204
205 TP_fast_assign(
206 memcpy(__entry->comm, p->comm, TASK_COMM_LEN);
207 __entry->pid = p->pid;
208 __entry->runtime = runtime;
209 __entry->pct = pct;
210 __entry->pred_demand = pred_demand;
211 memcpy(__entry->bucket, p->ravg.busy_buckets,
212 NUM_BUSY_BUCKETS * sizeof(u8));
213 __entry->cpu = rq->cpu;
214 ),
215
216 TP_printk("%d (%s): runtime %u pct %d cpu %d pred_demand %u (buckets: %u %u %u %u %u %u %u %u %u %u)",
217 __entry->pid, __entry->comm,
218 __entry->runtime, __entry->pct, __entry->cpu,
219 __entry->pred_demand, __entry->bucket[0], __entry->bucket[1],
220 __entry->bucket[2], __entry->bucket[3],__entry->bucket[4],
221 __entry->bucket[5], __entry->bucket[6], __entry->bucket[7],
222 __entry->bucket[8], __entry->bucket[9])
223);
224
225TRACE_EVENT(sched_update_history,
226
227 TP_PROTO(struct rq *rq, struct task_struct *p, u32 runtime, int samples,
228 enum task_event evt),
229
230 TP_ARGS(rq, p, runtime, samples, evt),
231
232 TP_STRUCT__entry(
233 __array( char, comm, TASK_COMM_LEN )
234 __field( pid_t, pid )
235 __field(unsigned int, runtime )
236 __field( int, samples )
237 __field(enum task_event, evt )
238 __field(unsigned int, demand )
239 __field(unsigned int, pred_demand )
240 __array( u32, hist, RAVG_HIST_SIZE_MAX)
241 __field(unsigned int, nr_big_tasks )
242 __field( int, cpu )
243 ),
244
245 TP_fast_assign(
246 memcpy(__entry->comm, p->comm, TASK_COMM_LEN);
247 __entry->pid = p->pid;
248 __entry->runtime = runtime;
249 __entry->samples = samples;
250 __entry->evt = evt;
251 __entry->demand = p->ravg.demand;
252 __entry->pred_demand = p->ravg.pred_demand;
253 memcpy(__entry->hist, p->ravg.sum_history,
254 RAVG_HIST_SIZE_MAX * sizeof(u32));
255 __entry->nr_big_tasks = rq->hmp_stats.nr_big_tasks;
256 __entry->cpu = rq->cpu;
257 ),
258
259 TP_printk("%d (%s): runtime %u samples %d event %s demand %u pred_demand %u"
260 " (hist: %u %u %u %u %u) cpu %d nr_big %u",
261 __entry->pid, __entry->comm,
262 __entry->runtime, __entry->samples,
263 task_event_names[__entry->evt],
264 __entry->demand, __entry->pred_demand,
265 __entry->hist[0], __entry->hist[1],
266 __entry->hist[2], __entry->hist[3],
267 __entry->hist[4], __entry->cpu, __entry->nr_big_tasks)
268);
269
270TRACE_EVENT(sched_get_task_cpu_cycles,
271
272 TP_PROTO(int cpu, int event, u64 cycles, u64 exec_time),
273
274 TP_ARGS(cpu, event, cycles, exec_time),
275
276 TP_STRUCT__entry(
277 __field(int, cpu )
278 __field(int, event )
279 __field(u64, cycles )
280 __field(u64, exec_time )
281 __field(u32, freq )
282 __field(u32, legacy_freq )
283 ),
284
285 TP_fast_assign(
286 __entry->cpu = cpu;
287 __entry->event = event;
288 __entry->cycles = cycles;
289 __entry->exec_time = exec_time;
290 __entry->freq = cpu_cycles_to_freq(cycles, exec_time);
291 __entry->legacy_freq = cpu_cur_freq(cpu);
292 ),
293
294 TP_printk("cpu=%d event=%d cycles=%llu exec_time=%llu freq=%u legacy_freq=%u",
295 __entry->cpu, __entry->event, __entry->cycles,
296 __entry->exec_time, __entry->freq, __entry->legacy_freq)
297);
298
Syed Rameez Mustafadddcab72016-09-07 16:18:27 -0700299TRACE_EVENT(sched_update_task_ravg,
300
301 TP_PROTO(struct task_struct *p, struct rq *rq, enum task_event evt,
302 u64 wallclock, u64 irqtime, u64 cycles, u64 exec_time,
303 struct group_cpu_time *cpu_time),
304
305 TP_ARGS(p, rq, evt, wallclock, irqtime, cycles, exec_time, cpu_time),
306
307 TP_STRUCT__entry(
308 __array( char, comm, TASK_COMM_LEN )
309 __field( pid_t, pid )
310 __field( pid_t, cur_pid )
311 __field(unsigned int, cur_freq )
312 __field( u64, wallclock )
313 __field( u64, mark_start )
314 __field( u64, delta_m )
315 __field( u64, win_start )
316 __field( u64, delta )
317 __field( u64, irqtime )
318 __field(enum task_event, evt )
319 __field(unsigned int, demand )
320 __field(unsigned int, sum )
321 __field( int, cpu )
322 __field(unsigned int, pred_demand )
323 __field( u64, rq_cs )
324 __field( u64, rq_ps )
325 __field( u64, grp_cs )
326 __field( u64, grp_ps )
Syed Rameez Mustafa60cef212016-05-09 16:28:07 -0700327 __field( u64, grp_nt_cs )
328 __field( u64, grp_nt_ps )
Syed Rameez Mustafadddcab72016-09-07 16:18:27 -0700329 __field( u32, curr_window )
330 __field( u32, prev_window )
Syed Rameez Mustafa60cef212016-05-09 16:28:07 -0700331 __dynamic_array(u32, curr_sum, nr_cpu_ids )
332 __dynamic_array(u32, prev_sum, nr_cpu_ids )
Syed Rameez Mustafadddcab72016-09-07 16:18:27 -0700333 __field( u64, nt_cs )
334 __field( u64, nt_ps )
335 __field( u32, active_windows )
Syed Rameez Mustafa59b5fb72016-05-31 16:40:45 -0700336 __field( u8, curr_top )
337 __field( u8, prev_top )
Syed Rameez Mustafadddcab72016-09-07 16:18:27 -0700338 ),
339
340 TP_fast_assign(
341 __entry->wallclock = wallclock;
342 __entry->win_start = rq->window_start;
343 __entry->delta = (wallclock - rq->window_start);
344 __entry->evt = evt;
345 __entry->cpu = rq->cpu;
346 __entry->cur_pid = rq->curr->pid;
347 __entry->cur_freq = cpu_cycles_to_freq(cycles, exec_time);
348 memcpy(__entry->comm, p->comm, TASK_COMM_LEN);
349 __entry->pid = p->pid;
350 __entry->mark_start = p->ravg.mark_start;
351 __entry->delta_m = (wallclock - p->ravg.mark_start);
352 __entry->demand = p->ravg.demand;
353 __entry->sum = p->ravg.sum;
354 __entry->irqtime = irqtime;
355 __entry->pred_demand = p->ravg.pred_demand;
356 __entry->rq_cs = rq->curr_runnable_sum;
357 __entry->rq_ps = rq->prev_runnable_sum;
358 __entry->grp_cs = cpu_time ? cpu_time->curr_runnable_sum : 0;
359 __entry->grp_ps = cpu_time ? cpu_time->prev_runnable_sum : 0;
360 __entry->grp_nt_cs = cpu_time ? cpu_time->nt_curr_runnable_sum : 0;
361 __entry->grp_nt_ps = cpu_time ? cpu_time->nt_prev_runnable_sum : 0;
362 __entry->curr_window = p->ravg.curr_window;
363 __entry->prev_window = p->ravg.prev_window;
Syed Rameez Mustafa60cef212016-05-09 16:28:07 -0700364 __window_data(__get_dynamic_array(curr_sum), p->ravg.curr_window_cpu);
365 __window_data(__get_dynamic_array(prev_sum), p->ravg.prev_window_cpu);
Syed Rameez Mustafadddcab72016-09-07 16:18:27 -0700366 __entry->nt_cs = rq->nt_curr_runnable_sum;
367 __entry->nt_ps = rq->nt_prev_runnable_sum;
368 __entry->active_windows = p->ravg.active_windows;
Syed Rameez Mustafa59b5fb72016-05-31 16:40:45 -0700369 __entry->curr_top = rq->curr_top;
370 __entry->prev_top = rq->prev_top;
Syed Rameez Mustafadddcab72016-09-07 16:18:27 -0700371 ),
372
Syed Rameez Mustafa59b5fb72016-05-31 16:40:45 -0700373 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",
374 __entry->wallclock, __entry->win_start, __entry->delta,
Syed Rameez Mustafadddcab72016-09-07 16:18:27 -0700375 task_event_names[__entry->evt], __entry->cpu,
376 __entry->cur_freq, __entry->cur_pid,
377 __entry->pid, __entry->comm, __entry->mark_start,
378 __entry->delta_m, __entry->demand,
379 __entry->sum, __entry->irqtime, __entry->pred_demand,
380 __entry->rq_cs, __entry->rq_ps, __entry->curr_window,
Syed Rameez Mustafa60cef212016-05-09 16:28:07 -0700381 __window_print(p, __get_dynamic_array(curr_sum), nr_cpu_ids),
382 __entry->prev_window,
383 __window_print(p, __get_dynamic_array(prev_sum), nr_cpu_ids),
384 __entry->nt_cs, __entry->nt_ps,
Syed Rameez Mustafadddcab72016-09-07 16:18:27 -0700385 __entry->active_windows, __entry->grp_cs,
Syed Rameez Mustafa59b5fb72016-05-31 16:40:45 -0700386 __entry->grp_ps, __entry->grp_nt_cs, __entry->grp_nt_ps,
387 __entry->curr_top, __entry->prev_top)
Syed Rameez Mustafadddcab72016-09-07 16:18:27 -0700388);
389
Joonwoo Parkf7d6cd42017-01-17 15:19:43 -0800390struct migration_sum_data;
391extern const char *migrate_type_names[];
Syed Rameez Mustafadddcab72016-09-07 16:18:27 -0700392
Joonwoo Parkf7d6cd42017-01-17 15:19:43 -0800393TRACE_EVENT(sched_set_preferred_cluster,
Syed Rameez Mustafadddcab72016-09-07 16:18:27 -0700394
Joonwoo Parkf7d6cd42017-01-17 15:19:43 -0800395 TP_PROTO(struct related_thread_group *grp, u64 total_demand),
396
397 TP_ARGS(grp, total_demand),
Syed Rameez Mustafadddcab72016-09-07 16:18:27 -0700398
399 TP_STRUCT__entry(
Joonwoo Parkf7d6cd42017-01-17 15:19:43 -0800400 __field( int, id )
401 __field( u64, demand )
402 __field( int, cluster_first_cpu )
403 __array( char, comm, TASK_COMM_LEN )
Syed Rameez Mustafadddcab72016-09-07 16:18:27 -0700404 __field( pid_t, pid )
Joonwoo Parkf7d6cd42017-01-17 15:19:43 -0800405 __field(unsigned int, task_demand )
Syed Rameez Mustafadddcab72016-09-07 16:18:27 -0700406 ),
407
408 TP_fast_assign(
Joonwoo Parkf7d6cd42017-01-17 15:19:43 -0800409 __entry->id = grp->id;
410 __entry->demand = total_demand;
411 __entry->cluster_first_cpu = grp->preferred_cluster ?
412 cluster_first_cpu(grp->preferred_cluster)
413 : -1;
Syed Rameez Mustafadddcab72016-09-07 16:18:27 -0700414 ),
415
Joonwoo Parkf7d6cd42017-01-17 15:19:43 -0800416 TP_printk("group_id %d total_demand %llu preferred_cluster_first_cpu %d",
417 __entry->id, __entry->demand,
418 __entry->cluster_first_cpu)
Syed Rameez Mustafadddcab72016-09-07 16:18:27 -0700419);
420
421TRACE_EVENT(sched_migration_update_sum,
422
Pavankumar Kondeti6deb2c42017-01-09 13:56:33 +0530423 TP_PROTO(struct task_struct *p, enum migrate_types migrate_type, struct rq *rq),
Syed Rameez Mustafadddcab72016-09-07 16:18:27 -0700424
Pavankumar Kondeti6deb2c42017-01-09 13:56:33 +0530425 TP_ARGS(p, migrate_type, rq),
Syed Rameez Mustafadddcab72016-09-07 16:18:27 -0700426
427 TP_STRUCT__entry(
428 __field(int, tcpu )
429 __field(int, pid )
Syed Rameez Mustafadddcab72016-09-07 16:18:27 -0700430 __field(enum migrate_types, migrate_type )
431 __field( s64, src_cs )
432 __field( s64, src_ps )
433 __field( s64, dst_cs )
434 __field( s64, dst_ps )
435 __field( s64, src_nt_cs )
436 __field( s64, src_nt_ps )
437 __field( s64, dst_nt_cs )
438 __field( s64, dst_nt_ps )
439 ),
440
441 TP_fast_assign(
442 __entry->tcpu = task_cpu(p);
443 __entry->pid = p->pid;
444 __entry->migrate_type = migrate_type;
Pavankumar Kondeti6deb2c42017-01-09 13:56:33 +0530445 __entry->src_cs = __get_update_sum(rq, migrate_type,
446 true, false, true);
447 __entry->src_ps = __get_update_sum(rq, migrate_type,
448 true, false, false);
449 __entry->dst_cs = __get_update_sum(rq, migrate_type,
450 false, false, true);
451 __entry->dst_ps = __get_update_sum(rq, migrate_type,
452 false, false, false);
453 __entry->src_nt_cs = __get_update_sum(rq, migrate_type,
454 true, true, true);
455 __entry->src_nt_ps = __get_update_sum(rq, migrate_type,
456 true, true, false);
457 __entry->dst_nt_cs = __get_update_sum(rq, migrate_type,
458 false, true, true);
459 __entry->dst_nt_ps = __get_update_sum(rq, migrate_type,
460 false, true, false);
Syed Rameez Mustafadddcab72016-09-07 16:18:27 -0700461 ),
462
463 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",
464 __entry->pid, __entry->tcpu, migrate_type_names[__entry->migrate_type],
465 __entry->src_cs, __entry->src_ps, __entry->dst_cs, __entry->dst_ps,
466 __entry->src_nt_cs, __entry->src_nt_ps, __entry->dst_nt_cs, __entry->dst_nt_ps)
467);
468
Joonwoo Parkf7d6cd42017-01-17 15:19:43 -0800469#endif
470
471#ifdef CONFIG_SCHED_WALT
472DECLARE_EVENT_CLASS(sched_cpu_load,
473
474 TP_PROTO(struct rq *rq, int idle, u64 irqload, unsigned int power_cost, int temp),
475
476 TP_ARGS(rq, idle, irqload, power_cost, temp),
477
478 TP_STRUCT__entry(
479 __field(unsigned int, cpu )
480 __field(unsigned int, idle )
481 __field(unsigned int, nr_running )
482 __field(unsigned int, nr_big_tasks )
483 __field(unsigned int, load_scale_factor )
484 __field(unsigned int, capacity )
485 __field( u64, cumulative_runnable_avg )
486 __field( u64, irqload )
487 __field(unsigned int, max_freq )
488 __field(unsigned int, power_cost )
489 __field( int, cstate )
490 __field( int, dstate )
491 __field( int, temp )
492 ),
493
494 TP_fast_assign(
495 __entry->cpu = rq->cpu;
496 __entry->idle = idle;
497 __entry->nr_running = rq->nr_running;
498 __entry->nr_big_tasks = rq->hmp_stats.nr_big_tasks;
499 __entry->load_scale_factor = cpu_load_scale_factor(rq->cpu);
500 __entry->capacity = cpu_capacity(rq->cpu);
501 __entry->cumulative_runnable_avg = rq->hmp_stats.cumulative_runnable_avg;
502 __entry->irqload = irqload;
503 __entry->max_freq = cpu_max_freq(rq->cpu);
504 __entry->power_cost = power_cost;
505 __entry->cstate = rq->cstate;
506 __entry->dstate = rq->cluster->dstate;
507 __entry->temp = temp;
508 ),
509
510 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",
511 __entry->cpu, __entry->idle, __entry->nr_running, __entry->nr_big_tasks,
512 __entry->load_scale_factor, __entry->capacity,
513 __entry->cumulative_runnable_avg, __entry->irqload,
514 __entry->max_freq, __entry->power_cost, __entry->cstate,
515 __entry->dstate, __entry->temp)
516);
517
518DEFINE_EVENT(sched_cpu_load, sched_cpu_load_lb,
519 TP_PROTO(struct rq *rq, int idle, u64 irqload, unsigned int power_cost, int temp),
520 TP_ARGS(rq, idle, irqload, power_cost, temp)
521);
522#endif
523
524#ifdef CONFIG_SCHED_HMP
525
526TRACE_EVENT(sched_task_load,
527
528 TP_PROTO(struct task_struct *p, bool boost, int reason,
529 bool sync, bool need_idle, u32 flags, int best_cpu),
530
531 TP_ARGS(p, boost, reason, sync, need_idle, flags, best_cpu),
532
533 TP_STRUCT__entry(
534 __array( char, comm, TASK_COMM_LEN )
535 __field( pid_t, pid )
536 __field(unsigned int, demand )
537 __field( bool, boost )
538 __field( int, reason )
539 __field( bool, sync )
540 __field( bool, need_idle )
541 __field( u32, flags )
542 __field( int, best_cpu )
543 __field( u64, latency )
544 __field( int, grp_id )
545 __field( u64, avg_burst )
546 __field( u64, avg_sleep )
547 ),
548
549 TP_fast_assign(
550 memcpy(__entry->comm, p->comm, TASK_COMM_LEN);
551 __entry->pid = p->pid;
552 __entry->demand = p->ravg.demand;
553 __entry->boost = boost;
554 __entry->reason = reason;
555 __entry->sync = sync;
556 __entry->need_idle = need_idle;
557 __entry->flags = flags;
558 __entry->best_cpu = best_cpu;
559 __entry->latency = p->state == TASK_WAKING ?
560 sched_ktime_clock() -
561 p->ravg.mark_start : 0;
562 __entry->grp_id = p->grp ? p->grp->id : 0;
563 __entry->avg_burst = p->ravg.avg_burst;
564 __entry->avg_sleep = p->ravg.avg_sleep_time;
565 ),
566
567 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",
568 __entry->pid, __entry->comm, __entry->demand,
569 __entry->boost, __entry->reason, __entry->sync,
570 __entry->need_idle, __entry->flags, __entry->grp_id,
571 __entry->best_cpu, __entry->latency, __entry->avg_burst,
572 __entry->avg_sleep)
573);
574
575DEFINE_EVENT(sched_cpu_load, sched_cpu_load_wakeup,
576 TP_PROTO(struct rq *rq, int idle, u64 irqload, unsigned int power_cost, int temp),
577 TP_ARGS(rq, idle, irqload, power_cost, temp)
578);
579
580DEFINE_EVENT(sched_cpu_load, sched_cpu_load_cgroup,
581 TP_PROTO(struct rq *rq, int idle, u64 irqload, unsigned int power_cost, int temp),
582 TP_ARGS(rq, idle, irqload, power_cost, temp)
583);
584
585TRACE_EVENT(sched_set_boost,
586
587 TP_PROTO(int type),
588
589 TP_ARGS(type),
590
591 TP_STRUCT__entry(
592 __field(int, type )
593 ),
594
595 TP_fast_assign(
596 __entry->type = type;
597 ),
598
599 TP_printk("type %d", __entry->type)
600);
601
602TRACE_EVENT(sched_reset_all_window_stats,
603
604 TP_PROTO(u64 window_start, u64 window_size, u64 time_taken,
605 int reason, unsigned int old_val, unsigned int new_val),
606
607 TP_ARGS(window_start, window_size, time_taken,
608 reason, old_val, new_val),
609
610 TP_STRUCT__entry(
611 __field( u64, window_start )
612 __field( u64, window_size )
613 __field( u64, time_taken )
614 __field( int, reason )
615 __field(unsigned int, old_val )
616 __field(unsigned int, new_val )
617 ),
618
619 TP_fast_assign(
620 __entry->window_start = window_start;
621 __entry->window_size = window_size;
622 __entry->time_taken = time_taken;
623 __entry->reason = reason;
624 __entry->old_val = old_val;
625 __entry->new_val = new_val;
626 ),
627
628 TP_printk("time_taken %llu window_start %llu window_size %llu reason %s old_val %u new_val %u",
629 __entry->time_taken, __entry->window_start,
630 __entry->window_size,
631 sched_window_reset_reasons[__entry->reason],
632 __entry->old_val, __entry->new_val)
633);
634
Syed Rameez Mustafadddcab72016-09-07 16:18:27 -0700635TRACE_EVENT(sched_get_busy,
636
637 TP_PROTO(int cpu, u64 load, u64 nload, u64 pload, int early),
638
639 TP_ARGS(cpu, load, nload, pload, early),
640
641 TP_STRUCT__entry(
642 __field( int, cpu )
643 __field( u64, load )
644 __field( u64, nload )
645 __field( u64, pload )
646 __field( int, early )
647 ),
648
649 TP_fast_assign(
650 __entry->cpu = cpu;
651 __entry->load = load;
652 __entry->nload = nload;
653 __entry->pload = pload;
654 __entry->early = early;
655 ),
656
657 TP_printk("cpu %d load %lld new_task_load %lld predicted_load %lld early %d",
658 __entry->cpu, __entry->load, __entry->nload,
659 __entry->pload, __entry->early)
660);
661
662TRACE_EVENT(sched_freq_alert,
663
664 TP_PROTO(int cpu, int pd_notif, int check_groups, struct rq *rq,
665 u64 new_load),
666
667 TP_ARGS(cpu, pd_notif, check_groups, rq, new_load),
668
669 TP_STRUCT__entry(
670 __field( int, cpu )
671 __field( int, pd_notif )
672 __field( int, check_groups )
673 __field( u64, old_busy_time )
674 __field( u64, ps )
675 __field( u64, new_load )
676 __field( u64, old_pred )
677 __field( u64, new_pred )
678 ),
679
680 TP_fast_assign(
681 __entry->cpu = cpu;
682 __entry->pd_notif = pd_notif;
683 __entry->check_groups = check_groups;
684 __entry->old_busy_time = rq->old_busy_time;
685 __entry->ps = rq->prev_runnable_sum;
686 __entry->new_load = new_load;
687 __entry->old_pred = rq->old_estimated_time;
688 __entry->new_pred = rq->hmp_stats.pred_demands_sum;
689 ),
690
691 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",
692 __entry->cpu, __entry->pd_notif, __entry->check_groups,
693 __entry->old_busy_time, __entry->ps, __entry->new_load,
694 __entry->old_pred, __entry->new_pred)
695);
696
697#endif /* CONFIG_SCHED_HMP */
698
699/*
Steven Rostedtea20d922009-04-10 08:54:16 -0400700 * Tracepoint for waking up a task:
Steven Rostedtea20d922009-04-10 08:54:16 -0400701 */
Ingo Molnar091ad362009-11-26 09:04:55 +0100702DECLARE_EVENT_CLASS(sched_wakeup_template,
Steven Rostedtea20d922009-04-10 08:54:16 -0400703
Peter Zijlstrafbd705a2015-06-09 11:13:36 +0200704 TP_PROTO(struct task_struct *p),
Steven Rostedtea20d922009-04-10 08:54:16 -0400705
Peter Zijlstrafbd705a2015-06-09 11:13:36 +0200706 TP_ARGS(__perf_task(p)),
Steven Rostedtea20d922009-04-10 08:54:16 -0400707
708 TP_STRUCT__entry(
709 __array( char, comm, TASK_COMM_LEN )
710 __field( pid_t, pid )
711 __field( int, prio )
712 __field( int, success )
Ingo Molnar434a83c2009-10-15 11:50:39 +0200713 __field( int, target_cpu )
Steven Rostedtea20d922009-04-10 08:54:16 -0400714 ),
715
716 TP_fast_assign(
717 memcpy(__entry->comm, p->comm, TASK_COMM_LEN);
718 __entry->pid = p->pid;
719 __entry->prio = p->prio;
Peter Zijlstrafbd705a2015-06-09 11:13:36 +0200720 __entry->success = 1; /* rudiment, kill when possible */
Ingo Molnar434a83c2009-10-15 11:50:39 +0200721 __entry->target_cpu = task_cpu(p);
Steven Rostedtea20d922009-04-10 08:54:16 -0400722 ),
723
Peter Zijlstrafbd705a2015-06-09 11:13:36 +0200724 TP_printk("comm=%s pid=%d prio=%d target_cpu=%03d",
Steven Rostedtea20d922009-04-10 08:54:16 -0400725 __entry->comm, __entry->pid, __entry->prio,
Peter Zijlstrafbd705a2015-06-09 11:13:36 +0200726 __entry->target_cpu)
Steven Rostedtea20d922009-04-10 08:54:16 -0400727);
728
Peter Zijlstrafbd705a2015-06-09 11:13:36 +0200729/*
730 * Tracepoint called when waking a task; this tracepoint is guaranteed to be
731 * called from the waking context.
732 */
733DEFINE_EVENT(sched_wakeup_template, sched_waking,
734 TP_PROTO(struct task_struct *p),
735 TP_ARGS(p));
736
737/*
738 * Tracepoint called when the task is actually woken; p->state == TASK_RUNNNG.
739 * It it not always called from the waking context.
740 */
Steven Rostedt75ec29a2009-11-18 20:48:08 -0500741DEFINE_EVENT(sched_wakeup_template, sched_wakeup,
Peter Zijlstrafbd705a2015-06-09 11:13:36 +0200742 TP_PROTO(struct task_struct *p),
743 TP_ARGS(p));
Steven Rostedt75ec29a2009-11-18 20:48:08 -0500744
Steven Rostedtea20d922009-04-10 08:54:16 -0400745/*
746 * Tracepoint for waking up a new task:
Steven Rostedtea20d922009-04-10 08:54:16 -0400747 */
Steven Rostedt75ec29a2009-11-18 20:48:08 -0500748DEFINE_EVENT(sched_wakeup_template, sched_wakeup_new,
Peter Zijlstrafbd705a2015-06-09 11:13:36 +0200749 TP_PROTO(struct task_struct *p),
750 TP_ARGS(p));
Steven Rostedtea20d922009-04-10 08:54:16 -0400751
Peter Zijlstra02f72692010-05-31 18:13:25 +0200752#ifdef CREATE_TRACE_POINTS
Peter Zijlstrac73464b2015-09-28 18:06:56 +0200753static inline long __trace_sched_switch_state(bool preempt, struct task_struct *p)
Peter Zijlstra02f72692010-05-31 18:13:25 +0200754{
Oleg Nesterov8f9fbf02014-10-07 21:51:08 +0200755#ifdef CONFIG_SCHED_DEBUG
756 BUG_ON(p != current);
757#endif /* CONFIG_SCHED_DEBUG */
Peter Zijlstra02f72692010-05-31 18:13:25 +0200758
Peter Zijlstrac73464b2015-09-28 18:06:56 +0200759 /*
760 * Preemption ignores task state, therefore preempted tasks are always
761 * RUNNING (we will not have dequeued if state != RUNNING).
762 */
763 return preempt ? TASK_RUNNING | TASK_STATE_MAX : p->state;
Peter Zijlstra02f72692010-05-31 18:13:25 +0200764}
Oleg Nesterov8f9fbf02014-10-07 21:51:08 +0200765#endif /* CREATE_TRACE_POINTS */
Peter Zijlstra02f72692010-05-31 18:13:25 +0200766
Steven Rostedtea20d922009-04-10 08:54:16 -0400767/*
768 * Tracepoint for task switches, performed by the scheduler:
Steven Rostedtea20d922009-04-10 08:54:16 -0400769 */
770TRACE_EVENT(sched_switch,
771
Peter Zijlstrac73464b2015-09-28 18:06:56 +0200772 TP_PROTO(bool preempt,
773 struct task_struct *prev,
Steven Rostedtea20d922009-04-10 08:54:16 -0400774 struct task_struct *next),
775
Peter Zijlstrac73464b2015-09-28 18:06:56 +0200776 TP_ARGS(preempt, prev, next),
Steven Rostedtea20d922009-04-10 08:54:16 -0400777
778 TP_STRUCT__entry(
779 __array( char, prev_comm, TASK_COMM_LEN )
780 __field( pid_t, prev_pid )
781 __field( int, prev_prio )
Steven Rostedt937cdb92009-05-15 10:51:13 -0400782 __field( long, prev_state )
Steven Rostedtea20d922009-04-10 08:54:16 -0400783 __array( char, next_comm, TASK_COMM_LEN )
784 __field( pid_t, next_pid )
785 __field( int, next_prio )
786 ),
787
788 TP_fast_assign(
789 memcpy(__entry->next_comm, next->comm, TASK_COMM_LEN);
790 __entry->prev_pid = prev->pid;
791 __entry->prev_prio = prev->prio;
Peter Zijlstrac73464b2015-09-28 18:06:56 +0200792 __entry->prev_state = __trace_sched_switch_state(preempt, prev);
Steven Rostedtea20d922009-04-10 08:54:16 -0400793 memcpy(__entry->prev_comm, prev->comm, TASK_COMM_LEN);
794 __entry->next_pid = next->pid;
795 __entry->next_prio = next->prio;
796 ),
797
Peter Zijlstra557ab422011-09-16 11:16:43 +0200798 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 -0400799 __entry->prev_comm, __entry->prev_pid, __entry->prev_prio,
Peter Zijlstra557ab422011-09-16 11:16:43 +0200800 __entry->prev_state & (TASK_STATE_MAX-1) ?
801 __print_flags(__entry->prev_state & (TASK_STATE_MAX-1), "|",
Steven Rostedt937cdb92009-05-15 10:51:13 -0400802 { 1, "S"} , { 2, "D" }, { 4, "T" }, { 8, "t" },
803 { 16, "Z" }, { 32, "X" }, { 64, "x" },
Peter Zijlstra80ed87c2015-05-08 14:23:45 +0200804 { 128, "K" }, { 256, "W" }, { 512, "P" },
805 { 1024, "N" }) : "R",
Peter Zijlstra557ab422011-09-16 11:16:43 +0200806 __entry->prev_state & TASK_STATE_MAX ? "+" : "",
Steven Rostedtea20d922009-04-10 08:54:16 -0400807 __entry->next_comm, __entry->next_pid, __entry->next_prio)
808);
809
810/*
811 * Tracepoint for a task being migrated:
812 */
813TRACE_EVENT(sched_migrate_task,
814
Syed Rameez Mustafadddcab72016-09-07 16:18:27 -0700815 TP_PROTO(struct task_struct *p, int dest_cpu, unsigned int load),
Steven Rostedtea20d922009-04-10 08:54:16 -0400816
Syed Rameez Mustafadddcab72016-09-07 16:18:27 -0700817 TP_ARGS(p, dest_cpu, load),
Steven Rostedtea20d922009-04-10 08:54:16 -0400818
819 TP_STRUCT__entry(
820 __array( char, comm, TASK_COMM_LEN )
821 __field( pid_t, pid )
822 __field( int, prio )
Syed Rameez Mustafadddcab72016-09-07 16:18:27 -0700823 __field(unsigned int, load )
Steven Rostedtea20d922009-04-10 08:54:16 -0400824 __field( int, orig_cpu )
825 __field( int, dest_cpu )
826 ),
827
828 TP_fast_assign(
829 memcpy(__entry->comm, p->comm, TASK_COMM_LEN);
830 __entry->pid = p->pid;
831 __entry->prio = p->prio;
Syed Rameez Mustafadddcab72016-09-07 16:18:27 -0700832 __entry->load = load;
Mathieu Desnoyersde1d7282009-05-05 16:49:59 +0800833 __entry->orig_cpu = task_cpu(p);
Steven Rostedtea20d922009-04-10 08:54:16 -0400834 __entry->dest_cpu = dest_cpu;
835 ),
836
Syed Rameez Mustafadddcab72016-09-07 16:18:27 -0700837 TP_printk("comm=%s pid=%d prio=%d load=%d orig_cpu=%d dest_cpu=%d",
838 __entry->comm, __entry->pid, __entry->prio, __entry->load,
Steven Rostedtea20d922009-04-10 08:54:16 -0400839 __entry->orig_cpu, __entry->dest_cpu)
840);
841
Syed Rameez Mustafadddcab72016-09-07 16:18:27 -0700842/*
843 * Tracepoint for a CPU going offline/online:
844 */
845TRACE_EVENT(sched_cpu_hotplug,
846
847 TP_PROTO(int affected_cpu, int error, int status),
848
849 TP_ARGS(affected_cpu, error, status),
850
851 TP_STRUCT__entry(
852 __field( int, affected_cpu )
853 __field( int, error )
854 __field( int, status )
855 ),
856
857 TP_fast_assign(
858 __entry->affected_cpu = affected_cpu;
859 __entry->error = error;
860 __entry->status = status;
861 ),
862
863 TP_printk("cpu %d %s error=%d", __entry->affected_cpu,
864 __entry->status ? "online" : "offline", __entry->error)
865);
866
867/*
868 * Tracepoint for load balancing:
869 */
870#if NR_CPUS > 32
871#error "Unsupported NR_CPUS for lb tracepoint."
872#endif
873TRACE_EVENT(sched_load_balance,
874
875 TP_PROTO(int cpu, enum cpu_idle_type idle, int balance,
876 unsigned long group_mask, int busiest_nr_running,
877 unsigned long imbalance, unsigned int env_flags, int ld_moved,
878 unsigned int balance_interval),
879
880 TP_ARGS(cpu, idle, balance, group_mask, busiest_nr_running,
881 imbalance, env_flags, ld_moved, balance_interval),
882
883 TP_STRUCT__entry(
884 __field( int, cpu)
885 __field( enum cpu_idle_type, idle)
886 __field( int, balance)
887 __field( unsigned long, group_mask)
888 __field( int, busiest_nr_running)
889 __field( unsigned long, imbalance)
890 __field( unsigned int, env_flags)
891 __field( int, ld_moved)
892 __field( unsigned int, balance_interval)
893 ),
894
895 TP_fast_assign(
896 __entry->cpu = cpu;
897 __entry->idle = idle;
898 __entry->balance = balance;
899 __entry->group_mask = group_mask;
900 __entry->busiest_nr_running = busiest_nr_running;
901 __entry->imbalance = imbalance;
902 __entry->env_flags = env_flags;
903 __entry->ld_moved = ld_moved;
904 __entry->balance_interval = balance_interval;
905 ),
906
907 TP_printk("cpu=%d state=%s balance=%d group=%#lx busy_nr=%d imbalance=%ld flags=%#x ld_moved=%d bal_int=%d",
908 __entry->cpu,
909 __entry->idle == CPU_IDLE ? "idle" :
910 (__entry->idle == CPU_NEWLY_IDLE ? "newly_idle" : "busy"),
911 __entry->balance,
912 __entry->group_mask, __entry->busiest_nr_running,
913 __entry->imbalance, __entry->env_flags, __entry->ld_moved,
914 __entry->balance_interval)
915);
916
Ingo Molnar091ad362009-11-26 09:04:55 +0100917DECLARE_EVENT_CLASS(sched_process_template,
Steven Rostedtea20d922009-04-10 08:54:16 -0400918
919 TP_PROTO(struct task_struct *p),
920
921 TP_ARGS(p),
922
923 TP_STRUCT__entry(
924 __array( char, comm, TASK_COMM_LEN )
925 __field( pid_t, pid )
926 __field( int, prio )
927 ),
928
929 TP_fast_assign(
930 memcpy(__entry->comm, p->comm, TASK_COMM_LEN);
931 __entry->pid = p->pid;
932 __entry->prio = p->prio;
933 ),
934
Ingo Molnar434a83c2009-10-15 11:50:39 +0200935 TP_printk("comm=%s pid=%d prio=%d",
Steven Rostedtea20d922009-04-10 08:54:16 -0400936 __entry->comm, __entry->pid, __entry->prio)
937);
938
939/*
Steven Rostedt75ec29a2009-11-18 20:48:08 -0500940 * Tracepoint for freeing a task:
941 */
942DEFINE_EVENT(sched_process_template, sched_process_free,
943 TP_PROTO(struct task_struct *p),
944 TP_ARGS(p));
Riley Andrews9de15b42015-10-02 00:39:53 -0700945
Steven Rostedt75ec29a2009-11-18 20:48:08 -0500946
947/*
Steven Rostedtea20d922009-04-10 08:54:16 -0400948 * Tracepoint for a task exiting:
949 */
Steven Rostedt75ec29a2009-11-18 20:48:08 -0500950DEFINE_EVENT(sched_process_template, sched_process_exit,
951 TP_PROTO(struct task_struct *p),
952 TP_ARGS(p));
Steven Rostedtea20d922009-04-10 08:54:16 -0400953
954/*
Li Zefan210f7662010-05-24 16:23:35 +0800955 * Tracepoint for waiting on task to unschedule:
956 */
957DEFINE_EVENT(sched_process_template, sched_wait_task,
958 TP_PROTO(struct task_struct *p),
959 TP_ARGS(p));
960
961/*
Steven Rostedtea20d922009-04-10 08:54:16 -0400962 * Tracepoint for a waiting task:
963 */
964TRACE_EVENT(sched_process_wait,
965
966 TP_PROTO(struct pid *pid),
967
968 TP_ARGS(pid),
969
970 TP_STRUCT__entry(
971 __array( char, comm, TASK_COMM_LEN )
972 __field( pid_t, pid )
973 __field( int, prio )
974 ),
975
976 TP_fast_assign(
977 memcpy(__entry->comm, current->comm, TASK_COMM_LEN);
978 __entry->pid = pid_nr(pid);
979 __entry->prio = current->prio;
980 ),
981
Ingo Molnar434a83c2009-10-15 11:50:39 +0200982 TP_printk("comm=%s pid=%d prio=%d",
Steven Rostedtea20d922009-04-10 08:54:16 -0400983 __entry->comm, __entry->pid, __entry->prio)
984);
985
986/*
987 * Tracepoint for do_fork:
988 */
989TRACE_EVENT(sched_process_fork,
990
991 TP_PROTO(struct task_struct *parent, struct task_struct *child),
992
993 TP_ARGS(parent, child),
994
995 TP_STRUCT__entry(
996 __array( char, parent_comm, TASK_COMM_LEN )
997 __field( pid_t, parent_pid )
998 __array( char, child_comm, TASK_COMM_LEN )
999 __field( pid_t, child_pid )
1000 ),
1001
1002 TP_fast_assign(
1003 memcpy(__entry->parent_comm, parent->comm, TASK_COMM_LEN);
1004 __entry->parent_pid = parent->pid;
1005 memcpy(__entry->child_comm, child->comm, TASK_COMM_LEN);
1006 __entry->child_pid = child->pid;
1007 ),
1008
Ingo Molnar434a83c2009-10-15 11:50:39 +02001009 TP_printk("comm=%s pid=%d child_comm=%s child_pid=%d",
Steven Rostedtea20d922009-04-10 08:54:16 -04001010 __entry->parent_comm, __entry->parent_pid,
1011 __entry->child_comm, __entry->child_pid)
1012);
1013
1014/*
David Smith4ff16c22012-02-07 10:11:05 -06001015 * Tracepoint for exec:
1016 */
1017TRACE_EVENT(sched_process_exec,
1018
1019 TP_PROTO(struct task_struct *p, pid_t old_pid,
1020 struct linux_binprm *bprm),
1021
1022 TP_ARGS(p, old_pid, bprm),
1023
1024 TP_STRUCT__entry(
1025 __string( filename, bprm->filename )
1026 __field( pid_t, pid )
1027 __field( pid_t, old_pid )
1028 ),
1029
1030 TP_fast_assign(
1031 __assign_str(filename, bprm->filename);
1032 __entry->pid = p->pid;
Oleg Nesterov63081912012-03-30 18:26:36 +02001033 __entry->old_pid = old_pid;
David Smith4ff16c22012-02-07 10:11:05 -06001034 ),
1035
1036 TP_printk("filename=%s pid=%d old_pid=%d", __get_str(filename),
1037 __entry->pid, __entry->old_pid)
1038);
1039
1040/*
Peter Zijlstra768d0c22009-07-23 20:13:26 +02001041 * XXX the below sched_stat tracepoints only apply to SCHED_OTHER/BATCH/IDLE
1042 * adding sched_stat support to SCHED_FIFO/RR would be welcome.
1043 */
Ingo Molnar091ad362009-11-26 09:04:55 +01001044DECLARE_EVENT_CLASS(sched_stat_template,
Peter Zijlstra768d0c22009-07-23 20:13:26 +02001045
1046 TP_PROTO(struct task_struct *tsk, u64 delay),
1047
Oleg Nesterov12473962013-08-06 18:08:44 +02001048 TP_ARGS(__perf_task(tsk), __perf_count(delay)),
Peter Zijlstra768d0c22009-07-23 20:13:26 +02001049
1050 TP_STRUCT__entry(
1051 __array( char, comm, TASK_COMM_LEN )
1052 __field( pid_t, pid )
1053 __field( u64, delay )
1054 ),
1055
1056 TP_fast_assign(
1057 memcpy(__entry->comm, tsk->comm, TASK_COMM_LEN);
1058 __entry->pid = tsk->pid;
1059 __entry->delay = delay;
Peter Zijlstra768d0c22009-07-23 20:13:26 +02001060 ),
1061
Ingo Molnar434a83c2009-10-15 11:50:39 +02001062 TP_printk("comm=%s pid=%d delay=%Lu [ns]",
Peter Zijlstra768d0c22009-07-23 20:13:26 +02001063 __entry->comm, __entry->pid,
1064 (unsigned long long)__entry->delay)
1065);
1066
Steven Rostedt75ec29a2009-11-18 20:48:08 -05001067
1068/*
1069 * Tracepoint for accounting wait time (time the task is runnable
1070 * but not actually running due to scheduler contention).
1071 */
1072DEFINE_EVENT(sched_stat_template, sched_stat_wait,
1073 TP_PROTO(struct task_struct *tsk, u64 delay),
1074 TP_ARGS(tsk, delay));
1075
1076/*
1077 * Tracepoint for accounting sleep time (time the task is not runnable,
1078 * including iowait, see below).
1079 */
Li Zefan470dda742009-11-26 15:08:01 +08001080DEFINE_EVENT(sched_stat_template, sched_stat_sleep,
1081 TP_PROTO(struct task_struct *tsk, u64 delay),
1082 TP_ARGS(tsk, delay));
Steven Rostedt75ec29a2009-11-18 20:48:08 -05001083
1084/*
1085 * Tracepoint for accounting iowait time (time the task is not runnable
1086 * due to waiting on IO to complete).
1087 */
Li Zefan470dda742009-11-26 15:08:01 +08001088DEFINE_EVENT(sched_stat_template, sched_stat_iowait,
1089 TP_PROTO(struct task_struct *tsk, u64 delay),
1090 TP_ARGS(tsk, delay));
Steven Rostedt75ec29a2009-11-18 20:48:08 -05001091
Peter Zijlstra768d0c22009-07-23 20:13:26 +02001092/*
Andrew Vaginb781a602011-11-28 12:03:35 +03001093 * Tracepoint for accounting blocked time (time the task is in uninterruptible).
1094 */
1095DEFINE_EVENT(sched_stat_template, sched_stat_blocked,
1096 TP_PROTO(struct task_struct *tsk, u64 delay),
1097 TP_ARGS(tsk, delay));
1098
1099/*
Riley Andrews9de15b42015-10-02 00:39:53 -07001100 * Tracepoint for recording the cause of uninterruptible sleep.
1101 */
1102TRACE_EVENT(sched_blocked_reason,
1103
1104 TP_PROTO(struct task_struct *tsk),
1105
1106 TP_ARGS(tsk),
1107
1108 TP_STRUCT__entry(
1109 __field( pid_t, pid )
1110 __field( void*, caller )
1111 __field( bool, io_wait )
1112 ),
1113
1114 TP_fast_assign(
1115 __entry->pid = tsk->pid;
1116 __entry->caller = (void*)get_wchan(tsk);
1117 __entry->io_wait = tsk->in_iowait;
1118 ),
1119
1120 TP_printk("pid=%d iowait=%d caller=%pS", __entry->pid, __entry->io_wait, __entry->caller)
1121);
1122
1123/*
Ingo Molnarf977bb42009-09-13 18:15:54 +02001124 * Tracepoint for accounting runtime (time the task is executing
1125 * on a CPU).
1126 */
Oleg Nesterov36009d072013-08-06 18:08:41 +02001127DECLARE_EVENT_CLASS(sched_stat_runtime,
Ingo Molnarf977bb42009-09-13 18:15:54 +02001128
1129 TP_PROTO(struct task_struct *tsk, u64 runtime, u64 vruntime),
1130
Oleg Nesterov12473962013-08-06 18:08:44 +02001131 TP_ARGS(tsk, __perf_count(runtime), vruntime),
Ingo Molnarf977bb42009-09-13 18:15:54 +02001132
1133 TP_STRUCT__entry(
1134 __array( char, comm, TASK_COMM_LEN )
1135 __field( pid_t, pid )
1136 __field( u64, runtime )
1137 __field( u64, vruntime )
1138 ),
1139
1140 TP_fast_assign(
1141 memcpy(__entry->comm, tsk->comm, TASK_COMM_LEN);
1142 __entry->pid = tsk->pid;
1143 __entry->runtime = runtime;
1144 __entry->vruntime = vruntime;
Ingo Molnarf977bb42009-09-13 18:15:54 +02001145 ),
1146
Ingo Molnar434a83c2009-10-15 11:50:39 +02001147 TP_printk("comm=%s pid=%d runtime=%Lu [ns] vruntime=%Lu [ns]",
Ingo Molnarf977bb42009-09-13 18:15:54 +02001148 __entry->comm, __entry->pid,
1149 (unsigned long long)__entry->runtime,
1150 (unsigned long long)__entry->vruntime)
1151);
1152
Oleg Nesterov36009d072013-08-06 18:08:41 +02001153DEFINE_EVENT(sched_stat_runtime, sched_stat_runtime,
1154 TP_PROTO(struct task_struct *tsk, u64 runtime, u64 vruntime),
1155 TP_ARGS(tsk, runtime, vruntime));
1156
Steven Rostedta8027072010-09-20 15:13:34 -04001157/*
1158 * Tracepoint for showing priority inheritance modifying a tasks
1159 * priority.
1160 */
1161TRACE_EVENT(sched_pi_setprio,
1162
1163 TP_PROTO(struct task_struct *tsk, int newprio),
1164
1165 TP_ARGS(tsk, newprio),
1166
1167 TP_STRUCT__entry(
1168 __array( char, comm, TASK_COMM_LEN )
1169 __field( pid_t, pid )
1170 __field( int, oldprio )
1171 __field( int, newprio )
1172 ),
1173
1174 TP_fast_assign(
1175 memcpy(__entry->comm, tsk->comm, TASK_COMM_LEN);
1176 __entry->pid = tsk->pid;
1177 __entry->oldprio = tsk->prio;
1178 __entry->newprio = newprio;
1179 ),
1180
1181 TP_printk("comm=%s pid=%d oldprio=%d newprio=%d",
1182 __entry->comm, __entry->pid,
1183 __entry->oldprio, __entry->newprio)
1184);
1185
Oleg Nesterov6a716c92013-10-19 18:18:28 +02001186#ifdef CONFIG_DETECT_HUNG_TASK
1187TRACE_EVENT(sched_process_hang,
1188 TP_PROTO(struct task_struct *tsk),
1189 TP_ARGS(tsk),
1190
1191 TP_STRUCT__entry(
1192 __array( char, comm, TASK_COMM_LEN )
1193 __field( pid_t, pid )
1194 ),
1195
1196 TP_fast_assign(
1197 memcpy(__entry->comm, tsk->comm, TASK_COMM_LEN);
1198 __entry->pid = tsk->pid;
1199 ),
1200
1201 TP_printk("comm=%s pid=%d", __entry->comm, __entry->pid)
1202);
1203#endif /* CONFIG_DETECT_HUNG_TASK */
1204
Mel Gorman286549d2014-01-21 15:51:03 -08001205DECLARE_EVENT_CLASS(sched_move_task_template,
1206
1207 TP_PROTO(struct task_struct *tsk, int src_cpu, int dst_cpu),
1208
1209 TP_ARGS(tsk, src_cpu, dst_cpu),
1210
1211 TP_STRUCT__entry(
1212 __field( pid_t, pid )
1213 __field( pid_t, tgid )
1214 __field( pid_t, ngid )
1215 __field( int, src_cpu )
1216 __field( int, src_nid )
1217 __field( int, dst_cpu )
1218 __field( int, dst_nid )
1219 ),
1220
1221 TP_fast_assign(
1222 __entry->pid = task_pid_nr(tsk);
1223 __entry->tgid = task_tgid_nr(tsk);
1224 __entry->ngid = task_numa_group_id(tsk);
1225 __entry->src_cpu = src_cpu;
1226 __entry->src_nid = cpu_to_node(src_cpu);
1227 __entry->dst_cpu = dst_cpu;
1228 __entry->dst_nid = cpu_to_node(dst_cpu);
1229 ),
1230
1231 TP_printk("pid=%d tgid=%d ngid=%d src_cpu=%d src_nid=%d dst_cpu=%d dst_nid=%d",
1232 __entry->pid, __entry->tgid, __entry->ngid,
1233 __entry->src_cpu, __entry->src_nid,
1234 __entry->dst_cpu, __entry->dst_nid)
1235);
1236
1237/*
1238 * Tracks migration of tasks from one runqueue to another. Can be used to
1239 * detect if automatic NUMA balancing is bouncing between nodes
1240 */
1241DEFINE_EVENT(sched_move_task_template, sched_move_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
1247DEFINE_EVENT(sched_move_task_template, sched_stick_numa,
1248 TP_PROTO(struct task_struct *tsk, int src_cpu, int dst_cpu),
1249
1250 TP_ARGS(tsk, src_cpu, dst_cpu)
1251);
1252
1253TRACE_EVENT(sched_swap_numa,
1254
1255 TP_PROTO(struct task_struct *src_tsk, int src_cpu,
1256 struct task_struct *dst_tsk, int dst_cpu),
1257
1258 TP_ARGS(src_tsk, src_cpu, dst_tsk, dst_cpu),
1259
1260 TP_STRUCT__entry(
1261 __field( pid_t, src_pid )
1262 __field( pid_t, src_tgid )
1263 __field( pid_t, src_ngid )
1264 __field( int, src_cpu )
1265 __field( int, src_nid )
1266 __field( pid_t, dst_pid )
1267 __field( pid_t, dst_tgid )
1268 __field( pid_t, dst_ngid )
1269 __field( int, dst_cpu )
1270 __field( int, dst_nid )
1271 ),
1272
1273 TP_fast_assign(
1274 __entry->src_pid = task_pid_nr(src_tsk);
1275 __entry->src_tgid = task_tgid_nr(src_tsk);
1276 __entry->src_ngid = task_numa_group_id(src_tsk);
1277 __entry->src_cpu = src_cpu;
1278 __entry->src_nid = cpu_to_node(src_cpu);
1279 __entry->dst_pid = task_pid_nr(dst_tsk);
1280 __entry->dst_tgid = task_tgid_nr(dst_tsk);
1281 __entry->dst_ngid = task_numa_group_id(dst_tsk);
1282 __entry->dst_cpu = dst_cpu;
1283 __entry->dst_nid = cpu_to_node(dst_cpu);
1284 ),
1285
1286 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",
1287 __entry->src_pid, __entry->src_tgid, __entry->src_ngid,
1288 __entry->src_cpu, __entry->src_nid,
1289 __entry->dst_pid, __entry->dst_tgid, __entry->dst_ngid,
1290 __entry->dst_cpu, __entry->dst_nid)
1291);
Andy Lutomirskidfc68f22014-06-04 10:31:15 -07001292
1293/*
1294 * Tracepoint for waking a polling cpu without an IPI.
1295 */
1296TRACE_EVENT(sched_wake_idle_without_ipi,
1297
1298 TP_PROTO(int cpu),
1299
1300 TP_ARGS(cpu),
1301
1302 TP_STRUCT__entry(
1303 __field( int, cpu )
1304 ),
1305
1306 TP_fast_assign(
1307 __entry->cpu = cpu;
1308 ),
1309
1310 TP_printk("cpu=%d", __entry->cpu)
1311);
Syed Rameez Mustafadddcab72016-09-07 16:18:27 -07001312
Juri Lelli0a942002015-11-09 12:06:24 +00001313TRACE_EVENT(sched_contrib_scale_f,
Juri Lelli0a942002015-11-09 12:06:24 +00001314 TP_PROTO(int cpu, unsigned long freq_scale_factor,
1315 unsigned long cpu_scale_factor),
Juri Lelli0a942002015-11-09 12:06:24 +00001316 TP_ARGS(cpu, freq_scale_factor, cpu_scale_factor),
Juri Lelli0a942002015-11-09 12:06:24 +00001317 TP_STRUCT__entry(
1318 __field(int, cpu)
1319 __field(unsigned long, freq_scale_factor)
1320 __field(unsigned long, cpu_scale_factor)
1321 ),
Juri Lelli0a942002015-11-09 12:06:24 +00001322 TP_fast_assign(
1323 __entry->cpu = cpu;
1324 __entry->freq_scale_factor = freq_scale_factor;
1325 __entry->cpu_scale_factor = cpu_scale_factor;
1326 ),
Juri Lelli0a942002015-11-09 12:06:24 +00001327 TP_printk("cpu=%d freq_scale_factor=%lu cpu_scale_factor=%lu",
1328 __entry->cpu, __entry->freq_scale_factor,
1329 __entry->cpu_scale_factor)
1330);
Juri Lellia4b0c3a2015-11-09 12:07:27 +00001331
Jeevan Shriram49f575e2017-03-02 16:52:44 -08001332#ifdef CONFIG_SMP
Juri Lellia4b0c3a2015-11-09 12:07:27 +00001333/*
1334 * Tracepoint for accounting sched averages for tasks.
1335 */
1336TRACE_EVENT(sched_load_avg_task,
Juri Lellia4b0c3a2015-11-09 12:07:27 +00001337 TP_PROTO(struct task_struct *tsk, struct sched_avg *avg),
Juri Lellia4b0c3a2015-11-09 12:07:27 +00001338 TP_ARGS(tsk, avg),
Juri Lellia4b0c3a2015-11-09 12:07:27 +00001339 TP_STRUCT__entry(
1340 __array( char, comm, TASK_COMM_LEN )
1341 __field( pid_t, pid )
1342 __field( int, cpu )
1343 __field( unsigned long, load_avg )
1344 __field( unsigned long, util_avg )
1345 __field( u64, load_sum )
1346 __field( u32, util_sum )
1347 __field( u32, period_contrib )
1348 ),
Juri Lellia4b0c3a2015-11-09 12:07:27 +00001349 TP_fast_assign(
1350 memcpy(__entry->comm, tsk->comm, TASK_COMM_LEN);
1351 __entry->pid = tsk->pid;
1352 __entry->cpu = task_cpu(tsk);
1353 __entry->load_avg = avg->load_avg;
1354 __entry->util_avg = avg->util_avg;
1355 __entry->load_sum = avg->load_sum;
1356 __entry->util_sum = avg->util_sum;
1357 __entry->period_contrib = avg->period_contrib;
1358 ),
Juri Lellia4b0c3a2015-11-09 12:07:27 +00001359 TP_printk("comm=%s pid=%d cpu=%d load_avg=%lu util_avg=%lu load_sum=%llu"
1360 " util_sum=%u period_contrib=%u",
1361 __entry->comm,
1362 __entry->pid,
1363 __entry->cpu,
1364 __entry->load_avg,
1365 __entry->util_avg,
1366 (u64)__entry->load_sum,
1367 (u32)__entry->util_sum,
1368 (u32)__entry->period_contrib)
1369);
Juri Lelli79478802015-11-09 12:07:48 +00001370/*
1371 * Tracepoint for accounting sched averages for cpus.
1372 */
1373TRACE_EVENT(sched_load_avg_cpu,
Juri Lelli79478802015-11-09 12:07:48 +00001374 TP_PROTO(int cpu, struct cfs_rq *cfs_rq),
Juri Lelli79478802015-11-09 12:07:48 +00001375 TP_ARGS(cpu, cfs_rq),
Juri Lelli79478802015-11-09 12:07:48 +00001376 TP_STRUCT__entry(
1377 __field( int, cpu )
1378 __field( unsigned long, load_avg )
1379 __field( unsigned long, util_avg )
1380 ),
Juri Lelli79478802015-11-09 12:07:48 +00001381 TP_fast_assign(
1382 __entry->cpu = cpu;
1383 __entry->load_avg = cfs_rq->avg.load_avg;
1384 __entry->util_avg = cfs_rq->avg.util_avg;
1385 ),
Juri Lelli79478802015-11-09 12:07:48 +00001386 TP_printk("cpu=%d load_avg=%lu util_avg=%lu",
1387 __entry->cpu, __entry->load_avg, __entry->util_avg)
1388);
Patrick Bellasi050dcb82015-06-22 13:49:07 +01001389/*
1390 * Tracepoint for sched_tune_config settings
1391 */
1392TRACE_EVENT(sched_tune_config,
Patrick Bellasi050dcb82015-06-22 13:49:07 +01001393 TP_PROTO(int boost),
Patrick Bellasi050dcb82015-06-22 13:49:07 +01001394 TP_ARGS(boost),
Patrick Bellasi050dcb82015-06-22 13:49:07 +01001395 TP_STRUCT__entry(
1396 __field( int, boost )
1397 ),
Patrick Bellasi050dcb82015-06-22 13:49:07 +01001398 TP_fast_assign(
1399 __entry->boost = boost;
1400 ),
Patrick Bellasi050dcb82015-06-22 13:49:07 +01001401 TP_printk("boost=%d ", __entry->boost)
1402);
Patrick Bellasicccead12015-06-22 13:51:07 +01001403/*
1404 * Tracepoint for accounting CPU boosted utilization
1405 */
1406TRACE_EVENT(sched_boost_cpu,
Srinath Sridharane71c4252016-07-28 17:28:55 +01001407 TP_PROTO(int cpu, unsigned long util, long margin),
Patrick Bellasicccead12015-06-22 13:51:07 +01001408 TP_ARGS(cpu, util, margin),
Patrick Bellasicccead12015-06-22 13:51:07 +01001409 TP_STRUCT__entry(
1410 __field( int, cpu )
1411 __field( unsigned long, util )
Srinath Sridharane71c4252016-07-28 17:28:55 +01001412 __field(long, margin )
Patrick Bellasicccead12015-06-22 13:51:07 +01001413 ),
Patrick Bellasicccead12015-06-22 13:51:07 +01001414 TP_fast_assign(
1415 __entry->cpu = cpu;
1416 __entry->util = util;
1417 __entry->margin = margin;
1418 ),
Srinath Sridharane71c4252016-07-28 17:28:55 +01001419 TP_printk("cpu=%d util=%lu margin=%ld",
Patrick Bellasicccead12015-06-22 13:51:07 +01001420 __entry->cpu,
1421 __entry->util,
1422 __entry->margin)
1423);
Patrick Bellasi953b1042015-06-24 15:36:08 +01001424/*
1425 * Tracepoint for schedtune_tasks_update
1426 */
1427TRACE_EVENT(sched_tune_tasks_update,
Patrick Bellasi953b1042015-06-24 15:36:08 +01001428 TP_PROTO(struct task_struct *tsk, int cpu, int tasks, int idx,
Srinath Sridharane71c4252016-07-28 17:28:55 +01001429 int boost, int max_boost),
Patrick Bellasi953b1042015-06-24 15:36:08 +01001430 TP_ARGS(tsk, cpu, tasks, idx, boost, max_boost),
Patrick Bellasi953b1042015-06-24 15:36:08 +01001431 TP_STRUCT__entry(
1432 __array( char, comm, TASK_COMM_LEN )
1433 __field( pid_t, pid )
1434 __field( int, cpu )
1435 __field( int, tasks )
1436 __field( int, idx )
Srinath Sridharane71c4252016-07-28 17:28:55 +01001437 __field( int, boost )
1438 __field( int, max_boost )
Patrick Bellasi953b1042015-06-24 15:36:08 +01001439 ),
Patrick Bellasi953b1042015-06-24 15:36:08 +01001440 TP_fast_assign(
1441 memcpy(__entry->comm, tsk->comm, TASK_COMM_LEN);
1442 __entry->pid = tsk->pid;
1443 __entry->cpu = cpu;
1444 __entry->tasks = tasks;
1445 __entry->idx = idx;
1446 __entry->boost = boost;
1447 __entry->max_boost = max_boost;
1448 ),
Patrick Bellasi953b1042015-06-24 15:36:08 +01001449 TP_printk("pid=%d comm=%s "
Srinath Sridharane71c4252016-07-28 17:28:55 +01001450 "cpu=%d tasks=%d idx=%d boost=%d max_boost=%d",
Patrick Bellasi953b1042015-06-24 15:36:08 +01001451 __entry->pid, __entry->comm,
1452 __entry->cpu, __entry->tasks, __entry->idx,
1453 __entry->boost, __entry->max_boost)
1454);
Patrick Bellasi953b1042015-06-24 15:36:08 +01001455/*
1456 * Tracepoint for schedtune_boostgroup_update
1457 */
1458TRACE_EVENT(sched_tune_boostgroup_update,
Patrick Bellasi953b1042015-06-24 15:36:08 +01001459 TP_PROTO(int cpu, int variation, int max_boost),
Patrick Bellasi953b1042015-06-24 15:36:08 +01001460 TP_ARGS(cpu, variation, max_boost),
Patrick Bellasi953b1042015-06-24 15:36:08 +01001461 TP_STRUCT__entry(
1462 __field( int, cpu )
1463 __field( int, variation )
1464 __field( int, max_boost )
1465 ),
Patrick Bellasi953b1042015-06-24 15:36:08 +01001466 TP_fast_assign(
1467 __entry->cpu = cpu;
1468 __entry->variation = variation;
1469 __entry->max_boost = max_boost;
1470 ),
Patrick Bellasi953b1042015-06-24 15:36:08 +01001471 TP_printk("cpu=%d variation=%d max_boost=%d",
1472 __entry->cpu, __entry->variation, __entry->max_boost)
1473);
Patrick Bellasiecccdb72016-01-14 18:43:37 +00001474/*
1475 * Tracepoint for accounting task boosted utilization
1476 */
1477TRACE_EVENT(sched_boost_task,
Srinath Sridharane71c4252016-07-28 17:28:55 +01001478 TP_PROTO(struct task_struct *tsk, unsigned long util, long margin),
Patrick Bellasiecccdb72016-01-14 18:43:37 +00001479 TP_ARGS(tsk, util, margin),
Patrick Bellasiecccdb72016-01-14 18:43:37 +00001480 TP_STRUCT__entry(
1481 __array( char, comm, TASK_COMM_LEN )
1482 __field( pid_t, pid )
1483 __field( unsigned long, util )
Srinath Sridharane71c4252016-07-28 17:28:55 +01001484 __field( long, margin )
Patrick Bellasiecccdb72016-01-14 18:43:37 +00001485 ),
Patrick Bellasiecccdb72016-01-14 18:43:37 +00001486 TP_fast_assign(
1487 memcpy(__entry->comm, tsk->comm, TASK_COMM_LEN);
1488 __entry->pid = tsk->pid;
1489 __entry->util = util;
1490 __entry->margin = margin;
1491 ),
Srinath Sridharane71c4252016-07-28 17:28:55 +01001492 TP_printk("comm=%s pid=%d util=%lu margin=%ld",
Patrick Bellasiecccdb72016-01-14 18:43:37 +00001493 __entry->comm, __entry->pid,
1494 __entry->util,
1495 __entry->margin)
1496);
Patrick Bellasi110441b2016-01-14 18:47:21 +00001497/*
1498 * Tracepoint for accounting sched group energy
1499 */
1500TRACE_EVENT(sched_energy_diff,
Patrick Bellasi110441b2016-01-14 18:47:21 +00001501 TP_PROTO(struct task_struct *tsk, int scpu, int dcpu, int udelta,
1502 int nrgb, int nrga, int nrgd, int capb, int capa, int capd,
1503 int nrgn, int nrgp),
Patrick Bellasi110441b2016-01-14 18:47:21 +00001504 TP_ARGS(tsk, scpu, dcpu, udelta,
1505 nrgb, nrga, nrgd, capb, capa, capd,
1506 nrgn, nrgp),
Patrick Bellasi110441b2016-01-14 18:47:21 +00001507 TP_STRUCT__entry(
1508 __array( char, comm, TASK_COMM_LEN )
1509 __field( pid_t, pid )
1510 __field( int, scpu )
1511 __field( int, dcpu )
1512 __field( int, udelta )
1513 __field( int, nrgb )
1514 __field( int, nrga )
1515 __field( int, nrgd )
1516 __field( int, capb )
1517 __field( int, capa )
1518 __field( int, capd )
1519 __field( int, nrgn )
1520 __field( int, nrgp )
1521 ),
Patrick Bellasi110441b2016-01-14 18:47:21 +00001522 TP_fast_assign(
1523 memcpy(__entry->comm, tsk->comm, TASK_COMM_LEN);
1524 __entry->pid = tsk->pid;
1525 __entry->scpu = scpu;
1526 __entry->dcpu = dcpu;
1527 __entry->udelta = udelta;
1528 __entry->nrgb = nrgb;
1529 __entry->nrga = nrga;
1530 __entry->nrgd = nrgd;
1531 __entry->capb = capb;
1532 __entry->capa = capa;
1533 __entry->capd = capd;
1534 __entry->nrgn = nrgn;
1535 __entry->nrgp = nrgp;
1536 ),
Patrick Bellasi110441b2016-01-14 18:47:21 +00001537 TP_printk("pid=%d comm=%s "
1538 "src_cpu=%d dst_cpu=%d usage_delta=%d "
1539 "nrg_before=%d nrg_after=%d nrg_diff=%d "
1540 "cap_before=%d cap_after=%d cap_delta=%d "
1541 "nrg_delta=%d nrg_payoff=%d",
1542 __entry->pid, __entry->comm,
1543 __entry->scpu, __entry->dcpu, __entry->udelta,
1544 __entry->nrgb, __entry->nrga, __entry->nrgd,
1545 __entry->capb, __entry->capa, __entry->capd,
1546 __entry->nrgn, __entry->nrgp)
1547);
Patrick Bellasi5824d982016-01-20 14:06:05 +00001548/*
1549 * Tracepoint for schedtune_tasks_update
1550 */
1551TRACE_EVENT(sched_tune_filter,
Patrick Bellasi5824d982016-01-20 14:06:05 +00001552 TP_PROTO(int nrg_delta, int cap_delta,
1553 int nrg_gain, int cap_gain,
1554 int payoff, int region),
Patrick Bellasi5824d982016-01-20 14:06:05 +00001555 TP_ARGS(nrg_delta, cap_delta, nrg_gain, cap_gain, payoff, region),
Patrick Bellasi5824d982016-01-20 14:06:05 +00001556 TP_STRUCT__entry(
1557 __field( int, nrg_delta )
1558 __field( int, cap_delta )
1559 __field( int, nrg_gain )
1560 __field( int, cap_gain )
1561 __field( int, payoff )
1562 __field( int, region )
1563 ),
Patrick Bellasi5824d982016-01-20 14:06:05 +00001564 TP_fast_assign(
1565 __entry->nrg_delta = nrg_delta;
1566 __entry->cap_delta = cap_delta;
1567 __entry->nrg_gain = nrg_gain;
1568 __entry->cap_gain = cap_gain;
1569 __entry->payoff = payoff;
1570 __entry->region = region;
1571 ),
Patrick Bellasi5824d982016-01-20 14:06:05 +00001572 TP_printk("nrg_delta=%d cap_delta=%d nrg_gain=%d cap_gain=%d payoff=%d region=%d",
1573 __entry->nrg_delta, __entry->cap_delta,
1574 __entry->nrg_gain, __entry->cap_gain,
1575 __entry->payoff, __entry->region)
1576);
Patrick Bellasi8e45d942016-02-10 09:24:36 +00001577/*
1578 * Tracepoint for system overutilized flag
1579 */
1580TRACE_EVENT(sched_overutilized,
Patrick Bellasi8e45d942016-02-10 09:24:36 +00001581 TP_PROTO(bool overutilized),
Patrick Bellasi8e45d942016-02-10 09:24:36 +00001582 TP_ARGS(overutilized),
Patrick Bellasi8e45d942016-02-10 09:24:36 +00001583 TP_STRUCT__entry(
1584 __field( bool, overutilized )
1585 ),
Patrick Bellasi8e45d942016-02-10 09:24:36 +00001586 TP_fast_assign(
1587 __entry->overutilized = overutilized;
1588 ),
Patrick Bellasi8e45d942016-02-10 09:24:36 +00001589 TP_printk("overutilized=%d",
1590 __entry->overutilized ? 1 : 0)
1591);
Jeevan Shriram49f575e2017-03-02 16:52:44 -08001592#endif
Srivatsa Vaddagiri26c21542016-05-31 09:08:38 -07001593
Syed Rameez Mustafadddcab72016-09-07 16:18:27 -07001594TRACE_EVENT(sched_get_nr_running_avg,
1595
1596 TP_PROTO(int avg, int big_avg, int iowait_avg),
1597
1598 TP_ARGS(avg, big_avg, iowait_avg),
1599
1600 TP_STRUCT__entry(
1601 __field( int, avg )
1602 __field( int, big_avg )
1603 __field( int, iowait_avg )
1604 ),
1605
1606 TP_fast_assign(
1607 __entry->avg = avg;
1608 __entry->big_avg = big_avg;
1609 __entry->iowait_avg = iowait_avg;
1610 ),
1611
1612 TP_printk("avg=%d big_avg=%d iowait_avg=%d",
1613 __entry->avg, __entry->big_avg, __entry->iowait_avg)
1614);
Olav Haugan39432ea2016-06-12 13:57:05 -07001615
Olav Haugan09bcc682016-09-02 17:12:20 -07001616TRACE_EVENT(core_ctl_eval_need,
1617
1618 TP_PROTO(unsigned int cpu, unsigned int old_need,
1619 unsigned int new_need, unsigned int updated),
1620 TP_ARGS(cpu, old_need, new_need, updated),
1621 TP_STRUCT__entry(
1622 __field(u32, cpu)
1623 __field(u32, old_need)
1624 __field(u32, new_need)
1625 __field(u32, updated)
1626 ),
1627 TP_fast_assign(
1628 __entry->cpu = cpu;
1629 __entry->old_need = old_need;
1630 __entry->new_need = new_need;
1631 __entry->updated = updated;
1632 ),
1633 TP_printk("cpu=%u, old_need=%u, new_need=%u, updated=%u", __entry->cpu,
1634 __entry->old_need, __entry->new_need, __entry->updated)
1635);
1636
1637TRACE_EVENT(core_ctl_set_busy,
1638
1639 TP_PROTO(unsigned int cpu, unsigned int busy,
1640 unsigned int old_is_busy, unsigned int is_busy),
1641 TP_ARGS(cpu, busy, old_is_busy, is_busy),
1642 TP_STRUCT__entry(
1643 __field(u32, cpu)
1644 __field(u32, busy)
1645 __field(u32, old_is_busy)
1646 __field(u32, is_busy)
1647 ),
1648 TP_fast_assign(
1649 __entry->cpu = cpu;
1650 __entry->busy = busy;
1651 __entry->old_is_busy = old_is_busy;
1652 __entry->is_busy = is_busy;
1653 ),
1654 TP_printk("cpu=%u, busy=%u, old_is_busy=%u, new_is_busy=%u",
1655 __entry->cpu, __entry->busy, __entry->old_is_busy,
1656 __entry->is_busy)
1657);
1658
Olav Haugana024f472016-10-13 10:34:11 -07001659TRACE_EVENT(core_ctl_set_boost,
1660
1661 TP_PROTO(u32 refcount, s32 ret),
1662 TP_ARGS(refcount, ret),
1663 TP_STRUCT__entry(
1664 __field(u32, refcount)
1665 __field(s32, ret)
1666 ),
1667 TP_fast_assign(
1668 __entry->refcount = refcount;
1669 __entry->ret = ret;
1670 ),
1671 TP_printk("refcount=%u, ret=%d", __entry->refcount, __entry->ret)
1672);
1673
Olav Haugan39432ea2016-06-12 13:57:05 -07001674/*
1675 * sched_isolate - called when cores are isolated/unisolated
1676 *
1677 * @acutal_mask: mask of cores actually isolated/unisolated
1678 * @req_mask: mask of cores requested isolated/unisolated
1679 * @online_mask: cpu online mask
1680 * @time: amount of time in us it took to isolate/unisolate
1681 * @isolate: 1 if isolating, 0 if unisolating
1682 *
1683 */
1684TRACE_EVENT(sched_isolate,
1685
1686 TP_PROTO(unsigned int requested_cpu, unsigned int isolated_cpus,
1687 u64 start_time, unsigned char isolate),
1688
1689 TP_ARGS(requested_cpu, isolated_cpus, start_time, isolate),
1690
1691 TP_STRUCT__entry(
1692 __field(u32, requested_cpu)
1693 __field(u32, isolated_cpus)
1694 __field(u32, time)
1695 __field(unsigned char, isolate)
1696 ),
1697
1698 TP_fast_assign(
1699 __entry->requested_cpu = requested_cpu;
1700 __entry->isolated_cpus = isolated_cpus;
1701 __entry->time = div64_u64(sched_clock() - start_time, 1000);
1702 __entry->isolate = isolate;
1703 ),
1704
1705 TP_printk("iso cpu=%u cpus=0x%x time=%u us isolated=%d",
1706 __entry->requested_cpu, __entry->isolated_cpus,
1707 __entry->time, __entry->isolate)
1708);
Steven Rostedtea20d922009-04-10 08:54:16 -04001709#endif /* _TRACE_SCHED_H */
Steven Rostedta8d154b2009-04-10 09:36:00 -04001710
1711/* This part must be outside protection */
1712#include <trace/define_trace.h>