This tracepoint allows to keep track of all explicit priority changes of a
task. It outputs the scheduling policy, the nice value, the rt_priority and the
deadline-related attributes (dl_runtime, dl_deadline and dl_period).
It is emitted in the code path of the sched_setscheduler, sched_setattr,
sched_setparam, and nice system calls.
This allows the analysis of real-time scheduling delays based on the configured
scheduling priorities and policies, which cannot be performed with the current
instrumentation in sched_switch. Also, instead of exposing the internal kernel
prio field, this tracepoint only outputs the user-visible priority attributes.
The effective priority of running threads can also be temporarily changed in
the PI code, but a dedicated tracepoint is already in place to cover this case.
Here are a few output examples:
After fork of a normal task:
renice -n 10 of a normal task:
sched_update_prio: { cpu_id = 4 }, { comm = "sleep", tid = 8149, prio = 30,
policy = ( "SCHED_NORMAL" : container = 0 ), nice = 10, rt_priority = 0,
dl_runtime = 0, dl_deadline = 0, dl_period = 0 }
SCHED_FIFO 60:
sched_update_prio: { cpu_id = 6 }, { comm = "chrt", tid = 7857, prio = -61,
policy = ( "SCHED_FIFO" : container = 1 ), nice = 0, rt_priority = 60,
dl_runtime = 0, dl_deadline = 0, dl_period = 0 }
SCHED_RR 60:
sched_update_prio: { cpu_id = 3 }, { comm = "chrt", tid = 8157, prio = -61,
policy = ( "SCHED_RR" : container = 2 ), nice = 0, rt_priority = 60, dl_runtime
= 0, dl_deadline = 0, dl_period = 0 }
SCHED_DEADLINE:
sched_update_prio: { cpu_id = 7 }, { comm = "b", tid = 8162, prio = -101,
policy = ( "SCHED_DEADLINE" : container = 6 ), nice = 0, rt_priority = 0,
dl_runtime =
10000000, dl_deadline =
30000000, dl_period =
30000000 }
Signed-off-by: Julien Desfossez <jdesfossez@efficios.com>
#endif /* _TRACE_SCHED_DEF_ */
+#if (LINUX_VERSION_CODE >= KERNEL_VERSION(4,7,0))
+LTTNG_TRACEPOINT_ENUM(lttng_sched_policy,
+ TP_ENUM_VALUES(
+ ctf_enum_value("SCHED_NORMAL", SCHED_NORMAL)
+ ctf_enum_value("SCHED_FIFO", SCHED_FIFO)
+ ctf_enum_value("SCHED_RR", SCHED_RR)
+ ctf_enum_value("SCHED_BATCH", SCHED_BATCH)
+ ctf_enum_value("SCHED_IDLE", SCHED_IDLE)
+ ctf_enum_value("SCHED_DEADLINE", SCHED_DEADLINE)
+ )
+)
+#endif
+
/*
* Tracepoint for calling kthread_stop, performed to end a kthread:
*/
)
#endif
+#if (LINUX_VERSION_CODE >= KERNEL_VERSION(4,7,0))
+/*
+ * Tracepoint for priority changes of a task.
+ */
+LTTNG_TRACEPOINT_EVENT(sched_update_prio,
+
+ TP_PROTO(struct task_struct *tsk),
+
+ TP_ARGS(tsk),
+
+ TP_FIELDS(
+ ctf_array_text(char, comm, tsk->comm, TASK_COMM_LEN)
+ ctf_integer(pid_t, tid, tsk->pid)
+ ctf_integer(int, prio, tsk->prio - MAX_RT_PRIO)
+ ctf_enum(lttng_sched_policy, unsigned int, policy, tsk->policy)
+ ctf_integer(int, nice, task_nice(tsk))
+ ctf_integer(unsigned int, rt_priority, tsk->rt_priority)
+ ctf_integer(u64, dl_runtime, tsk->dl.dl_runtime)
+ ctf_integer(u64, dl_deadline, tsk->dl.dl_deadline)
+ ctf_integer(u64, dl_period, tsk->dl.dl_period)
+ )
+)
+#endif
+
#endif /* LTTNG_TRACE_SCHED_H */
/* This part must be outside protection */
__entry->oldprio, __entry->newprio)
);
+/*
+ * Tracepoint for priority changes of a task.
+ */
+TRACE_EVENT(sched_set_prio,
+
+ TP_PROTO(struct task_struct *tsk, int newprio),
+
+ TP_ARGS(tsk, newprio),
+
+ TP_STRUCT__entry(
+ __array( char, comm, TASK_COMM_LEN )
+ __field( pid_t, pid )
+ __field( int, oldprio )
+ __field( int, newprio )
+ ),
+
+ TP_fast_assign(
+ memcpy(__entry->comm, tsk->comm, TASK_COMM_LEN);
+ __entry->pid = tsk->pid;
+ __entry->oldprio = tsk->prio;
+ __entry->newprio = newprio;
+ ),
+
+ TP_printk("comm=%s pid=%d oldprio=%d newprio=%d",
+ __entry->comm, __entry->pid,
+ __entry->oldprio, __entry->newprio)
+);
+
#endif /* _TRACE_SCHED_H */
/* This part must be outside protection */