sched/ext: add sched_info_enqueue in dispatch path for schedstat
RFC PATCH 1/1 sched/ext: add sched_info_enqueue in dispatch path for schedstat
SCX tasks re-dispatched from BPF (e.g., after bandwidth throttling) bypass enqueue_task() and go directly through dispatch_enqueue(). This skips sched_info_enqueue(), leaving last_queued at 0, which prevents run_delay from accumulating in /proc/<pid>/schedstat.
Add sched_info_enqueue() in dispatch_enqueue() when last_queued is not already set. This ensures run_delay correctly reflects the time a task spends waiting for a CPU after being dispatched, including time spent in BPF-managed throttle queues.
Without this fix, schedstat shows frozen run_delay values for SCX tasks that go through throttle/unthrottle cycles.
--- kernel/sched/ext.c | 4 ++++ 1 file changed, 4 insertions(+)
kernel/sched/ext.c +4 -0
@@ -1525,6 +1525,10 @@ static void dispatch_enqueue(struct scx_sched *sch, struct rq *rq,WARN_ON_ONCE ((p->scx.dsq_flags &SCX_TASK_DSQ_ON_PRIQ ) || !RB_EMPTY_NODE (&p->scx.dsq_priq)); +/* Track queue time for schedstat run_delay accounting */ +if (!p->sched_info.last_queued) +sched_info_enqueue (task_rq (p), p); +if (!is_local) {raw_spin_lock_nested (&dsq->lock, (enq_flags &SCX_ENQ_NESTED ) ?SINGLE_DEPTH_NESTING :0 );
Signature · 8 lines
2.47.3 Amazon Development Centre (South Africa) (Proprietary) Limited 29 Gogosoa Street, Observatory, Cape Town, Western Cape, 7925, South Africa Registration Number: 2004 / 034463 / 07
Quoted 23 lines · Fernand Sieber
SCX tasks re-dispatched from BPF (e.g., after bandwidth throttling) bypass
enqueue_task()and go directly throughdispatch_enqueue(). This skipssched_info_enqueue(), leavinglast_queuedat 0, which preventsrun_delayfrom accumulating in /proc/<pid>/schedstat.Add
sched_info_enqueue()indispatch_enqueue()whenlast_queuedis not already set. This ensuresrun_delaycorrectly reflects the time a task spends waiting for a CPU after being dispatched, including time spent in BPF-managed throttle queues.Without this fix, schedstat shows frozen
run_delayvalues for SCX tasks that go through throttle/unthrottle cycles.Signed-off-by Fernand Sieber <[email protected]>--- kernel/sched/ext.c | 4 ++++ 1 file changed, 4 insertions(+)kernel/sched/ext.c +0
-0
kernel/sched/ext.c static void dispatch_enqueue(struct scx_sched *sch, struct rq *rq, · line 1530
Quoted 6 lines
kernel/sched/ext.c +3
-0@@ -1525,6 +1525,10 @@ static void dispatch_enqueue(struct scx_sched *sch, struct rq *rq,WARN_ON_ONCE ((p->scx.dsq_flags &SCX_TASK_DSQ_ON_PRIQ ) || !RB_EMPTY_NODE (&p->scx.dsq_priq)); +/* Track queue time for schedstat run_delay accounting */ +if (!p->sched_info.last_queued) +sched_info_enqueue (task_rq (p), p);
I don't think this works. A DSQ can be used for throttling too and a BPF data structure can be used for non-throttling queueing too. I don't see how doing the above unconditionally would capture something meaningful reliably.
Thanks.
Signature · 1 line
tejun