From: Tejun Heo <tj@kernel.org>
To: David Vernet <void@manifault.com>,
Andrea Righi <arighi@nvidia.com>,
Changwoo Min <changwoo@igalia.com>
Cc: sched-ext@lists.linux.dev, Emil Tsalapatis <emil@etsalapatis.com>,
linux-kernel@vger.kernel.org, Tejun Heo <tj@kernel.org>
Subject: [PATCH 3/5] sched_ext: Count kicks denied for lacking baseline cid access
Date: Fri, 24 Jul 2026 08:21:23 -1000 [thread overview]
Message-ID: <20260724182125.985061-4-tj@kernel.org> (raw)
In-Reply-To: <20260724182125.985061-1-tj@kernel.org>
kick_one_cpu() silently skips a kick when the kicking sub-sched lacks
SCX_CAP_BASE on the target cid, as does kick_one_cpu_if_idle() for idle
kicks. The skips are sound with the same logic as the reenq gate but are
invisible today, unlike the preempt degradation counted in
SCX_EV_SUB_PREEMPT_DENIED. Count them in a new SCX_EV_SUB_KICK_DENIED event
so every cap denial is observable.
Signed-off-by: Tejun Heo <tj@kernel.org>
---
kernel/sched/ext/ext.c | 20 ++++++++++++++------
kernel/sched/ext/internal.h | 8 ++++++++
2 files changed, 22 insertions(+), 6 deletions(-)
diff --git a/kernel/sched/ext/ext.c b/kernel/sched/ext/ext.c
index fd88b4d4f12a..5d02bb99c09d 100644
--- a/kernel/sched/ext/ext.c
+++ b/kernel/sched/ext/ext.c
@@ -8118,6 +8118,7 @@ static bool kick_one_cpu(s32 cpu, struct scx_sched_pcpu *pcpu, struct rq *this_r
struct scx_rq *this_scx = &this_rq->scx;
const struct sched_class *cur_class;
bool should_wait = false;
+ bool kickable;
unsigned long flags;
raw_spin_rq_lock_irqsave(rq, flags);
@@ -8131,9 +8132,10 @@ static bool kick_one_cpu(s32 cpu, struct scx_sched_pcpu *pcpu, struct rq *this_r
* business forcing a reschedule there - skip. This is the authoritative
* cap check: ecaps is read here under @rq's lock.
*/
- if ((cpu_online(cpu) || cpu == cpu_of(this_rq)) &&
- !sched_class_above(cur_class, &ext_sched_class) &&
- !scx_missing_caps(pcpu->sch, cpu, SCX_CAP_BASE)) {
+ kickable = (cpu_online(cpu) || cpu == cpu_of(this_rq)) &&
+ !sched_class_above(cur_class, &ext_sched_class);
+
+ if (kickable && !scx_missing_caps(pcpu->sch, cpu, SCX_CAP_BASE)) {
if (cpumask_test_cpu(cpu, pcpu->cpus_to_preempt)) {
if (cur_class == &ext_sched_class) {
if (likely(!scx_missing_caps(pcpu->sch, cpu,
@@ -8157,6 +8159,9 @@ static bool kick_one_cpu(s32 cpu, struct scx_sched_pcpu *pcpu, struct rq *this_r
resched_curr(rq);
} else {
+ /* a kickable cpu was skipped solely for the missing caps */
+ if (kickable)
+ __scx_add_event(pcpu->sch, SCX_EV_SUB_KICK_DENIED, 1);
cpumask_clear_cpu(cpu, pcpu->cpus_to_preempt);
cpumask_clear_cpu(cpu, pcpu->cpus_to_wait);
}
@@ -8176,9 +8181,12 @@ static void kick_one_cpu_if_idle(s32 cpu, struct scx_sched_pcpu *pcpu,
/* idle kicks need baseline access too, see kick_one_cpu() */
if (!can_skip_idle_kick(rq) &&
- (cpu_online(cpu) || cpu == cpu_of(this_rq)) &&
- !scx_missing_caps(pcpu->sch, cpu, SCX_CAP_BASE))
- resched_curr(rq);
+ (cpu_online(cpu) || cpu == cpu_of(this_rq))) {
+ if (likely(!scx_missing_caps(pcpu->sch, cpu, SCX_CAP_BASE)))
+ resched_curr(rq);
+ else
+ __scx_add_event(pcpu->sch, SCX_EV_SUB_KICK_DENIED, 1);
+ }
raw_spin_rq_unlock_irqrestore(rq, flags);
}
diff --git a/kernel/sched/ext/internal.h b/kernel/sched/ext/internal.h
index 1bdf34f3fc3c..308d16320818 100644
--- a/kernel/sched/ext/internal.h
+++ b/kernel/sched/ext/internal.h
@@ -1194,6 +1194,13 @@ struct scx_event_stats {
*/
s64 SCX_EV_SUB_PREEMPT_DENIED;
+ /*
+ * The number of times a kick was skipped because the sub-sched lacked
+ * baseline access on the target cid. The preempt-part degradation of a
+ * delivered kick is counted in SCX_EV_SUB_PREEMPT_DENIED instead.
+ */
+ s64 SCX_EV_SUB_KICK_DENIED;
+
/*
* The number of times a local DSQ reenq was dropped because the
* sub-sched lacked baseline access on the target cid.
@@ -1219,6 +1226,7 @@ struct scx_event_stats {
SCX_EVENT(SCX_EV_SUB_BYPASS_DISPATCH); \
SCX_EVENT(SCX_EV_SUB_FORCED_ADMIT); \
SCX_EVENT(SCX_EV_SUB_PREEMPT_DENIED); \
+ SCX_EVENT(SCX_EV_SUB_KICK_DENIED); \
SCX_EVENT(SCX_EV_SUB_REENQ_DENIED)
struct scx_sched;
--
2.55.0
next prev parent reply other threads:[~2026-07-24 18:21 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-07-24 18:21 [PATCHSET sched_ext/for-7.3] sched_ext: Follow-up fixes and missing cap enforcement Tejun Heo
2026-07-24 18:21 ` [PATCH 1/5] tools/sched_ext: Don't restart over a pending exit request Tejun Heo
2026-07-24 18:21 ` [PATCH 2/5] sched_ext: Gate local DSQ reenq on baseline cid access Tejun Heo
2026-07-24 18:21 ` Tejun Heo [this message]
2026-07-24 18:21 ` [PATCH 4/5] sched_ext: Factor out scx_cpuperf_set() Tejun Heo
2026-07-24 18:21 ` [PATCH 5/5] sched_ext: Gate scx_bpf_cidperf_set() behind a new SCX_CAP_PERF Tejun Heo
-- strict thread matches above, loose matches on Subject: below --
2026-07-24 19:16 [PATCHSET v2 sched_ext/for-7.3] sched_ext: Follow-up fixes and missing cap enforcement Tejun Heo
2026-07-24 19:16 ` [PATCH 3/5] sched_ext: Count kicks denied for lacking baseline cid access Tejun Heo
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20260724182125.985061-4-tj@kernel.org \
--to=tj@kernel.org \
--cc=arighi@nvidia.com \
--cc=changwoo@igalia.com \
--cc=emil@etsalapatis.com \
--cc=linux-kernel@vger.kernel.org \
--cc=sched-ext@lists.linux.dev \
--cc=void@manifault.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox