[PATCH v2 08/11] sched_ext: Add an event, BYPASS_DISPATCH

Changwoo Min
2025-01-26T10:16:57Z

Add a core event, BYPASS_DISPATCH, which represents how many tasks
have been dispatched in the bypass mode.

__scx_add_event() is used since the caller holds an rq lock,
so the preemption has already been disabled.

Signed-off-by: Changwoo Min <changwoo@igalia.com>
---
kernel/sched/ext.c | 9 +++++++++
1 file changed, 9 insertions(+)

diff --git a/kernel/sched/ext.c b/kernel/sched/ext.c
index bb363809e484..9a680774c1fc 100644
--- a/kernel/sched/ext.c
+++ b/kernel/sched/ext.c
@@ -1486,6 +1486,11 @@ struct scx_event_stats {
*/
u64 ENQ_SKIP_EXITING;

+ /*
+ * The number of tasks dispatched in the bypassing mode.
+ */
+ u64 BYPASS_DISPATCH;
+
/*
* The number of times the bypassing mode has been activated.
*/
@@ -2941,6 +2946,8 @@ static int balance_one(struct rq *rq, struct task_struct *prev)
return false;

has_tasks:
+ if (scx_rq_bypassing(rq))
+ __scx_add_event(BYPASS_DISPATCH, 1);
rq->scx.flags &= ~SCX_RQ_IN_BALANCE;
return true;
}
@@ -5524,6 +5531,7 @@ static void scx_dump_state(struct scx_exit_info *ei, size_t dump_len)
scx_dump_event(s, &events, DISPATCH_LOCAL_DSQ_OFFLINE);
scx_dump_event(s, &events, DISPATCH_KEEP_LAST);
scx_dump_event(s, &events, ENQ_SKIP_EXITING);
+ scx_dump_event(s, &events, BYPASS_DISPATCH);
scx_dump_event(s, &events, BYPASS_ACTIVATE);

if (seq_buf_has_overflowed(&s) && dump_len >= sizeof(trunc_marker))
@@ -7856,6 +7864,7 @@ __bpf_kfunc void scx_bpf_event_stats(struct scx_event_stats *events,
scx_agg_event(&e_sys, e_cpu, SELECT_CPU_FALLBACK);
scx_agg_event(&e_sys, e_cpu, DISPATCH_LOCAL_DSQ_OFFLINE);
scx_agg_event(&e_sys, e_cpu, DISPATCH_KEEP_LAST);
+ scx_agg_event(&e_sys, e_cpu, BYPASS_DISPATCH);
scx_agg_event(&e_sys, e_cpu, BYPASS_ACTIVATE);
}

--
2.48.1