From a4f61f0a1afdb3c07025b91379f5c46dd89eb817 Mon Sep 17 00:00:00 2001 From: Andrea Righi Date: Mon, 6 Apr 2026 13:47:55 +0200 Subject: [PATCH] sched_ext: Documentation: Add ops.dequeue() to task lifecycle Document ops.dequeue() in the sched_ext task lifecycle now that its semantics are well-defined. Also update the pseudo-code to use task_is_runnable() consistently and clarify the case where ops.dispatch() does not refill the time slice. Signed-off-by: Andrea Righi Reviewed-by: Emil Tsalapatis Signed-off-by: Tejun Heo --- Documentation/scheduler/sched-ext.rst | 26 ++++++++++++++++---------- 1 file changed, 16 insertions(+), 10 deletions(-) diff --git a/Documentation/scheduler/sched-ext.rst b/Documentation/scheduler/sched-ext.rst index 404b4e4c33f7..9f03650abfeb 100644 --- a/Documentation/scheduler/sched-ext.rst +++ b/Documentation/scheduler/sched-ext.rst @@ -422,23 +422,29 @@ by a sched_ext scheduler: ops.runnable(); /* Task becomes ready to run */ - while (task is runnable) { + while (task_is_runnable(task)) { if (task is not in a DSQ && task->scx.slice == 0) { ops.enqueue(); /* Task can be added to a DSQ */ - /* Any usable CPU becomes available */ - - ops.dispatch(); /* Task is moved to a local DSQ */ - - ops.dequeue(); /* Exiting BPF scheduler */ + /* Task property change (i.e., affinity, nice, etc.)? */ + if (sched_change(task)) { + ops.dequeue(); /* Exiting BPF scheduler custody */ + continue; + } } + + /* Any usable CPU becomes available */ + + ops.dispatch(); /* Task is moved to a local DSQ */ + ops.dequeue(); /* Exiting BPF scheduler custody */ + ops.running(); /* Task starts running on its assigned CPU */ - while task_is_runnable(p) { - while (task->scx.slice > 0 && task_is_runnable(p)) - ops.tick(); /* Called every 1/HZ seconds */ + while (task_is_runnable(task) && task->scx.slice > 0) { + ops.tick(); /* Called every 1/HZ seconds */ - ops.dispatch(); /* task->scx.slice can be refilled */ + if (task->scx.slice == 0) + ops.dispatch(); /* task->scx.slice can be refilled */ } ops.stopping(); /* Task stops running (time slice expires or wait) */