mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH] sched_ext: Count cap-rejected local DSQ inserts in SCX_EV_SUB_REJECT
@ 2026-09-25  7:05 luoliang
  2026-09-28 19:06 ` Tejun Heo
  2026-09-29  3:03 ` [PATCH v2] " luoliang
  0 siblings, 2 replies; 6+ messages in thread
From: luoliang @ 2026-09-25  7:05 UTC (permalink / raw)
  To: Tejun Heo
  Cc: David Vernet, Andrea Righi, Changwoo Min, sched-ext,
	linux-kernel, Liang Luo

From: Liang Luo <luoliang@kylinos.cn>

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@kylinos.cn>
---
 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


^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2026-09-29  6:12 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-09-25  7:05 [PATCH] sched_ext: Count cap-rejected local DSQ inserts in SCX_EV_SUB_REJECT luoliang
2026-09-28 19:06 ` Tejun Heo
2026-09-29  3:00   ` luoliang
2026-09-29  3:03 ` [PATCH v2] " luoliang
2026-09-29  5:09   ` Andrea Righi
2026-09-29  6:12     ` luoliang

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®