[PATCH 4/9] tools/sched_ext: scx_pair: Don't attach after an interrupted initialization
From: Tao Cui
Date: Tue Nov 10 2026 - 08:00:23 EST
From: Tao Cui <cuitao@xxxxxxxxxx>
The cgrp_q_arr initialization loop checks exit_req and breaks early so
that Ctrl-C doesn't make the user wait through all MAX_CGRPS iterations
- but the break falls straight into SCX_OPS_ATTACH(). Attaching with
part of the inner queue maps missing lets ops.cgroup_init() hand out
slots for cgroups whose inner map was never created, and the first task
in such a cgroup aborts the scheduler with an scx_bpf_error(). On a busy
system the 4096-iteration loop takes long enough that hitting it with
Ctrl-C is likely, so the intended responsive interrupt turns into a
scheduler crash dump.
Exit cleanly when interrupted mid-initialization instead of attaching.
Fixes: f0262b102c7c ("tools/sched_ext: add scx_pair scheduler")
Signed-off-by: Tao Cui <cuitao@xxxxxxxxxx>
---
tools/sched_ext/scx_pair.c | 11 ++++++++++-
1 file changed, 10 insertions(+), 1 deletion(-)
diff --git a/tools/sched_ext/scx_pair.c b/tools/sched_ext/scx_pair.c
index 00f595b58f97..35c8a1a07f56 100644
--- a/tools/sched_ext/scx_pair.c
+++ b/tools/sched_ext/scx_pair.c
@@ -161,8 +161,17 @@ int main(int argc, char **argv)
printf("\n");
/*
- * Fully initialized, attach and run.
+ * Fully initialized, attach and run. An interrupt during the
+ * initialization loop leaves the tail of cgrp_q_arr without inner
+ * maps; attaching in that state lets ops.cgroup_init() hand out
+ * uninitialized slots and abort the scheduler on the first cgroup
+ * task.
*/
+ if (exit_req) {
+ scx_pair__destroy(skel);
+ return 1;
+ }
+
link = SCX_OPS_ATTACH(skel, pair_ops, scx_pair);
while (!exit_req && !UEI_EXITED(skel, uei)) {
--
2.53.0
base-commit: 5b740a72b55c4267ba4d8010f17dde26b26f52d3