Skip to contentSkip to conversation

sched_ext: Documentation: Clarify ops.dispatch() role in task lifecycle

PATCH Applied Andrea Righi 2 participants 2 messages Mar 25 – Mar 26

Subsystems (2)
lore
Share & tools
lore

Andrea Righi

author reviewer
#0 lore raw

PATCH 1/1 sched_ext: Documentation: Clarify ops.dispatch() role in task lifecycle

ops.dispatch() is invoked when a CPU becomes available. This can occur when a task voluntarily yields the CPU, exhausts its time slice, or is preempted for other reasons.

If the task is still runnable, refilling its time slice in ops.dispatch() (either by the BPF scheduler or the sched_ext core) allows it to continue running without triggering ops.stopping(). However, this behavior is not clearly reflected in the current task lifecycle diagram.

Update the diagram to better represent this interaction.

Fixes 9465f44d2df2 ("sched_ext: Documentation: Clarify time slice handling in task lifecycle")
Cc [email protected] # v6.17+
---
 Documentation/scheduler/sched-ext.rst | 12 +++++++-----
 1 file changed, 7 insertions(+), 5 deletions(-)
Documentation/scheduler/sched-ext.rst +7 -5
index 9e4dbabc03c0b..404b4e4c33f7e 100644
@@ -433,13 +433,15 @@ by a sched_ext scheduler:
                 ops.dequeue(); /* Exiting BPF scheduler */
             }
             ops.running();      /* Task starts running on its assigned CPU */
-            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 */
+            while task_is_runnable(p) {
+                while (task->scx.slice > 0 && task_is_runnable(p))
+                    ops.tick();     /* Called every 1/HZ seconds */
+
+                ops.dispatch();     /* task->scx.slice can be refilled */
+            }
 
-            ops.dispatch();     /* task->scx.slice can be refilled */
+            ops.stopping();     /* Task stops running (time slice expires or wait) */
         }
 
         ops.quiescent();        /* Task releases its assigned CPU (wait) */
Signature · 1 line
2.53.0
reviewer Applied
#1 lore raw

Applied to sched_ext/for-7.1.

Thanks.

Signature · 1 line
tejun