[PATCH v2 07/11] sched_ext: Add an event, BYPASS_ACTIVATE

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

Add a core event, BYPASS_ACTIVATE, which represents how many times
the bypass mode has been triggered.

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 6dc86bc06596..bb363809e484 100644
--- a/kernel/sched/ext.c
+++ b/kernel/sched/ext.c
@@ -1485,6 +1485,11 @@ struct scx_event_stats {
* is dispatched to a local DSQ when exiting.
*/
u64 ENQ_SKIP_EXITING;
+
+ /*
+ * The number of times the bypassing mode has been activated.
+ */
+ u64 BYPASS_ACTIVATE;
};

/*
@@ -3707,6 +3712,7 @@ static int select_task_rq_scx(struct task_struct *p, int prev_cpu, int wake_flag
p->scx.slice = SCX_SLICE_DFL;
p->scx.ddsp_dsq_id = SCX_DSQ_LOCAL;
}
+
return cpu;
}
}
@@ -4922,6 +4928,7 @@ static void scx_ops_bypass(bool bypass)
WARN_ON_ONCE(scx_ops_bypass_depth <= 0);
if (scx_ops_bypass_depth != 1)
goto unlock;
+ scx_add_event(BYPASS_ACTIVATE, 1);
} else {
scx_ops_bypass_depth--;
WARN_ON_ONCE(scx_ops_bypass_depth < 0);
@@ -5517,6 +5524,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_ACTIVATE);

if (seq_buf_has_overflowed(&s) && dump_len >= sizeof(trunc_marker))
memcpy(ei->dump + dump_len - sizeof(trunc_marker),
@@ -7848,6 +7856,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_ACTIVATE);
}

/*
--
2.48.1