mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [RFC PATCH] sched/ext: add sched_info_enqueue in dispatch path for schedstat
@ 2026-05-25 19:19 Fernand Sieber
  2026-05-27 19:31 ` Tejun Heo
  0 siblings, 1 reply; 2+ messages in thread
From: Fernand Sieber @ 2026-05-25 19:19 UTC (permalink / raw)
  To: Tejun Heo, David Vernet
  Cc: Andrea Righi, Changwoo Min, Ingo Molnar, Peter Zijlstra,
	Vincent Guittot, linux-kernel, nh-open-source, Fahad Mubeen,
	Hendrik Borghorst, David Woodhouse, Fernand Sieber

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.

Signed-off-by: Fernand Sieber <sieberf@amazon.com>
---
 kernel/sched/ext.c | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/kernel/sched/ext.c b/kernel/sched/ext.c
index 7ebdaf75d..827a96e39 100644
--- a/kernel/sched/ext.c
+++ b/kernel/sched/ext.c
@@ -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);
-- 
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


^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2026-05-27 19:31 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-05-25 19:19 [RFC PATCH] sched/ext: add sched_info_enqueue in dispatch path for schedstat Fernand Sieber
2026-05-27 19:31 ` Tejun Heo

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®