[PATCH v2 06/11] sched_ext: Add an event, ENQ_SKIP_EXITING

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

Add a core event, ENQ_SKIP_EXITING, which represents how many times
a task is enqueued to a local DSQ when exiting if SCX_OPS_ENQ_EXITING
is not set.

__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 | 11 ++++++++++-
1 file changed, 10 insertions(+), 1 deletion(-)

diff --git a/kernel/sched/ext.c b/kernel/sched/ext.c
index d3a1ef58202c..6dc86bc06596 100644
--- a/kernel/sched/ext.c
+++ b/kernel/sched/ext.c
@@ -1479,6 +1479,12 @@ struct scx_event_stats {
* continued to run because there were no other tasks on the CPU.
*/
u64 DISPATCH_KEEP_LAST;
+
+ /*
+ * If SCX_OPS_ENQ_EXITING is not set, the number of times that a task
+ * is dispatched to a local DSQ when exiting.
+ */
+ u64 ENQ_SKIP_EXITING;
};

/*
@@ -2086,8 +2092,10 @@ static void do_enqueue_task(struct rq *rq, struct task_struct *p, u64 enq_flags,

/* see %SCX_OPS_ENQ_EXITING */
if (!static_branch_unlikely(&scx_ops_enq_exiting) &&
- unlikely(p->flags & PF_EXITING))
+ unlikely(p->flags & PF_EXITING)) {
+ __scx_add_event(ENQ_SKIP_EXITING, 1);
goto local;
+ }

if (!SCX_HAS_OP(enqueue))
goto global;
@@ -5508,6 +5516,7 @@ static void scx_dump_state(struct scx_exit_info *ei, size_t dump_len)
scx_dump_event(s, &events, SELECT_CPU_FALLBACK);
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);

if (seq_buf_has_overflowed(&s) && dump_len >= sizeof(trunc_marker))
memcpy(ei->dump + dump_len - sizeof(trunc_marker),
--
2.48.1