* [PATCH] sched_ext: Documentation: add task lifecycle summary
@ 2025-02-27 15:57 Andrea Righi
2025-02-27 16:28 ` Tejun Heo
0 siblings, 1 reply; 2+ messages in thread
From: Andrea Righi @ 2025-02-27 15:57 UTC (permalink / raw)
To: Tejun Heo, David Vernet, Changwoo Min
Cc: Jonathan Corbet, linux-doc, linux-kernel
Understanding the lifecycle of a task in sched_ext can be not trivial,
therefore add a section to the main documentation that summarizes the
entire workflow of a task using pseudo-code.
Signed-off-by: Andrea Righi <arighi@nvidia.com>
---
Documentation/scheduler/sched-ext.rst | 36 +++++++++++++++++++++++++++
1 file changed, 36 insertions(+)
diff --git a/Documentation/scheduler/sched-ext.rst b/Documentation/scheduler/sched-ext.rst
index c4672d7df2f73..0993e41353db7 100644
--- a/Documentation/scheduler/sched-ext.rst
+++ b/Documentation/scheduler/sched-ext.rst
@@ -294,6 +294,42 @@ dispatching, and must be dispatched to with ``scx_bpf_dsq_insert()``. See
the function documentation and usage in ``tools/sched_ext/scx_simple.bpf.c``
for more information.
+Task Lifecycle
+--------------
+
+The following pseudo-code summarizes the entire lifecycle of a task managed
+by a sched_ext scheduler:
+
+.. code-block:: c
+
+ ops.init_task(); /* A new task is created */
+ ops.enable(); /* Enable BPF scheduling for the task */
+
+ while (task in SCHED_EXT) {
+ if (task can migrate)
+ ops.select_cpu(); /* Called on wakeup (optimization) */
+
+ ops.runnable(); /* Task becomes ready to run */
+
+ while (task is runnable) {
+ if (task is not in a DSQ) {
+ ops.enqueue(); /* Task can be added to a DSQ */
+
+ /* A 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 */
+ ops.stopping(); /* Task stops running (time slice expires or wait) */
+ }
+
+ ops.quiescent(); /* Task releases its assigned CPU (wait) */
+ }
+
+ ops.disable(); /* Disable BPF scheduling for the task */
+ ops.exit_task(); /* Task is destroyed */
+
Where to Look
=============
--
2.48.1
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH] sched_ext: Documentation: add task lifecycle summary
2025-02-27 15:57 [PATCH] sched_ext: Documentation: add task lifecycle summary Andrea Righi
@ 2025-02-27 16:28 ` Tejun Heo
0 siblings, 0 replies; 2+ messages in thread
From: Tejun Heo @ 2025-02-27 16:28 UTC (permalink / raw)
To: Andrea Righi
Cc: David Vernet, Changwoo Min, Jonathan Corbet, linux-doc,
linux-kernel
On Thu, Feb 27, 2025 at 04:57:33PM +0100, Andrea Righi wrote:
> Understanding the lifecycle of a task in sched_ext can be not trivial,
> therefore add a section to the main documentation that summarizes the
> entire workflow of a task using pseudo-code.
>
> Signed-off-by: Andrea Righi <arighi@nvidia.com>
Applied to sched_ext/for-6.15.
Thanks.
--
tejun
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2025-02-27 16:28 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-02-27 15:57 [PATCH] sched_ext: Documentation: add task lifecycle summary Andrea Righi
2025-02-27 16:28 ` Tejun Heo
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox