[PATCH] sched/debug: Add tracepoint for RT throttling
From: Benjamin Bouvier
Date: Fri Dec 14 2018 - 03:28:19 EST
As there is currently no information on which RT task is throttled, add a
new tracepoint for debug purpose. By the way improve printk debugging
message by adding task name, pid and cpu for which the throttle has been
executed.
Signed-off-by: Benjamin Bouvier <benjamin.bouvier@xxxxxxxxx>
---
include/trace/events/sched.h | 27 +++++++++++++++++++++++++++
kernel/sched/rt.c | 6 +++++-
2 files changed, 32 insertions(+), 1 deletion(-)
diff --git a/include/trace/events/sched.h b/include/trace/events/sched.h
index 9a4bdfadab07..09d3f7566f0a 100644
--- a/include/trace/events/sched.h
+++ b/include/trace/events/sched.h
@@ -587,6 +587,33 @@ TRACE_EVENT(sched_wake_idle_without_ipi,
TP_printk("cpu=%d", __entry->cpu)
);
+
+/*
+ * Tracepoint for RT throttling task.
+ */
+TRACE_EVENT(sched_rt_throttling,
+
+ TP_PROTO(struct task_struct *tsk, int cpu),
+
+ TP_ARGS(tsk, cpu),
+
+ TP_STRUCT__entry(
+ __array(char, comm, TASK_COMM_LEN)
+ __field(pid_t, pid)
+ __field(int, cpu)
+ ),
+
+ TP_fast_assign(
+ memcpy(__entry->comm, tsk->comm, TASK_COMM_LEN);
+ __entry->pid = tsk->pid;
+ __entry->cpu = cpu;
+ ),
+
+ TP_printk("comm=%s pid=%d cpu=%d",
+ __entry->comm, __entry->pid,
+ __entry->cpu)
+);
+
#endif /* _TRACE_SCHED_H */
/* This part must be outside protection */
diff --git a/kernel/sched/rt.c b/kernel/sched/rt.c
index a21ea6021929..1a0ee91c9e16 100644
--- a/kernel/sched/rt.c
+++ b/kernel/sched/rt.c
@@ -6,6 +6,7 @@
#include "sched.h"
#include "pelt.h"
+#include <trace/events/sched.h>
int sched_rr_timeslice = RR_TIMESLICE;
int sysctl_sched_rr_timeslice = (MSEC_PER_SEC / HZ) * RR_TIMESLICE;
@@ -928,7 +929,10 @@ static int sched_rt_runtime_exceeded(struct rt_rq *rt_rq)
*/
if (likely(rt_b->rt_runtime)) {
rt_rq->rt_throttled = 1;
- printk_deferred_once("sched: RT throttling activated\n");
+ printk_deferred_once(
+ "sched: RT throttling activated for task pid %d (%s) on cpu:%d\n",
+ rt_rq->rq->curr->pid, rt_rq->rq->curr->comm, rt_rq->rq->cpu);
+ trace_sched_rt_throttling(rt_rq->rq->curr, rt_rq->rq->cpu);
} else {
/*
* In case we did anyway, make it go away,
--
2.10.2