[PATCH] sched_ext: Count cap-rejected local DSQ inserts in SCX_EV_SUB_REJECT

From: luoliang

Date: Fri Sep 25 2026 - 03:06:31 EST


From: Liang Luo <luoliang@xxxxxxxxxx>

When a task is enqueued on a local DSQ without the caps its enqueue flags
require, __scx_resolve_local_dsq() has three outcomes: admit the task
anyway because the rq is draining offline, the task is migration-disabled
or a migration is pending (counted in SCX_EV_SUB_FORCED_ADMIT), divert it
to the rescue path when the enqueue requested rescue (counted in
SCX_EV_SUB_RESCUE), or divert it to the reject DSQ to be re-enqueued so
that the BPF scheduler can re-decide.

The first two are counted but the last is not, so the number of tasks
diverted to the reject DSQ is missing from the counters exposed via
sysfs, scx_dump_state() and the scx_bpf_events() kfunc. No other
counter covers it: nr_rejected counts tasks refused by ops.init_task()
through task->scx.disallow, and SCX_EV_REENQ_REPEAT only sees a reject
diversion once the same task fails its placement again.

Add SCX_EV_SUB_REJECT and count the reject diversion so that all three
outcomes of a cap-missing local DSQ insert are observable.

Fixes: 75a8c8202c91 ("sched_ext: Add reject DSQ for cap-rejected dispatches")
Signed-off-by: Liang Luo <luoliang@xxxxxxxxxx>
---
kernel/sched/ext/internal.h | 10 +++++++++-
kernel/sched/ext/sub.c | 2 ++
2 files changed, 11 insertions(+), 1 deletion(-)

diff --git a/kernel/sched/ext/internal.h b/kernel/sched/ext/internal.h
index 0bcceab612de..36da1a6560db 100644
--- a/kernel/sched/ext/internal.h
+++ b/kernel/sched/ext/internal.h
@@ -1308,6 +1308,13 @@ struct scx_event_stats {
* caps for its cid and the task entered the rescue path.
*/
s64 SCX_EV_SUB_RESCUE;
+
+ /*
+ * The number of times an insert lacked the caps for its cid and was
+ * diverted to the reject DSQ to be re-enqueued so that the BPF
+ * scheduler can re-decide.
+ */
+ s64 SCX_EV_SUB_REJECT;
};

#define SCX_EVENTS_LIST(SCX_EVENT) \
@@ -1331,7 +1338,8 @@ struct scx_event_stats {
SCX_EVENT(SCX_EV_SUB_KICK_DENIED); \
SCX_EVENT(SCX_EV_SUB_REENQ_DENIED); \
SCX_EVENT(SCX_EV_SUB_CIDPERF_DENIED); \
- SCX_EVENT(SCX_EV_SUB_RESCUE)
+ SCX_EVENT(SCX_EV_SUB_RESCUE); \
+ SCX_EVENT(SCX_EV_SUB_REJECT)

struct scx_sched;

diff --git a/kernel/sched/ext/sub.c b/kernel/sched/ext/sub.c
index 10567196be96..3429b84f319a 100644
--- a/kernel/sched/ext/sub.c
+++ b/kernel/sched/ext/sub.c
@@ -748,6 +748,8 @@ struct scx_dispatch_q *__scx_resolve_local_dsq(struct scx_sched *sch, struct rq
return &rq->scx.rescue.dsq;
}

+ __scx_add_event(sch, SCX_EV_SUB_REJECT, 1);
+
p->scx.reenq_reason_caps = missing;
p->scx.reenq_reason_cid = cid;

--
2.43.0