diff options
| author | Andrea Righi <arighi@nvidia.com> | 2026-09-18 19:13:27 +0200 |
|---|---|---|
| committer | Tejun Heo <tj@kernel.org> | 2026-09-18 14:19:16 -1000 |
| commit | f8e5a4e3f3bea6b389ae8dbeafe50fdb8ab543b2 (patch) | |
| tree | 61431fb42574aff25185e6a99a28cb430b3e02f3 /include/linux | |
| parent | 46eb991947d45f7e3bf4fc9d9e3b1c3454627400 (diff) | |
| download | linux-next-f8e5a4e3f3bea6b389ae8dbeafe50fdb8ab543b2.tar.gz linux-next-f8e5a4e3f3bea6b389ae8dbeafe50fdb8ab543b2.zip | |
sched_ext: Add lazy preemption support
The fair scheduling class can request lazy rescheduling, deferring an
in-kernel scheduling boundary until returning to user space or until the
next scheduler tick. sched_ext only exposes immediate preemption,
preventing BPF schedulers from making the same trade-off.
Add SCX_ENQ_PREEMPT_LAZY and SCX_KICK_PREEMPT_LAZY. Both expire the
current sched_ext task slice but request lazy rescheduling. Immediate
preemption, WAIT and plain kicks take precedence when requests are
combined, while a lazy enqueue to a non-local DSQ retains the
head-insertion semantics of SCX_ENQ_PREEMPT.
Add SCX_OPS_LAZY_RESCHED as the default slice-expiry policy for newly
enabled tasks and initialize it before ops.enable(). Add
scx_bpf_task_set_lazy_resched() so the owning scheduler can override the
persistent policy per task from any callback while preserving
sub-scheduler task ownership boundaries. Bypass continues to force
immediate rescheduling.
For an infinite-slice task whose tick is stopped, set the lazy
reschedule request before restoring the scheduler tick dependency. This
lets the dependency update's IPI serve the request on return to user
space and guarantees that the next tick promotes it otherwise. Use
pinned rq locking for remote kick delivery so RQCF_UPDATED reflects
clock updates since lock acquisition.
Accumulate kick requests independently and resolve precedence while
holding the target rq lock. Reject invalid SCX_KICK_IDLE combinations
and unknown kick flags, which were previously silently ignored.
Tested-by: Tao Cui <cuitao@kylinos.cn>
Signed-off-by: Andrea Righi <arighi@nvidia.com>
Signed-off-by: Tejun Heo <tj@kernel.org>
Diffstat (limited to 'include/linux')
| -rw-r--r-- | include/linux/sched/ext.h | 8 |
1 files changed, 8 insertions, 0 deletions
diff --git a/include/linux/sched/ext.h b/include/linux/sched/ext.h index 8de69843c215..1e1fc3312bc4 100644 --- a/include/linux/sched/ext.h +++ b/include/linux/sched/ext.h @@ -278,6 +278,14 @@ struct sched_ext_entity { */ bool disallow; /* reject switching into SCX */ + /* + * If set, depletion of this task's slice at the scheduler tick requests + * lazy instead of immediate rescheduling. Initialized from + * %SCX_OPS_LAZY_RESCHED immediately before ops.enable() and may be + * modified afterwards with scx_bpf_task_set_lazy_resched(). + */ + bool lazy_resched; + /* cold fields */ #ifdef CONFIG_EXT_GROUP_SCHED struct cgroup *cgrp_moving_from; |
