Skip to contentSkip to conversation

sched_ext: Count SCX_EV_SUB_BYPASS_DISPATCH in the dispatch fallback

PATCH Applied [email protected] 2 participants 2 messages Sep 23

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 sched_ext: Count SCX_EV_SUB_BYPASS_DISPATCH in the dispatch fallback

From: Liang Luo <[email protected]>

When a descendant scheduler enters bypass mode, its tasks are parked in the bypass DSQs of the nearest non-bypassing ancestor, which is then responsible for running them. On behalf of such a non-bypassing host, scx_dispatch_sched() consumes those bypass DSQs from two places: the attempt made every SCX_BYPASS_HOST_NTH dispatches, and the end-of-dispatch fallback that keeps the CPU from going idle while bypassed descendants still have tasks queued.

The former increments SCX_EV_SUB_BYPASS_DISPATCH but the latter does not, even though both perform the same scx_consume_dispatch_q() on the same bypass DSQ. The descendant bypass dispatches done by the fallback are therefore missing from the counter exposed via sysfs, scx_dump_state() and the scx_bpf_events() kfunc, which under-reports the actual number of such dispatches.

Add the missing __scx_add_event() so the fallback counts them too. When @sch itself is bypassing, scx_dispatch_sched() takes the earlier self-bypass branch and returns before reaching these host paths; that mode is accounted for by SCX_EV_BYPASS_DISPATCH at enqueue time and is intentionally left unchanged.

Fixes 025b1bd41965 ("sched_ext: Implement hierarchical bypass mode")
---
 kernel/sched/ext/inlines.h | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)
kernel/sched/ext/inlines.h +3 -1
index ed423bcc26b8..2ff5479334cb 100644
@@ -129,8 +129,10 @@ scx_dispatch_sched(struct scx_sched *sch, struct rq *rq,
 	 * scheduler's ops.dispatch() doesn't yield any tasks.
 	 */
 	if (scx_bypass_dsp_enabled(sch) &&
-	    scx_consume_dispatch_q(sch, rq, scx_bypass_dsq(sch, cpu), 0))
+	    scx_consume_dispatch_q(sch, rq, scx_bypass_dsq(sch, cpu), 0)) {
+		__scx_add_event(sch, SCX_EV_SUB_BYPASS_DISPATCH, 1);
 		return SCX_DSP_LOCAL;
+	}
 
 	return SCX_DSP_NONE;
 }
Signature · 1 line
2.43.0
reviewer Applied
#1 lore raw

Applied to sched_ext/for-7.3-fixes.

Thanks.

--
tejun