Documentation/scheduler/sched-ext.rst
Source file repositories/reference/linux-study-clean/Documentation/scheduler/sched-ext.rst
File Facts
- System
- Linux kernel
- Corpus path
Documentation/scheduler/sched-ext.rst- Extension
.rst- Size
- 23624 bytes
- Lines
- 565
- Domain
- Support Tooling And Documentation
- Bucket
- Documentation
- Inferred role
- Support Tooling And Documentation: documentation
- Status
- atlas-only
Why This File Exists
Repository support layer: documentation, build tooling, samples, user-space helper tools, generated initramfs support, licenses, and validation utilities.
- Repository support layer: documentation, build tooling, samples, user-space helper tools, generated initramfs support, licenses, and validation utilities.
- Defines or uses C structs; map object ownership, embedded links, reference counts, and lock ownership.
Dependency Surface
- No C-style include directives detected by the generator.
Detected Declarations
function DSQsfunction BPF_STRUCT_OPSfunction BPF_STRUCT_OPS_SLEEPABLEfunction BPF_STRUCT_OPS
Annotated Snippet
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(task)) {
if (task is not in a DSQ || task->scx.slice == 0) {
ops.enqueue(); /* Task can be added to a DSQ */
/* Task property change (i.e., affinity, nice, etc.)? */
if (sched_change(task)) {
ops.dequeue(); /* Exiting BPF scheduler custody */
ops.quiescent();
/* Property change callback, e.g. ops.set_weight() */
ops.runnable();
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(task) && task->scx.slice > 0) {
ops.tick(); /* Called every 1/HZ seconds */
if (task->scx.slice == 0)
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) */
}
ops.disable(); /* Disable BPF scheduling for the task */
ops.exit_task(); /* Task is destroyed */
Note that the above pseudo-code does not cover all possible state transitions
and edge cases, to name a few examples:
* ``ops.dispatch()`` may fail to move the task to a local DSQ due to a racing
property change on that task, in which case ``ops.dispatch()`` will be
retried.
* The task may be direct-dispatched to a local DSQ from ``ops.enqueue()``,
in which case ``ops.dispatch()`` and ``ops.dequeue()`` are skipped and we go
straight to ``ops.running()``.
* Property changes may occur at virtually any point during the task's lifecycle,
not just when the task is queued and waiting to be dispatched. For example,
changing a property of a running task will lead to the callback sequence
``ops.stopping()`` -> ``ops.quiescent()`` -> (property change callback) ->
``ops.runnable()`` -> ``ops.running()``.
* A sched_ext task can be preempted by a task from a higher-priority scheduling
class, in which case it will exit the tick-dispatch loop even though it is runnable
and has a non-zero slice.
See the "Scheduling Cycle" section for a more detailed description of how
a freshly woken up task gets on a CPU.
Where to Look
Annotation
- Detected declarations: `function DSQs`, `function BPF_STRUCT_OPS`, `function BPF_STRUCT_OPS_SLEEPABLE`, `function BPF_STRUCT_OPS`.
- Atlas domain: Support Tooling And Documentation / Documentation.
- Implementation status: atlas-only.
Implementation Notes
- This generated page is the file-by-file coverage layer; curated subsystem chapters should link here when they synthesize a multi-file control flow.
- Core OS pages should be promoted from atlas-only to deep-reviewed when they explain data structures, invariants, locking, lifecycle, and C implementation snippets.
- Driver-family pages are intentionally pattern-oriented unless they are part of the selected PCIe/NVMe representative device path.