aboutsummaryrefslogtreecommitdiffstats
path: root/kernel
diff options
context:
space:
mode:
authorChangwoo Min <changwoo@igalia.com>2025-01-31 16:09:31 +0900
committerTejun Heo <tj@kernel.org>2025-02-02 07:23:18 -1000
commit7125660bc16b7e87665bc859e7337388bdb63e0a (patch)
treef5bc55e0cdcd409aa46291ba273665d5b6cdb221 /kernel
parentsched_ext: Add an event, SCX_EV_DISPATCH_LOCAL_DSQ_OFFLINE (diff)
downloadlinux-7125660bc16b7e87665bc859e7337388bdb63e0a.tar.gz
linux-7125660bc16b7e87665bc859e7337388bdb63e0a.zip
sched_ext: Add an event, SCX_EV_DISPATCH_KEEP_LAST
Add a core event, SCX_EV_DISPATCH_KEEP_LAST, which represents how many times a task is continued to run without ops.enqueue() when SCX_OPS_ENQ_LAST 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> Signed-off-by: Tejun Heo <tj@kernel.org>
Diffstat (limited to 'kernel')
-rw-r--r--kernel/sched/ext.c9
1 files changed, 9 insertions, 0 deletions
diff --git a/kernel/sched/ext.c b/kernel/sched/ext.c
index d1447f18381e..cbb3d059072f 100644
--- a/kernel/sched/ext.c
+++ b/kernel/sched/ext.c
@@ -1455,6 +1455,12 @@ struct scx_event_stats {
* the meantime. In this case, the task is bounced to the global DSQ.
*/
u64 SCX_EV_DISPATCH_LOCAL_DSQ_OFFLINE;
+
+ /*
+ * If SCX_OPS_ENQ_LAST is not set, the number of times that a task
+ * continued to run because there were no other tasks on the CPU.
+ */
+ u64 SCX_EV_DISPATCH_KEEP_LAST;
};
/*
@@ -2907,6 +2913,7 @@ no_tasks:
if (prev_on_rq && (!static_branch_unlikely(&scx_ops_enq_last) ||
scx_rq_bypassing(rq))) {
rq->scx.flags |= SCX_RQ_BAL_KEEP;
+ __scx_add_event(SCX_EV_DISPATCH_KEEP_LAST, 1);
goto has_tasks;
}
rq->scx.flags &= ~SCX_RQ_IN_BALANCE;
@@ -4977,6 +4984,7 @@ static void scx_dump_state(struct scx_exit_info *ei, size_t dump_len)
scx_bpf_events(&events, sizeof(events));
scx_dump_event(s, &events, SCX_EV_SELECT_CPU_FALLBACK);
scx_dump_event(s, &events, SCX_EV_DISPATCH_LOCAL_DSQ_OFFLINE);
+ scx_dump_event(s, &events, SCX_EV_DISPATCH_KEEP_LAST);
if (seq_buf_has_overflowed(&s) && dump_len >= sizeof(trunc_marker))
memcpy(ei->dump + dump_len - sizeof(trunc_marker),
@@ -7112,6 +7120,7 @@ __bpf_kfunc void scx_bpf_events(struct scx_event_stats *events,
e_cpu = per_cpu_ptr(&event_stats_cpu, cpu);
scx_agg_event(&e_sys, e_cpu, SCX_EV_SELECT_CPU_FALLBACK);
scx_agg_event(&e_sys, e_cpu, SCX_EV_DISPATCH_LOCAL_DSQ_OFFLINE);
+ scx_agg_event(&e_sys, e_cpu, SCX_EV_DISPATCH_KEEP_LAST);
}
/*