From 9465f44d2df21b43f062de303e59e2b391eeab16 Mon Sep 17 00:00:00 2001 From: Andrea Righi Date: Mon, 9 Jun 2025 18:23:42 +0200 Subject: [PATCH] sched_ext: Documentation: Clarify time slice handling in task lifecycle It is not always obvious how a task's time slice can be refilled, either explicitly from ops.dispatch() or automatically by the sched_ext core, to skip subsequent ops.enqueue() and ops.dispatch() calls. This typically happens when the task is the only one running on a CPU. To make this behavior easier to understand, update the task lifecycle diagram to explicitly document how time slice handling works in such cases. Signed-off-by: Andrea Righi Signed-off-by: Tejun Heo --- Documentation/scheduler/sched-ext.rst | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/Documentation/scheduler/sched-ext.rst b/Documentation/scheduler/sched-ext.rst index a1869c38046ed..404fe6126a769 100644 --- a/Documentation/scheduler/sched-ext.rst +++ b/Documentation/scheduler/sched-ext.rst @@ -313,16 +313,21 @@ by a sched_ext scheduler: ops.runnable(); /* Task becomes ready to run */ while (task is runnable) { - if (task is not in a DSQ) { + if (task is not in a DSQ && task->scx.slice == 0) { ops.enqueue(); /* Task can be added to a DSQ */ - /* A CPU becomes available */ + /* Any usable CPU becomes available */ ops.dispatch(); /* Task is moved to a local DSQ */ } ops.running(); /* Task starts running on its assigned CPU */ - ops.tick(); /* Called every 1/HZ seconds */ + while (task->scx.slice > 0 && task is runnable) + ops.tick(); /* Called every 1/HZ seconds */ ops.stopping(); /* Task stops running (time slice expires or wait) */ + + /* Task's CPU becomes available */ + + ops.dispatch(); /* task->scx.slice can be refilled */ } ops.quiescent(); /* Task releases its assigned CPU (wait) */ -- 2.47.2