blob: ba2b0bacdb377b568d1d4ae097459d4963dc3545 [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
Joonwoo Parkcc7d1272017-01-26 14:47:00 -0800699#ifdef CONFIG_SMP
700TRACE_EVENT(sched_cpu_util,
701
Joonwoo Park449182f2017-01-30 21:04:36 -0800702 TP_PROTO(struct task_struct *p, int cpu, int task_util, unsigned long curr_util, int sync),
Joonwoo Parkcc7d1272017-01-26 14:47:00 -0800703
Joonwoo Park449182f2017-01-30 21:04:36 -0800704 TP_ARGS(p, cpu, task_util, curr_util, sync),
Joonwoo Parkcc7d1272017-01-26 14:47:00 -0800705
706 TP_STRUCT__entry(
707 __array(char, comm, TASK_COMM_LEN )
708 __field(int, pid )
709 __field(unsigned int, cpu )
710 __field(int, task_util )
711 __field(unsigned int, nr_running )
712 __field(long, cpu_util )
713 __field(unsigned int, capacity_curr )
714 __field(unsigned int, capacity )
Joonwoo Park449182f2017-01-30 21:04:36 -0800715 __field(unsigned long, curr_util )
Joonwoo Parkcc7d1272017-01-26 14:47:00 -0800716 __field(int, sync )
717 __field(int, idle_state )
Joonwoo Park7b211a42017-01-31 18:26:42 -0800718 __field(unsigned int, irqload )
719 __field(int, high_irqload )
Joonwoo Parkcc7d1272017-01-26 14:47:00 -0800720 ),
721
722 TP_fast_assign(
723 memcpy(__entry->comm, p->comm, TASK_COMM_LEN);
724 __entry->pid = p->pid;
725 __entry->cpu = cpu;
726 __entry->task_util = task_util;
727 __entry->nr_running = cpu_rq(cpu)->nr_running;
728 __entry->cpu_util = cpu_util(cpu);
729 __entry->capacity_curr = capacity_curr_of(cpu);
730 __entry->capacity = capacity_of(cpu);
Joonwoo Park449182f2017-01-30 21:04:36 -0800731 __entry->curr_util = curr_util;
Joonwoo Parkcc7d1272017-01-26 14:47:00 -0800732 __entry->sync = sync;
733 __entry->idle_state = idle_get_state_idx(cpu_rq(cpu));
Joonwoo Park7b211a42017-01-31 18:26:42 -0800734 __entry->irqload = sched_irqload(cpu);
735 __entry->high_irqload = sched_cpu_high_irqload(cpu);
Joonwoo Parkcc7d1272017-01-26 14:47:00 -0800736 ),
737
Joonwoo Park7b211a42017-01-31 18:26:42 -0800738 TP_printk("comm=%s pid=%d cpu=%d task_util=%d nr_running=%d cpu_util=%ld capacity_curr=%u capacity=%u curr_util=%ld sync=%d idle_state=%d irqload=%u high_irqload=%u",
739 __entry->comm, __entry->pid, __entry->cpu, __entry->task_util, __entry->nr_running, __entry->cpu_util, __entry->capacity_curr, __entry->capacity, __entry->curr_util, __entry->sync, __entry->idle_state, __entry->irqload, __entry->high_irqload)
Joonwoo Parkcc7d1272017-01-26 14:47:00 -0800740);
741
742DECLARE_EVENT_CLASS(sched_task_util,
743
744 TP_PROTO(struct task_struct *p, int task_cpu, unsigned long task_util, int nominated_cpu, int target_cpu, int ediff),
745
746 TP_ARGS(p, task_cpu, task_util, nominated_cpu, target_cpu, ediff),
747
748 TP_STRUCT__entry(
749 __array(char, comm, TASK_COMM_LEN )
750 __field(int, pid )
751 __field(int, task_cpu )
752 __field(unsigned long, task_util )
753 __field(unsigned long, cpu_util_freq )
754 __field(int, nominated_cpu )
755 __field(int, target_cpu )
756 __field(int, ediff )
757 ),
758
759 TP_fast_assign(
760 memcpy(__entry->comm, p->comm, TASK_COMM_LEN);
761 __entry->pid = p->pid;
762 __entry->task_cpu = task_cpu;
763 __entry->task_util = task_util;
764 __entry->cpu_util_freq = cpu_util_freq(target_cpu, NULL);
765 __entry->nominated_cpu = nominated_cpu;
766 __entry->target_cpu = target_cpu;
767 __entry->ediff = ediff;
768 ),
769
770 TP_printk("comm=%s pid=%d task_cpu=%d task_util=%lu nominated_cpu=%d target_cpu=%d energy_diff=%d",
771 __entry->comm, __entry->pid, __entry->task_cpu, __entry->task_util, __entry->nominated_cpu, __entry->target_cpu, __entry->ediff)
772);
773
774DEFINE_EVENT(sched_task_util, sched_task_util_overutilzed,
775 TP_PROTO(struct task_struct *p, int task_cpu, unsigned long task_util, int nominated_cpu, int target_cpu, int ediff),
Joonwoo Park2ae888b2017-01-12 17:46:00 -0800776 TP_ARGS(p, task_cpu, task_util, nominated_cpu, target_cpu, ediff)
Joonwoo Parkcc7d1272017-01-26 14:47:00 -0800777);
778
779DEFINE_EVENT(sched_task_util, sched_task_util_energy_diff,
780 TP_PROTO(struct task_struct *p, int task_cpu, unsigned long task_util, int nominated_cpu, int target_cpu, int ediff),
Joonwoo Park2ae888b2017-01-12 17:46:00 -0800781 TP_ARGS(p, task_cpu, task_util, nominated_cpu, target_cpu, ediff)
Joonwoo Parkcc7d1272017-01-26 14:47:00 -0800782);
783
784DEFINE_EVENT(sched_task_util, sched_task_util_energy_aware,
785 TP_PROTO(struct task_struct *p, int task_cpu, unsigned long task_util, int nominated_cpu, int target_cpu, int ediff),
Joonwoo Park2ae888b2017-01-12 17:46:00 -0800786 TP_ARGS(p, task_cpu, task_util, nominated_cpu, target_cpu, ediff)
Joonwoo Parkcc7d1272017-01-26 14:47:00 -0800787);
788#endif
789
Syed Rameez Mustafadddcab72016-09-07 16:18:27 -0700790/*
Steven Rostedtea20d922009-04-10 08:54:16 -0400791 * Tracepoint for waking up a task:
Steven Rostedtea20d922009-04-10 08:54:16 -0400792 */
Ingo Molnar091ad362009-11-26 09:04:55 +0100793DECLARE_EVENT_CLASS(sched_wakeup_template,
Steven Rostedtea20d922009-04-10 08:54:16 -0400794
Peter Zijlstrafbd705a2015-06-09 11:13:36 +0200795 TP_PROTO(struct task_struct *p),
Steven Rostedtea20d922009-04-10 08:54:16 -0400796
Peter Zijlstrafbd705a2015-06-09 11:13:36 +0200797 TP_ARGS(__perf_task(p)),
Steven Rostedtea20d922009-04-10 08:54:16 -0400798
799 TP_STRUCT__entry(
800 __array( char, comm, TASK_COMM_LEN )
801 __field( pid_t, pid )
802 __field( int, prio )
803 __field( int, success )
Ingo Molnar434a83c2009-10-15 11:50:39 +0200804 __field( int, target_cpu )
Steven Rostedtea20d922009-04-10 08:54:16 -0400805 ),
806
807 TP_fast_assign(
808 memcpy(__entry->comm, p->comm, TASK_COMM_LEN);
809 __entry->pid = p->pid;
810 __entry->prio = p->prio;
Peter Zijlstrafbd705a2015-06-09 11:13:36 +0200811 __entry->success = 1; /* rudiment, kill when possible */
Ingo Molnar434a83c2009-10-15 11:50:39 +0200812 __entry->target_cpu = task_cpu(p);
Steven Rostedtea20d922009-04-10 08:54:16 -0400813 ),
814
Peter Zijlstrafbd705a2015-06-09 11:13:36 +0200815 TP_printk("comm=%s pid=%d prio=%d target_cpu=%03d",
Steven Rostedtea20d922009-04-10 08:54:16 -0400816 __entry->comm, __entry->pid, __entry->prio,
Peter Zijlstrafbd705a2015-06-09 11:13:36 +0200817 __entry->target_cpu)
Steven Rostedtea20d922009-04-10 08:54:16 -0400818);
819
Peter Zijlstrafbd705a2015-06-09 11:13:36 +0200820/*
821 * Tracepoint called when waking a task; this tracepoint is guaranteed to be
822 * called from the waking context.
823 */
824DEFINE_EVENT(sched_wakeup_template, sched_waking,
825 TP_PROTO(struct task_struct *p),
826 TP_ARGS(p));
827
828/*
829 * Tracepoint called when the task is actually woken; p->state == TASK_RUNNNG.
830 * It it not always called from the waking context.
831 */
Steven Rostedt75ec29a2009-11-18 20:48:08 -0500832DEFINE_EVENT(sched_wakeup_template, sched_wakeup,
Peter Zijlstrafbd705a2015-06-09 11:13:36 +0200833 TP_PROTO(struct task_struct *p),
834 TP_ARGS(p));
Steven Rostedt75ec29a2009-11-18 20:48:08 -0500835
Steven Rostedtea20d922009-04-10 08:54:16 -0400836/*
837 * Tracepoint for waking up a new task:
Steven Rostedtea20d922009-04-10 08:54:16 -0400838 */
Steven Rostedt75ec29a2009-11-18 20:48:08 -0500839DEFINE_EVENT(sched_wakeup_template, sched_wakeup_new,
Peter Zijlstrafbd705a2015-06-09 11:13:36 +0200840 TP_PROTO(struct task_struct *p),
841 TP_ARGS(p));
Steven Rostedtea20d922009-04-10 08:54:16 -0400842
Peter Zijlstra02f72692010-05-31 18:13:25 +0200843#ifdef CREATE_TRACE_POINTS
Peter Zijlstrac73464b2015-09-28 18:06:56 +0200844static inline long __trace_sched_switch_state(bool preempt, struct task_struct *p)
Peter Zijlstra02f72692010-05-31 18:13:25 +0200845{
Oleg Nesterov8f9fbf02014-10-07 21:51:08 +0200846#ifdef CONFIG_SCHED_DEBUG
847 BUG_ON(p != current);
848#endif /* CONFIG_SCHED_DEBUG */
Peter Zijlstra02f72692010-05-31 18:13:25 +0200849
Peter Zijlstrac73464b2015-09-28 18:06:56 +0200850 /*
851 * Preemption ignores task state, therefore preempted tasks are always
852 * RUNNING (we will not have dequeued if state != RUNNING).
853 */
854 return preempt ? TASK_RUNNING | TASK_STATE_MAX : p->state;
Peter Zijlstra02f72692010-05-31 18:13:25 +0200855}
Oleg Nesterov8f9fbf02014-10-07 21:51:08 +0200856#endif /* CREATE_TRACE_POINTS */
Peter Zijlstra02f72692010-05-31 18:13:25 +0200857
Steven Rostedtea20d922009-04-10 08:54:16 -0400858/*
859 * Tracepoint for task switches, performed by the scheduler:
Steven Rostedtea20d922009-04-10 08:54:16 -0400860 */
861TRACE_EVENT(sched_switch,
862
Peter Zijlstrac73464b2015-09-28 18:06:56 +0200863 TP_PROTO(bool preempt,
864 struct task_struct *prev,
Steven Rostedtea20d922009-04-10 08:54:16 -0400865 struct task_struct *next),
866
Peter Zijlstrac73464b2015-09-28 18:06:56 +0200867 TP_ARGS(preempt, prev, next),
Steven Rostedtea20d922009-04-10 08:54:16 -0400868
869 TP_STRUCT__entry(
870 __array( char, prev_comm, TASK_COMM_LEN )
871 __field( pid_t, prev_pid )
872 __field( int, prev_prio )
Steven Rostedt937cdb92009-05-15 10:51:13 -0400873 __field( long, prev_state )
Steven Rostedtea20d922009-04-10 08:54:16 -0400874 __array( char, next_comm, TASK_COMM_LEN )
875 __field( pid_t, next_pid )
876 __field( int, next_prio )
877 ),
878
879 TP_fast_assign(
880 memcpy(__entry->next_comm, next->comm, TASK_COMM_LEN);
881 __entry->prev_pid = prev->pid;
882 __entry->prev_prio = prev->prio;
Peter Zijlstrac73464b2015-09-28 18:06:56 +0200883 __entry->prev_state = __trace_sched_switch_state(preempt, prev);
Steven Rostedtea20d922009-04-10 08:54:16 -0400884 memcpy(__entry->prev_comm, prev->comm, TASK_COMM_LEN);
885 __entry->next_pid = next->pid;
886 __entry->next_prio = next->prio;
887 ),
888
Peter Zijlstra557ab422011-09-16 11:16:43 +0200889 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 -0400890 __entry->prev_comm, __entry->prev_pid, __entry->prev_prio,
Peter Zijlstra557ab422011-09-16 11:16:43 +0200891 __entry->prev_state & (TASK_STATE_MAX-1) ?
892 __print_flags(__entry->prev_state & (TASK_STATE_MAX-1), "|",
Steven Rostedt937cdb92009-05-15 10:51:13 -0400893 { 1, "S"} , { 2, "D" }, { 4, "T" }, { 8, "t" },
894 { 16, "Z" }, { 32, "X" }, { 64, "x" },
Peter Zijlstra80ed87c2015-05-08 14:23:45 +0200895 { 128, "K" }, { 256, "W" }, { 512, "P" },
896 { 1024, "N" }) : "R",
Peter Zijlstra557ab422011-09-16 11:16:43 +0200897 __entry->prev_state & TASK_STATE_MAX ? "+" : "",
Steven Rostedtea20d922009-04-10 08:54:16 -0400898 __entry->next_comm, __entry->next_pid, __entry->next_prio)
899);
900
901/*
902 * Tracepoint for a task being migrated:
903 */
904TRACE_EVENT(sched_migrate_task,
905
Syed Rameez Mustafadddcab72016-09-07 16:18:27 -0700906 TP_PROTO(struct task_struct *p, int dest_cpu, unsigned int load),
Steven Rostedtea20d922009-04-10 08:54:16 -0400907
Syed Rameez Mustafadddcab72016-09-07 16:18:27 -0700908 TP_ARGS(p, dest_cpu, load),
Steven Rostedtea20d922009-04-10 08:54:16 -0400909
910 TP_STRUCT__entry(
911 __array( char, comm, TASK_COMM_LEN )
912 __field( pid_t, pid )
913 __field( int, prio )
Syed Rameez Mustafadddcab72016-09-07 16:18:27 -0700914 __field(unsigned int, load )
Steven Rostedtea20d922009-04-10 08:54:16 -0400915 __field( int, orig_cpu )
916 __field( int, dest_cpu )
917 ),
918
919 TP_fast_assign(
920 memcpy(__entry->comm, p->comm, TASK_COMM_LEN);
921 __entry->pid = p->pid;
922 __entry->prio = p->prio;
Syed Rameez Mustafadddcab72016-09-07 16:18:27 -0700923 __entry->load = load;
Mathieu Desnoyersde1d7282009-05-05 16:49:59 +0800924 __entry->orig_cpu = task_cpu(p);
Steven Rostedtea20d922009-04-10 08:54:16 -0400925 __entry->dest_cpu = dest_cpu;
926 ),
927
Syed Rameez Mustafadddcab72016-09-07 16:18:27 -0700928 TP_printk("comm=%s pid=%d prio=%d load=%d orig_cpu=%d dest_cpu=%d",
929 __entry->comm, __entry->pid, __entry->prio, __entry->load,
Steven Rostedtea20d922009-04-10 08:54:16 -0400930 __entry->orig_cpu, __entry->dest_cpu)
931);
932
Syed Rameez Mustafadddcab72016-09-07 16:18:27 -0700933/*
934 * Tracepoint for a CPU going offline/online:
935 */
936TRACE_EVENT(sched_cpu_hotplug,
937
938 TP_PROTO(int affected_cpu, int error, int status),
939
940 TP_ARGS(affected_cpu, error, status),
941
942 TP_STRUCT__entry(
943 __field( int, affected_cpu )
944 __field( int, error )
945 __field( int, status )
946 ),
947
948 TP_fast_assign(
949 __entry->affected_cpu = affected_cpu;
950 __entry->error = error;
951 __entry->status = status;
952 ),
953
954 TP_printk("cpu %d %s error=%d", __entry->affected_cpu,
955 __entry->status ? "online" : "offline", __entry->error)
956);
957
958/*
959 * Tracepoint for load balancing:
960 */
961#if NR_CPUS > 32
962#error "Unsupported NR_CPUS for lb tracepoint."
963#endif
964TRACE_EVENT(sched_load_balance,
965
966 TP_PROTO(int cpu, enum cpu_idle_type idle, int balance,
967 unsigned long group_mask, int busiest_nr_running,
968 unsigned long imbalance, unsigned int env_flags, int ld_moved,
969 unsigned int balance_interval),
970
971 TP_ARGS(cpu, idle, balance, group_mask, busiest_nr_running,
972 imbalance, env_flags, ld_moved, balance_interval),
973
974 TP_STRUCT__entry(
975 __field( int, cpu)
976 __field( enum cpu_idle_type, idle)
977 __field( int, balance)
978 __field( unsigned long, group_mask)
979 __field( int, busiest_nr_running)
980 __field( unsigned long, imbalance)
981 __field( unsigned int, env_flags)
982 __field( int, ld_moved)
983 __field( unsigned int, balance_interval)
984 ),
985
986 TP_fast_assign(
987 __entry->cpu = cpu;
988 __entry->idle = idle;
989 __entry->balance = balance;
990 __entry->group_mask = group_mask;
991 __entry->busiest_nr_running = busiest_nr_running;
992 __entry->imbalance = imbalance;
993 __entry->env_flags = env_flags;
994 __entry->ld_moved = ld_moved;
995 __entry->balance_interval = balance_interval;
996 ),
997
998 TP_printk("cpu=%d state=%s balance=%d group=%#lx busy_nr=%d imbalance=%ld flags=%#x ld_moved=%d bal_int=%d",
999 __entry->cpu,
1000 __entry->idle == CPU_IDLE ? "idle" :
1001 (__entry->idle == CPU_NEWLY_IDLE ? "newly_idle" : "busy"),
1002 __entry->balance,
1003 __entry->group_mask, __entry->busiest_nr_running,
1004 __entry->imbalance, __entry->env_flags, __entry->ld_moved,
1005 __entry->balance_interval)
1006);
1007
Ingo Molnar091ad362009-11-26 09:04:55 +01001008DECLARE_EVENT_CLASS(sched_process_template,
Steven Rostedtea20d922009-04-10 08:54:16 -04001009
1010 TP_PROTO(struct task_struct *p),
1011
1012 TP_ARGS(p),
1013
1014 TP_STRUCT__entry(
1015 __array( char, comm, TASK_COMM_LEN )
1016 __field( pid_t, pid )
1017 __field( int, prio )
1018 ),
1019
1020 TP_fast_assign(
1021 memcpy(__entry->comm, p->comm, TASK_COMM_LEN);
1022 __entry->pid = p->pid;
1023 __entry->prio = p->prio;
1024 ),
1025
Ingo Molnar434a83c2009-10-15 11:50:39 +02001026 TP_printk("comm=%s pid=%d prio=%d",
Steven Rostedtea20d922009-04-10 08:54:16 -04001027 __entry->comm, __entry->pid, __entry->prio)
1028);
1029
1030/*
Steven Rostedt75ec29a2009-11-18 20:48:08 -05001031 * Tracepoint for freeing a task:
1032 */
1033DEFINE_EVENT(sched_process_template, sched_process_free,
1034 TP_PROTO(struct task_struct *p),
1035 TP_ARGS(p));
Riley Andrews9de15b42015-10-02 00:39:53 -07001036
Steven Rostedt75ec29a2009-11-18 20:48:08 -05001037
1038/*
Steven Rostedtea20d922009-04-10 08:54:16 -04001039 * Tracepoint for a task exiting:
1040 */
Steven Rostedt75ec29a2009-11-18 20:48:08 -05001041DEFINE_EVENT(sched_process_template, sched_process_exit,
1042 TP_PROTO(struct task_struct *p),
1043 TP_ARGS(p));
Steven Rostedtea20d922009-04-10 08:54:16 -04001044
1045/*
Li Zefan210f7662010-05-24 16:23:35 +08001046 * Tracepoint for waiting on task to unschedule:
1047 */
1048DEFINE_EVENT(sched_process_template, sched_wait_task,
1049 TP_PROTO(struct task_struct *p),
1050 TP_ARGS(p));
1051
1052/*
Steven Rostedtea20d922009-04-10 08:54:16 -04001053 * Tracepoint for a waiting task:
1054 */
1055TRACE_EVENT(sched_process_wait,
1056
1057 TP_PROTO(struct pid *pid),
1058
1059 TP_ARGS(pid),
1060
1061 TP_STRUCT__entry(
1062 __array( char, comm, TASK_COMM_LEN )
1063 __field( pid_t, pid )
1064 __field( int, prio )
1065 ),
1066
1067 TP_fast_assign(
1068 memcpy(__entry->comm, current->comm, TASK_COMM_LEN);
1069 __entry->pid = pid_nr(pid);
1070 __entry->prio = current->prio;
1071 ),
1072
Ingo Molnar434a83c2009-10-15 11:50:39 +02001073 TP_printk("comm=%s pid=%d prio=%d",
Steven Rostedtea20d922009-04-10 08:54:16 -04001074 __entry->comm, __entry->pid, __entry->prio)
1075);
1076
1077/*
1078 * Tracepoint for do_fork:
1079 */
1080TRACE_EVENT(sched_process_fork,
1081
1082 TP_PROTO(struct task_struct *parent, struct task_struct *child),
1083
1084 TP_ARGS(parent, child),
1085
1086 TP_STRUCT__entry(
1087 __array( char, parent_comm, TASK_COMM_LEN )
1088 __field( pid_t, parent_pid )
1089 __array( char, child_comm, TASK_COMM_LEN )
1090 __field( pid_t, child_pid )
1091 ),
1092
1093 TP_fast_assign(
1094 memcpy(__entry->parent_comm, parent->comm, TASK_COMM_LEN);
1095 __entry->parent_pid = parent->pid;
1096 memcpy(__entry->child_comm, child->comm, TASK_COMM_LEN);
1097 __entry->child_pid = child->pid;
1098 ),
1099
Ingo Molnar434a83c2009-10-15 11:50:39 +02001100 TP_printk("comm=%s pid=%d child_comm=%s child_pid=%d",
Steven Rostedtea20d922009-04-10 08:54:16 -04001101 __entry->parent_comm, __entry->parent_pid,
1102 __entry->child_comm, __entry->child_pid)
1103);
1104
1105/*
David Smith4ff16c22012-02-07 10:11:05 -06001106 * Tracepoint for exec:
1107 */
1108TRACE_EVENT(sched_process_exec,
1109
1110 TP_PROTO(struct task_struct *p, pid_t old_pid,
1111 struct linux_binprm *bprm),
1112
1113 TP_ARGS(p, old_pid, bprm),
1114
1115 TP_STRUCT__entry(
1116 __string( filename, bprm->filename )
1117 __field( pid_t, pid )
1118 __field( pid_t, old_pid )
1119 ),
1120
1121 TP_fast_assign(
1122 __assign_str(filename, bprm->filename);
1123 __entry->pid = p->pid;
Oleg Nesterov63081912012-03-30 18:26:36 +02001124 __entry->old_pid = old_pid;
David Smith4ff16c22012-02-07 10:11:05 -06001125 ),
1126
1127 TP_printk("filename=%s pid=%d old_pid=%d", __get_str(filename),
1128 __entry->pid, __entry->old_pid)
1129);
1130
1131/*
Peter Zijlstra768d0c22009-07-23 20:13:26 +02001132 * XXX the below sched_stat tracepoints only apply to SCHED_OTHER/BATCH/IDLE
1133 * adding sched_stat support to SCHED_FIFO/RR would be welcome.
1134 */
Ingo Molnar091ad362009-11-26 09:04:55 +01001135DECLARE_EVENT_CLASS(sched_stat_template,
Peter Zijlstra768d0c22009-07-23 20:13:26 +02001136
1137 TP_PROTO(struct task_struct *tsk, u64 delay),
1138
Oleg Nesterov12473962013-08-06 18:08:44 +02001139 TP_ARGS(__perf_task(tsk), __perf_count(delay)),
Peter Zijlstra768d0c22009-07-23 20:13:26 +02001140
1141 TP_STRUCT__entry(
1142 __array( char, comm, TASK_COMM_LEN )
1143 __field( pid_t, pid )
1144 __field( u64, delay )
1145 ),
1146
1147 TP_fast_assign(
1148 memcpy(__entry->comm, tsk->comm, TASK_COMM_LEN);
1149 __entry->pid = tsk->pid;
1150 __entry->delay = delay;
Peter Zijlstra768d0c22009-07-23 20:13:26 +02001151 ),
1152
Ingo Molnar434a83c2009-10-15 11:50:39 +02001153 TP_printk("comm=%s pid=%d delay=%Lu [ns]",
Peter Zijlstra768d0c22009-07-23 20:13:26 +02001154 __entry->comm, __entry->pid,
1155 (unsigned long long)__entry->delay)
1156);
1157
Steven Rostedt75ec29a2009-11-18 20:48:08 -05001158
1159/*
1160 * Tracepoint for accounting wait time (time the task is runnable
1161 * but not actually running due to scheduler contention).
1162 */
1163DEFINE_EVENT(sched_stat_template, sched_stat_wait,
1164 TP_PROTO(struct task_struct *tsk, u64 delay),
1165 TP_ARGS(tsk, delay));
1166
1167/*
1168 * Tracepoint for accounting sleep time (time the task is not runnable,
1169 * including iowait, see below).
1170 */
Li Zefan470dda742009-11-26 15:08:01 +08001171DEFINE_EVENT(sched_stat_template, sched_stat_sleep,
1172 TP_PROTO(struct task_struct *tsk, u64 delay),
1173 TP_ARGS(tsk, delay));
Steven Rostedt75ec29a2009-11-18 20:48:08 -05001174
1175/*
1176 * Tracepoint for accounting iowait time (time the task is not runnable
1177 * due to waiting on IO to complete).
1178 */
Li Zefan470dda742009-11-26 15:08:01 +08001179DEFINE_EVENT(sched_stat_template, sched_stat_iowait,
1180 TP_PROTO(struct task_struct *tsk, u64 delay),
1181 TP_ARGS(tsk, delay));
Steven Rostedt75ec29a2009-11-18 20:48:08 -05001182
Peter Zijlstra768d0c22009-07-23 20:13:26 +02001183/*
Andrew Vaginb781a602011-11-28 12:03:35 +03001184 * Tracepoint for accounting blocked time (time the task is in uninterruptible).
1185 */
1186DEFINE_EVENT(sched_stat_template, sched_stat_blocked,
1187 TP_PROTO(struct task_struct *tsk, u64 delay),
1188 TP_ARGS(tsk, delay));
1189
1190/*
Riley Andrews9de15b42015-10-02 00:39:53 -07001191 * Tracepoint for recording the cause of uninterruptible sleep.
1192 */
1193TRACE_EVENT(sched_blocked_reason,
1194
1195 TP_PROTO(struct task_struct *tsk),
1196
1197 TP_ARGS(tsk),
1198
1199 TP_STRUCT__entry(
1200 __field( pid_t, pid )
1201 __field( void*, caller )
1202 __field( bool, io_wait )
1203 ),
1204
1205 TP_fast_assign(
1206 __entry->pid = tsk->pid;
1207 __entry->caller = (void*)get_wchan(tsk);
1208 __entry->io_wait = tsk->in_iowait;
1209 ),
1210
1211 TP_printk("pid=%d iowait=%d caller=%pS", __entry->pid, __entry->io_wait, __entry->caller)
1212);
1213
1214/*
Ingo Molnarf977bb42009-09-13 18:15:54 +02001215 * Tracepoint for accounting runtime (time the task is executing
1216 * on a CPU).
1217 */
Oleg Nesterov36009d072013-08-06 18:08:41 +02001218DECLARE_EVENT_CLASS(sched_stat_runtime,
Ingo Molnarf977bb42009-09-13 18:15:54 +02001219
1220 TP_PROTO(struct task_struct *tsk, u64 runtime, u64 vruntime),
1221
Oleg Nesterov12473962013-08-06 18:08:44 +02001222 TP_ARGS(tsk, __perf_count(runtime), vruntime),
Ingo Molnarf977bb42009-09-13 18:15:54 +02001223
1224 TP_STRUCT__entry(
1225 __array( char, comm, TASK_COMM_LEN )
1226 __field( pid_t, pid )
1227 __field( u64, runtime )
1228 __field( u64, vruntime )
1229 ),
1230
1231 TP_fast_assign(
1232 memcpy(__entry->comm, tsk->comm, TASK_COMM_LEN);
1233 __entry->pid = tsk->pid;
1234 __entry->runtime = runtime;
1235 __entry->vruntime = vruntime;
Ingo Molnarf977bb42009-09-13 18:15:54 +02001236 ),
1237
Ingo Molnar434a83c2009-10-15 11:50:39 +02001238 TP_printk("comm=%s pid=%d runtime=%Lu [ns] vruntime=%Lu [ns]",
Ingo Molnarf977bb42009-09-13 18:15:54 +02001239 __entry->comm, __entry->pid,
1240 (unsigned long long)__entry->runtime,
1241 (unsigned long long)__entry->vruntime)
1242);
1243
Oleg Nesterov36009d072013-08-06 18:08:41 +02001244DEFINE_EVENT(sched_stat_runtime, sched_stat_runtime,
1245 TP_PROTO(struct task_struct *tsk, u64 runtime, u64 vruntime),
1246 TP_ARGS(tsk, runtime, vruntime));
1247
Steven Rostedta8027072010-09-20 15:13:34 -04001248/*
1249 * Tracepoint for showing priority inheritance modifying a tasks
1250 * priority.
1251 */
1252TRACE_EVENT(sched_pi_setprio,
1253
1254 TP_PROTO(struct task_struct *tsk, int newprio),
1255
1256 TP_ARGS(tsk, newprio),
1257
1258 TP_STRUCT__entry(
1259 __array( char, comm, TASK_COMM_LEN )
1260 __field( pid_t, pid )
1261 __field( int, oldprio )
1262 __field( int, newprio )
1263 ),
1264
1265 TP_fast_assign(
1266 memcpy(__entry->comm, tsk->comm, TASK_COMM_LEN);
1267 __entry->pid = tsk->pid;
1268 __entry->oldprio = tsk->prio;
1269 __entry->newprio = newprio;
1270 ),
1271
1272 TP_printk("comm=%s pid=%d oldprio=%d newprio=%d",
1273 __entry->comm, __entry->pid,
1274 __entry->oldprio, __entry->newprio)
1275);
1276
Oleg Nesterov6a716c92013-10-19 18:18:28 +02001277#ifdef CONFIG_DETECT_HUNG_TASK
1278TRACE_EVENT(sched_process_hang,
1279 TP_PROTO(struct task_struct *tsk),
1280 TP_ARGS(tsk),
1281
1282 TP_STRUCT__entry(
1283 __array( char, comm, TASK_COMM_LEN )
1284 __field( pid_t, pid )
1285 ),
1286
1287 TP_fast_assign(
1288 memcpy(__entry->comm, tsk->comm, TASK_COMM_LEN);
1289 __entry->pid = tsk->pid;
1290 ),
1291
1292 TP_printk("comm=%s pid=%d", __entry->comm, __entry->pid)
1293);
1294#endif /* CONFIG_DETECT_HUNG_TASK */
1295
Mel Gorman286549d2014-01-21 15:51:03 -08001296DECLARE_EVENT_CLASS(sched_move_task_template,
1297
1298 TP_PROTO(struct task_struct *tsk, int src_cpu, int dst_cpu),
1299
1300 TP_ARGS(tsk, src_cpu, dst_cpu),
1301
1302 TP_STRUCT__entry(
1303 __field( pid_t, pid )
1304 __field( pid_t, tgid )
1305 __field( pid_t, ngid )
1306 __field( int, src_cpu )
1307 __field( int, src_nid )
1308 __field( int, dst_cpu )
1309 __field( int, dst_nid )
1310 ),
1311
1312 TP_fast_assign(
1313 __entry->pid = task_pid_nr(tsk);
1314 __entry->tgid = task_tgid_nr(tsk);
1315 __entry->ngid = task_numa_group_id(tsk);
1316 __entry->src_cpu = src_cpu;
1317 __entry->src_nid = cpu_to_node(src_cpu);
1318 __entry->dst_cpu = dst_cpu;
1319 __entry->dst_nid = cpu_to_node(dst_cpu);
1320 ),
1321
1322 TP_printk("pid=%d tgid=%d ngid=%d src_cpu=%d src_nid=%d dst_cpu=%d dst_nid=%d",
1323 __entry->pid, __entry->tgid, __entry->ngid,
1324 __entry->src_cpu, __entry->src_nid,
1325 __entry->dst_cpu, __entry->dst_nid)
1326);
1327
1328/*
1329 * Tracks migration of tasks from one runqueue to another. Can be used to
1330 * detect if automatic NUMA balancing is bouncing between nodes
1331 */
1332DEFINE_EVENT(sched_move_task_template, sched_move_numa,
1333 TP_PROTO(struct task_struct *tsk, int src_cpu, int dst_cpu),
1334
1335 TP_ARGS(tsk, src_cpu, dst_cpu)
1336);
1337
1338DEFINE_EVENT(sched_move_task_template, sched_stick_numa,
1339 TP_PROTO(struct task_struct *tsk, int src_cpu, int dst_cpu),
1340
1341 TP_ARGS(tsk, src_cpu, dst_cpu)
1342);
1343
1344TRACE_EVENT(sched_swap_numa,
1345
1346 TP_PROTO(struct task_struct *src_tsk, int src_cpu,
1347 struct task_struct *dst_tsk, int dst_cpu),
1348
1349 TP_ARGS(src_tsk, src_cpu, dst_tsk, dst_cpu),
1350
1351 TP_STRUCT__entry(
1352 __field( pid_t, src_pid )
1353 __field( pid_t, src_tgid )
1354 __field( pid_t, src_ngid )
1355 __field( int, src_cpu )
1356 __field( int, src_nid )
1357 __field( pid_t, dst_pid )
1358 __field( pid_t, dst_tgid )
1359 __field( pid_t, dst_ngid )
1360 __field( int, dst_cpu )
1361 __field( int, dst_nid )
1362 ),
1363
1364 TP_fast_assign(
1365 __entry->src_pid = task_pid_nr(src_tsk);
1366 __entry->src_tgid = task_tgid_nr(src_tsk);
1367 __entry->src_ngid = task_numa_group_id(src_tsk);
1368 __entry->src_cpu = src_cpu;
1369 __entry->src_nid = cpu_to_node(src_cpu);
1370 __entry->dst_pid = task_pid_nr(dst_tsk);
1371 __entry->dst_tgid = task_tgid_nr(dst_tsk);
1372 __entry->dst_ngid = task_numa_group_id(dst_tsk);
1373 __entry->dst_cpu = dst_cpu;
1374 __entry->dst_nid = cpu_to_node(dst_cpu);
1375 ),
1376
1377 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",
1378 __entry->src_pid, __entry->src_tgid, __entry->src_ngid,
1379 __entry->src_cpu, __entry->src_nid,
1380 __entry->dst_pid, __entry->dst_tgid, __entry->dst_ngid,
1381 __entry->dst_cpu, __entry->dst_nid)
1382);
Andy Lutomirskidfc68f22014-06-04 10:31:15 -07001383
1384/*
1385 * Tracepoint for waking a polling cpu without an IPI.
1386 */
1387TRACE_EVENT(sched_wake_idle_without_ipi,
1388
1389 TP_PROTO(int cpu),
1390
1391 TP_ARGS(cpu),
1392
1393 TP_STRUCT__entry(
1394 __field( int, cpu )
1395 ),
1396
1397 TP_fast_assign(
1398 __entry->cpu = cpu;
1399 ),
1400
1401 TP_printk("cpu=%d", __entry->cpu)
1402);
Syed Rameez Mustafadddcab72016-09-07 16:18:27 -07001403
Juri Lelli0a942002015-11-09 12:06:24 +00001404TRACE_EVENT(sched_contrib_scale_f,
Juri Lelli0a942002015-11-09 12:06:24 +00001405 TP_PROTO(int cpu, unsigned long freq_scale_factor,
1406 unsigned long cpu_scale_factor),
Juri Lelli0a942002015-11-09 12:06:24 +00001407 TP_ARGS(cpu, freq_scale_factor, cpu_scale_factor),
Juri Lelli0a942002015-11-09 12:06:24 +00001408 TP_STRUCT__entry(
1409 __field(int, cpu)
1410 __field(unsigned long, freq_scale_factor)
1411 __field(unsigned long, cpu_scale_factor)
1412 ),
Juri Lelli0a942002015-11-09 12:06:24 +00001413 TP_fast_assign(
1414 __entry->cpu = cpu;
1415 __entry->freq_scale_factor = freq_scale_factor;
1416 __entry->cpu_scale_factor = cpu_scale_factor;
1417 ),
Juri Lelli0a942002015-11-09 12:06:24 +00001418 TP_printk("cpu=%d freq_scale_factor=%lu cpu_scale_factor=%lu",
1419 __entry->cpu, __entry->freq_scale_factor,
1420 __entry->cpu_scale_factor)
1421);
Juri Lellia4b0c3a2015-11-09 12:07:27 +00001422
Jeevan Shriram49f575e2017-03-02 16:52:44 -08001423#ifdef CONFIG_SMP
Juri Lellia4b0c3a2015-11-09 12:07:27 +00001424/*
1425 * Tracepoint for accounting sched averages for tasks.
1426 */
1427TRACE_EVENT(sched_load_avg_task,
Juri Lellia4b0c3a2015-11-09 12:07:27 +00001428 TP_PROTO(struct task_struct *tsk, struct sched_avg *avg),
Juri Lellia4b0c3a2015-11-09 12:07:27 +00001429 TP_ARGS(tsk, avg),
Juri Lellia4b0c3a2015-11-09 12:07:27 +00001430 TP_STRUCT__entry(
1431 __array( char, comm, TASK_COMM_LEN )
1432 __field( pid_t, pid )
1433 __field( int, cpu )
1434 __field( unsigned long, load_avg )
1435 __field( unsigned long, util_avg )
1436 __field( u64, load_sum )
1437 __field( u32, util_sum )
1438 __field( u32, period_contrib )
1439 ),
Juri Lellia4b0c3a2015-11-09 12:07:27 +00001440 TP_fast_assign(
1441 memcpy(__entry->comm, tsk->comm, TASK_COMM_LEN);
1442 __entry->pid = tsk->pid;
1443 __entry->cpu = task_cpu(tsk);
1444 __entry->load_avg = avg->load_avg;
1445 __entry->util_avg = avg->util_avg;
1446 __entry->load_sum = avg->load_sum;
1447 __entry->util_sum = avg->util_sum;
1448 __entry->period_contrib = avg->period_contrib;
1449 ),
Juri Lellia4b0c3a2015-11-09 12:07:27 +00001450 TP_printk("comm=%s pid=%d cpu=%d load_avg=%lu util_avg=%lu load_sum=%llu"
1451 " util_sum=%u period_contrib=%u",
1452 __entry->comm,
1453 __entry->pid,
1454 __entry->cpu,
1455 __entry->load_avg,
1456 __entry->util_avg,
1457 (u64)__entry->load_sum,
1458 (u32)__entry->util_sum,
1459 (u32)__entry->period_contrib)
1460);
Juri Lelli79478802015-11-09 12:07:48 +00001461/*
1462 * Tracepoint for accounting sched averages for cpus.
1463 */
1464TRACE_EVENT(sched_load_avg_cpu,
Juri Lelli79478802015-11-09 12:07:48 +00001465 TP_PROTO(int cpu, struct cfs_rq *cfs_rq),
Juri Lelli79478802015-11-09 12:07:48 +00001466 TP_ARGS(cpu, cfs_rq),
Juri Lelli79478802015-11-09 12:07:48 +00001467 TP_STRUCT__entry(
1468 __field( int, cpu )
1469 __field( unsigned long, load_avg )
1470 __field( unsigned long, util_avg )
1471 ),
Juri Lelli79478802015-11-09 12:07:48 +00001472 TP_fast_assign(
1473 __entry->cpu = cpu;
1474 __entry->load_avg = cfs_rq->avg.load_avg;
1475 __entry->util_avg = cfs_rq->avg.util_avg;
1476 ),
Juri Lelli79478802015-11-09 12:07:48 +00001477 TP_printk("cpu=%d load_avg=%lu util_avg=%lu",
1478 __entry->cpu, __entry->load_avg, __entry->util_avg)
1479);
Patrick Bellasi050dcb82015-06-22 13:49:07 +01001480/*
1481 * Tracepoint for sched_tune_config settings
1482 */
1483TRACE_EVENT(sched_tune_config,
Patrick Bellasi050dcb82015-06-22 13:49:07 +01001484 TP_PROTO(int boost),
Patrick Bellasi050dcb82015-06-22 13:49:07 +01001485 TP_ARGS(boost),
Patrick Bellasi050dcb82015-06-22 13:49:07 +01001486 TP_STRUCT__entry(
1487 __field( int, boost )
1488 ),
Patrick Bellasi050dcb82015-06-22 13:49:07 +01001489 TP_fast_assign(
1490 __entry->boost = boost;
1491 ),
Patrick Bellasi050dcb82015-06-22 13:49:07 +01001492 TP_printk("boost=%d ", __entry->boost)
1493);
Patrick Bellasicccead12015-06-22 13:51:07 +01001494/*
1495 * Tracepoint for accounting CPU boosted utilization
1496 */
1497TRACE_EVENT(sched_boost_cpu,
Srinath Sridharane71c4252016-07-28 17:28:55 +01001498 TP_PROTO(int cpu, unsigned long util, long margin),
Patrick Bellasicccead12015-06-22 13:51:07 +01001499 TP_ARGS(cpu, util, margin),
Patrick Bellasicccead12015-06-22 13:51:07 +01001500 TP_STRUCT__entry(
1501 __field( int, cpu )
1502 __field( unsigned long, util )
Srinath Sridharane71c4252016-07-28 17:28:55 +01001503 __field(long, margin )
Patrick Bellasicccead12015-06-22 13:51:07 +01001504 ),
Patrick Bellasicccead12015-06-22 13:51:07 +01001505 TP_fast_assign(
1506 __entry->cpu = cpu;
1507 __entry->util = util;
1508 __entry->margin = margin;
1509 ),
Srinath Sridharane71c4252016-07-28 17:28:55 +01001510 TP_printk("cpu=%d util=%lu margin=%ld",
Patrick Bellasicccead12015-06-22 13:51:07 +01001511 __entry->cpu,
1512 __entry->util,
1513 __entry->margin)
1514);
Patrick Bellasi953b1042015-06-24 15:36:08 +01001515/*
1516 * Tracepoint for schedtune_tasks_update
1517 */
1518TRACE_EVENT(sched_tune_tasks_update,
Patrick Bellasi953b1042015-06-24 15:36:08 +01001519 TP_PROTO(struct task_struct *tsk, int cpu, int tasks, int idx,
Srinath Sridharane71c4252016-07-28 17:28:55 +01001520 int boost, int max_boost),
Patrick Bellasi953b1042015-06-24 15:36:08 +01001521 TP_ARGS(tsk, cpu, tasks, idx, boost, max_boost),
Patrick Bellasi953b1042015-06-24 15:36:08 +01001522 TP_STRUCT__entry(
1523 __array( char, comm, TASK_COMM_LEN )
1524 __field( pid_t, pid )
1525 __field( int, cpu )
1526 __field( int, tasks )
1527 __field( int, idx )
Srinath Sridharane71c4252016-07-28 17:28:55 +01001528 __field( int, boost )
1529 __field( int, max_boost )
Patrick Bellasi953b1042015-06-24 15:36:08 +01001530 ),
Patrick Bellasi953b1042015-06-24 15:36:08 +01001531 TP_fast_assign(
1532 memcpy(__entry->comm, tsk->comm, TASK_COMM_LEN);
1533 __entry->pid = tsk->pid;
1534 __entry->cpu = cpu;
1535 __entry->tasks = tasks;
1536 __entry->idx = idx;
1537 __entry->boost = boost;
1538 __entry->max_boost = max_boost;
1539 ),
Patrick Bellasi953b1042015-06-24 15:36:08 +01001540 TP_printk("pid=%d comm=%s "
Srinath Sridharane71c4252016-07-28 17:28:55 +01001541 "cpu=%d tasks=%d idx=%d boost=%d max_boost=%d",
Patrick Bellasi953b1042015-06-24 15:36:08 +01001542 __entry->pid, __entry->comm,
1543 __entry->cpu, __entry->tasks, __entry->idx,
1544 __entry->boost, __entry->max_boost)
1545);
Patrick Bellasi953b1042015-06-24 15:36:08 +01001546/*
1547 * Tracepoint for schedtune_boostgroup_update
1548 */
1549TRACE_EVENT(sched_tune_boostgroup_update,
Patrick Bellasi953b1042015-06-24 15:36:08 +01001550 TP_PROTO(int cpu, int variation, int max_boost),
Patrick Bellasi953b1042015-06-24 15:36:08 +01001551 TP_ARGS(cpu, variation, max_boost),
Patrick Bellasi953b1042015-06-24 15:36:08 +01001552 TP_STRUCT__entry(
1553 __field( int, cpu )
1554 __field( int, variation )
1555 __field( int, max_boost )
1556 ),
Patrick Bellasi953b1042015-06-24 15:36:08 +01001557 TP_fast_assign(
1558 __entry->cpu = cpu;
1559 __entry->variation = variation;
1560 __entry->max_boost = max_boost;
1561 ),
Patrick Bellasi953b1042015-06-24 15:36:08 +01001562 TP_printk("cpu=%d variation=%d max_boost=%d",
1563 __entry->cpu, __entry->variation, __entry->max_boost)
1564);
Patrick Bellasiecccdb72016-01-14 18:43:37 +00001565/*
1566 * Tracepoint for accounting task boosted utilization
1567 */
1568TRACE_EVENT(sched_boost_task,
Srinath Sridharane71c4252016-07-28 17:28:55 +01001569 TP_PROTO(struct task_struct *tsk, unsigned long util, long margin),
Patrick Bellasiecccdb72016-01-14 18:43:37 +00001570 TP_ARGS(tsk, util, margin),
Patrick Bellasiecccdb72016-01-14 18:43:37 +00001571 TP_STRUCT__entry(
1572 __array( char, comm, TASK_COMM_LEN )
1573 __field( pid_t, pid )
1574 __field( unsigned long, util )
Srinath Sridharane71c4252016-07-28 17:28:55 +01001575 __field( long, margin )
Patrick Bellasiecccdb72016-01-14 18:43:37 +00001576 ),
Patrick Bellasiecccdb72016-01-14 18:43:37 +00001577 TP_fast_assign(
1578 memcpy(__entry->comm, tsk->comm, TASK_COMM_LEN);
1579 __entry->pid = tsk->pid;
1580 __entry->util = util;
1581 __entry->margin = margin;
1582 ),
Srinath Sridharane71c4252016-07-28 17:28:55 +01001583 TP_printk("comm=%s pid=%d util=%lu margin=%ld",
Patrick Bellasiecccdb72016-01-14 18:43:37 +00001584 __entry->comm, __entry->pid,
1585 __entry->util,
1586 __entry->margin)
1587);
Patrick Bellasi110441b2016-01-14 18:47:21 +00001588/*
1589 * Tracepoint for accounting sched group energy
1590 */
1591TRACE_EVENT(sched_energy_diff,
Patrick Bellasi110441b2016-01-14 18:47:21 +00001592 TP_PROTO(struct task_struct *tsk, int scpu, int dcpu, int udelta,
1593 int nrgb, int nrga, int nrgd, int capb, int capa, int capd,
1594 int nrgn, int nrgp),
Patrick Bellasi110441b2016-01-14 18:47:21 +00001595 TP_ARGS(tsk, scpu, dcpu, udelta,
1596 nrgb, nrga, nrgd, capb, capa, capd,
1597 nrgn, nrgp),
Patrick Bellasi110441b2016-01-14 18:47:21 +00001598 TP_STRUCT__entry(
1599 __array( char, comm, TASK_COMM_LEN )
1600 __field( pid_t, pid )
1601 __field( int, scpu )
1602 __field( int, dcpu )
1603 __field( int, udelta )
1604 __field( int, nrgb )
1605 __field( int, nrga )
1606 __field( int, nrgd )
1607 __field( int, capb )
1608 __field( int, capa )
1609 __field( int, capd )
1610 __field( int, nrgn )
1611 __field( int, nrgp )
1612 ),
Patrick Bellasi110441b2016-01-14 18:47:21 +00001613 TP_fast_assign(
1614 memcpy(__entry->comm, tsk->comm, TASK_COMM_LEN);
1615 __entry->pid = tsk->pid;
1616 __entry->scpu = scpu;
1617 __entry->dcpu = dcpu;
1618 __entry->udelta = udelta;
1619 __entry->nrgb = nrgb;
1620 __entry->nrga = nrga;
1621 __entry->nrgd = nrgd;
1622 __entry->capb = capb;
1623 __entry->capa = capa;
1624 __entry->capd = capd;
1625 __entry->nrgn = nrgn;
1626 __entry->nrgp = nrgp;
1627 ),
Patrick Bellasi110441b2016-01-14 18:47:21 +00001628 TP_printk("pid=%d comm=%s "
1629 "src_cpu=%d dst_cpu=%d usage_delta=%d "
1630 "nrg_before=%d nrg_after=%d nrg_diff=%d "
1631 "cap_before=%d cap_after=%d cap_delta=%d "
1632 "nrg_delta=%d nrg_payoff=%d",
1633 __entry->pid, __entry->comm,
1634 __entry->scpu, __entry->dcpu, __entry->udelta,
1635 __entry->nrgb, __entry->nrga, __entry->nrgd,
1636 __entry->capb, __entry->capa, __entry->capd,
1637 __entry->nrgn, __entry->nrgp)
1638);
Patrick Bellasi5824d982016-01-20 14:06:05 +00001639/*
1640 * Tracepoint for schedtune_tasks_update
1641 */
1642TRACE_EVENT(sched_tune_filter,
Patrick Bellasi5824d982016-01-20 14:06:05 +00001643 TP_PROTO(int nrg_delta, int cap_delta,
1644 int nrg_gain, int cap_gain,
1645 int payoff, int region),
Patrick Bellasi5824d982016-01-20 14:06:05 +00001646 TP_ARGS(nrg_delta, cap_delta, nrg_gain, cap_gain, payoff, region),
Patrick Bellasi5824d982016-01-20 14:06:05 +00001647 TP_STRUCT__entry(
1648 __field( int, nrg_delta )
1649 __field( int, cap_delta )
1650 __field( int, nrg_gain )
1651 __field( int, cap_gain )
1652 __field( int, payoff )
1653 __field( int, region )
1654 ),
Patrick Bellasi5824d982016-01-20 14:06:05 +00001655 TP_fast_assign(
1656 __entry->nrg_delta = nrg_delta;
1657 __entry->cap_delta = cap_delta;
1658 __entry->nrg_gain = nrg_gain;
1659 __entry->cap_gain = cap_gain;
1660 __entry->payoff = payoff;
1661 __entry->region = region;
1662 ),
Patrick Bellasi5824d982016-01-20 14:06:05 +00001663 TP_printk("nrg_delta=%d cap_delta=%d nrg_gain=%d cap_gain=%d payoff=%d region=%d",
1664 __entry->nrg_delta, __entry->cap_delta,
1665 __entry->nrg_gain, __entry->cap_gain,
1666 __entry->payoff, __entry->region)
1667);
Patrick Bellasi8e45d942016-02-10 09:24:36 +00001668/*
1669 * Tracepoint for system overutilized flag
1670 */
1671TRACE_EVENT(sched_overutilized,
Patrick Bellasi8e45d942016-02-10 09:24:36 +00001672 TP_PROTO(bool overutilized),
Patrick Bellasi8e45d942016-02-10 09:24:36 +00001673 TP_ARGS(overutilized),
Patrick Bellasi8e45d942016-02-10 09:24:36 +00001674 TP_STRUCT__entry(
1675 __field( bool, overutilized )
1676 ),
Patrick Bellasi8e45d942016-02-10 09:24:36 +00001677 TP_fast_assign(
1678 __entry->overutilized = overutilized;
1679 ),
Patrick Bellasi8e45d942016-02-10 09:24:36 +00001680 TP_printk("overutilized=%d",
1681 __entry->overutilized ? 1 : 0)
1682);
Jeevan Shriram49f575e2017-03-02 16:52:44 -08001683#endif
Srivatsa Vaddagiri26c21542016-05-31 09:08:38 -07001684
Syed Rameez Mustafadddcab72016-09-07 16:18:27 -07001685TRACE_EVENT(sched_get_nr_running_avg,
1686
1687 TP_PROTO(int avg, int big_avg, int iowait_avg),
1688
1689 TP_ARGS(avg, big_avg, iowait_avg),
1690
1691 TP_STRUCT__entry(
1692 __field( int, avg )
1693 __field( int, big_avg )
1694 __field( int, iowait_avg )
1695 ),
1696
1697 TP_fast_assign(
1698 __entry->avg = avg;
1699 __entry->big_avg = big_avg;
1700 __entry->iowait_avg = iowait_avg;
1701 ),
1702
1703 TP_printk("avg=%d big_avg=%d iowait_avg=%d",
1704 __entry->avg, __entry->big_avg, __entry->iowait_avg)
1705);
Olav Haugan39432ea2016-06-12 13:57:05 -07001706
Olav Haugan09bcc682016-09-02 17:12:20 -07001707TRACE_EVENT(core_ctl_eval_need,
1708
1709 TP_PROTO(unsigned int cpu, unsigned int old_need,
1710 unsigned int new_need, unsigned int updated),
1711 TP_ARGS(cpu, old_need, new_need, updated),
1712 TP_STRUCT__entry(
1713 __field(u32, cpu)
1714 __field(u32, old_need)
1715 __field(u32, new_need)
1716 __field(u32, updated)
1717 ),
1718 TP_fast_assign(
1719 __entry->cpu = cpu;
1720 __entry->old_need = old_need;
1721 __entry->new_need = new_need;
1722 __entry->updated = updated;
1723 ),
1724 TP_printk("cpu=%u, old_need=%u, new_need=%u, updated=%u", __entry->cpu,
1725 __entry->old_need, __entry->new_need, __entry->updated)
1726);
1727
1728TRACE_EVENT(core_ctl_set_busy,
1729
1730 TP_PROTO(unsigned int cpu, unsigned int busy,
1731 unsigned int old_is_busy, unsigned int is_busy),
1732 TP_ARGS(cpu, busy, old_is_busy, is_busy),
1733 TP_STRUCT__entry(
1734 __field(u32, cpu)
1735 __field(u32, busy)
1736 __field(u32, old_is_busy)
1737 __field(u32, is_busy)
1738 ),
1739 TP_fast_assign(
1740 __entry->cpu = cpu;
1741 __entry->busy = busy;
1742 __entry->old_is_busy = old_is_busy;
1743 __entry->is_busy = is_busy;
1744 ),
1745 TP_printk("cpu=%u, busy=%u, old_is_busy=%u, new_is_busy=%u",
1746 __entry->cpu, __entry->busy, __entry->old_is_busy,
1747 __entry->is_busy)
1748);
1749
Olav Haugana024f472016-10-13 10:34:11 -07001750TRACE_EVENT(core_ctl_set_boost,
1751
1752 TP_PROTO(u32 refcount, s32 ret),
1753 TP_ARGS(refcount, ret),
1754 TP_STRUCT__entry(
1755 __field(u32, refcount)
1756 __field(s32, ret)
1757 ),
1758 TP_fast_assign(
1759 __entry->refcount = refcount;
1760 __entry->ret = ret;
1761 ),
1762 TP_printk("refcount=%u, ret=%d", __entry->refcount, __entry->ret)
1763);
1764
Olav Haugan39432ea2016-06-12 13:57:05 -07001765/*
1766 * sched_isolate - called when cores are isolated/unisolated
1767 *
1768 * @acutal_mask: mask of cores actually isolated/unisolated
1769 * @req_mask: mask of cores requested isolated/unisolated
1770 * @online_mask: cpu online mask
1771 * @time: amount of time in us it took to isolate/unisolate
1772 * @isolate: 1 if isolating, 0 if unisolating
1773 *
1774 */
1775TRACE_EVENT(sched_isolate,
1776
1777 TP_PROTO(unsigned int requested_cpu, unsigned int isolated_cpus,
1778 u64 start_time, unsigned char isolate),
1779
1780 TP_ARGS(requested_cpu, isolated_cpus, start_time, isolate),
1781
1782 TP_STRUCT__entry(
1783 __field(u32, requested_cpu)
1784 __field(u32, isolated_cpus)
1785 __field(u32, time)
1786 __field(unsigned char, isolate)
1787 ),
1788
1789 TP_fast_assign(
1790 __entry->requested_cpu = requested_cpu;
1791 __entry->isolated_cpus = isolated_cpus;
1792 __entry->time = div64_u64(sched_clock() - start_time, 1000);
1793 __entry->isolate = isolate;
1794 ),
1795
1796 TP_printk("iso cpu=%u cpus=0x%x time=%u us isolated=%d",
1797 __entry->requested_cpu, __entry->isolated_cpus,
1798 __entry->time, __entry->isolate)
1799);
Steven Rostedtea20d922009-04-10 08:54:16 -04001800#endif /* _TRACE_SCHED_H */
Steven Rostedta8d154b2009-04-10 09:36:00 -04001801
1802/* This part must be outside protection */
1803#include <trace/define_trace.h>