* [PATCH] sched/debug: Add tracepoint for RT throttling
@ 2018-12-14 8:27 Benjamin Bouvier
2018-12-14 8:46 ` Sebastian Andrzej Siewior
2018-12-15 21:59 ` kbuild test robot
0 siblings, 2 replies; 3+ messages in thread
From: Benjamin Bouvier @ 2018-12-14 8:27 UTC (permalink / raw)
To: mingo, peterz
Cc: rostedt, u.kleine-koenig, bigeasy, pkondeti, alexander.sverdlin,
linux-kernel, Benjamin Bouvier
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@nokia.com>
---
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
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH] sched/debug: Add tracepoint for RT throttling
2018-12-14 8:27 [PATCH] sched/debug: Add tracepoint for RT throttling Benjamin Bouvier
@ 2018-12-14 8:46 ` Sebastian Andrzej Siewior
2018-12-15 21:59 ` kbuild test robot
1 sibling, 0 replies; 3+ messages in thread
From: Sebastian Andrzej Siewior @ 2018-12-14 8:46 UTC (permalink / raw)
To: Benjamin Bouvier
Cc: mingo, peterz, rostedt, u.kleine-koenig, pkondeti,
alexander.sverdlin, linux-kernel
On 2018-12-14 10:27:41 [+0200], Benjamin Bouvier wrote:
> 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.
Throttling is for _all_ RT class applications. The task you print might
be innocent and getting the blame. The interesting part is to see all
the RT tasks (not sure about DL) since the last time, the timer was
started on the CPU.
Sebastian
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] sched/debug: Add tracepoint for RT throttling
2018-12-14 8:27 [PATCH] sched/debug: Add tracepoint for RT throttling Benjamin Bouvier
2018-12-14 8:46 ` Sebastian Andrzej Siewior
@ 2018-12-15 21:59 ` kbuild test robot
1 sibling, 0 replies; 3+ messages in thread
From: kbuild test robot @ 2018-12-15 21:59 UTC (permalink / raw)
To: Benjamin Bouvier
Cc: kbuild-all, mingo, peterz, rostedt, u.kleine-koenig, bigeasy,
pkondeti, alexander.sverdlin, linux-kernel, Benjamin Bouvier
[-- Attachment #1: Type: text/plain, Size: 3202 bytes --]
Hi Benjamin,
Thank you for the patch! Yet something to improve:
[auto build test ERROR on tip/perf/core]
[also build test ERROR on v4.20-rc6 next-20181214]
[if your patch is applied to the wrong git tree, please drop us a note to help improve the system]
url: https://github.com/0day-ci/linux/commits/Benjamin-Bouvier/sched-debug-Add-tracepoint-for-RT-throttling/20181216-050740
config: x86_64-randconfig-x001-201850 (attached as .config)
compiler: gcc-7 (Debian 7.3.0-1) 7.3.0
reproduce:
# save the attached .config to linux build tree
make ARCH=x86_64
All errors (new ones prefixed by >>):
In file included from include/linux/kernel.h:14:0,
from arch/x86/include/asm/percpu.h:45,
from arch/x86/include/asm/current.h:6,
from include/linux/sched.h:12,
from kernel//sched/sched.h:5,
from kernel//sched/rt.c:6:
kernel//sched/rt.c: In function 'sched_rt_runtime_exceeded':
>> kernel//sched/rt.c:934:59: error: 'struct rq' has no member named 'cpu'
rt_rq->rq->curr->pid, rt_rq->rq->curr->comm, rt_rq->rq->cpu);
^
include/linux/printk.h:372:26: note: in definition of macro 'printk_deferred_once'
printk_deferred(fmt, ##__VA_ARGS__); \
^~~~~~~~~~~
kernel//sched/rt.c:935:56: error: 'struct rq' has no member named 'cpu'
trace_sched_rt_throttling(rt_rq->rq->curr, rt_rq->rq->cpu);
^~
vim +934 kernel//sched/rt.c
907
908 static int sched_rt_runtime_exceeded(struct rt_rq *rt_rq)
909 {
910 u64 runtime = sched_rt_runtime(rt_rq);
911
912 if (rt_rq->rt_throttled)
913 return rt_rq_throttled(rt_rq);
914
915 if (runtime >= sched_rt_period(rt_rq))
916 return 0;
917
918 balance_runtime(rt_rq);
919 runtime = sched_rt_runtime(rt_rq);
920 if (runtime == RUNTIME_INF)
921 return 0;
922
923 if (rt_rq->rt_time > runtime) {
924 struct rt_bandwidth *rt_b = sched_rt_bandwidth(rt_rq);
925
926 /*
927 * Don't actually throttle groups that have no runtime assigned
928 * but accrue some time due to boosting.
929 */
930 if (likely(rt_b->rt_runtime)) {
931 rt_rq->rt_throttled = 1;
932 printk_deferred_once(
933 "sched: RT throttling activated for task pid %d (%s) on cpu:%d\n",
> 934 rt_rq->rq->curr->pid, rt_rq->rq->curr->comm, rt_rq->rq->cpu);
935 trace_sched_rt_throttling(rt_rq->rq->curr, rt_rq->rq->cpu);
936 } else {
937 /*
938 * In case we did anyway, make it go away,
939 * replenishment is a joke, since it will replenish us
940 * with exactly 0 ns.
941 */
942 rt_rq->rt_time = 0;
943 }
944
945 if (rt_rq_throttled(rt_rq)) {
946 sched_rt_rq_dequeue(rt_rq);
947 return 1;
948 }
949 }
950
951 return 0;
952 }
953
---
0-DAY kernel test infrastructure Open Source Technology Center
https://lists.01.org/pipermail/kbuild-all Intel Corporation
[-- Attachment #2: .config.gz --]
[-- Type: application/gzip, Size: 29739 bytes --]
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2018-12-15 22:00 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-12-14 8:27 [PATCH] sched/debug: Add tracepoint for RT throttling Benjamin Bouvier
2018-12-14 8:46 ` Sebastian Andrzej Siewior
2018-12-15 21:59 ` kbuild test robot
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).