[PATCH] sched_ext: Add tracepoint for scheduler exit

Pat Somaru posted 1 patch 1 week, 6 days ago
include/trace/events/sched_ext.h | 19 +++++++++++++++++++
kernel/sched/ext.c               |  2 ++
2 files changed, 21 insertions(+)
[PATCH] sched_ext: Add tracepoint for scheduler exit
Posted by Pat Somaru 1 week, 6 days ago
sched_ext schedulers have state in BPF programs and kernel. scx_dump
provides kernel state and BPF program state on error, but this is static
in what it can provide.

Add a sched_ext_exit tracepoint in scx_claim_exit() so that BPF programs
can dynamically inspect scheduler specific state at the moment of exit.

Signed-off-by: Pat Somaru <patso@likewhatevs.io>
---
 include/trace/events/sched_ext.h | 19 +++++++++++++++++++
 kernel/sched/ext.c               |  2 ++
 2 files changed, 21 insertions(+)

diff --git a/include/trace/events/sched_ext.h b/include/trace/events/sched_ext.h
index d1bf5acd59c5..9ccf884919c1 100644
--- a/include/trace/events/sched_ext.h
+++ b/include/trace/events/sched_ext.h
@@ -84,6 +84,25 @@ TRACE_EVENT(sched_ext_bypass_lb,
 	)
 );
 
+TRACE_EVENT(sched_ext_exit,
+
+	TP_PROTO(__u32 kind),
+
+	TP_ARGS(kind),
+
+	TP_STRUCT__entry(
+		__field(__u32, kind)
+	),
+
+	TP_fast_assign(
+		__entry->kind		= kind;
+	),
+
+	TP_printk("kind %u",
+		  __entry->kind
+	)
+);
+
 #endif /* _TRACE_SCHED_EXT_H */
 
 /* This part must be outside protection */
diff --git a/kernel/sched/ext.c b/kernel/sched/ext.c
index 64f8a096f133..0219b11bb9d1 100644
--- a/kernel/sched/ext.c
+++ b/kernel/sched/ext.c
@@ -6200,6 +6200,8 @@ static bool scx_claim_exit(struct scx_sched *sch, enum scx_exit_kind kind)
 	 */
 	WRITE_ONCE(sch->aborting, true);
 
+	trace_sched_ext_exit(kind);
+
 	/*
 	 * Propagate exits to descendants immediately. Each has a dedicated
 	 * helper kthread and can run in parallel. While most of disabling is
-- 
2.54.0
Re: [PATCH] sched_ext: Add tracepoint for scheduler exit
Posted by Tejun Heo 1 week, 6 days ago
Hello,

The TP should carry sch. With only kind, an observer can't tell which
scheduler in a hierarchy just exited.

Thanks.

--
tejun