Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

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 <arighi@nvidia.com>
Signed-off-by: Tejun Heo <tj@kernel.org>

authored by

Andrea Righi and committed by
Tejun Heo
9465f44d 086ed90a

+8 -3
+8 -3
Documentation/scheduler/sched-ext.rst
··· 313 313 ops.runnable(); /* Task becomes ready to run */ 314 314 315 315 while (task is runnable) { 316 - if (task is not in a DSQ) { 316 + if (task is not in a DSQ && task->scx.slice == 0) { 317 317 ops.enqueue(); /* Task can be added to a DSQ */ 318 318 319 - /* A CPU becomes available */ 319 + /* Any usable CPU becomes available */ 320 320 321 321 ops.dispatch(); /* Task is moved to a local DSQ */ 322 322 } 323 323 ops.running(); /* Task starts running on its assigned CPU */ 324 - ops.tick(); /* Called every 1/HZ seconds */ 324 + while (task->scx.slice > 0 && task is runnable) 325 + ops.tick(); /* Called every 1/HZ seconds */ 325 326 ops.stopping(); /* Task stops running (time slice expires or wait) */ 327 + 328 + /* Task's CPU becomes available */ 329 + 330 + ops.dispatch(); /* task->scx.slice can be refilled */ 326 331 } 327 332 328 333 ops.quiescent(); /* Task releases its assigned CPU (wait) */