[PATCH 1/2] sched_ext: Enable tick for finite slices on nohz_full
From: Andrea Righi
Date: Mon Jul 06 2026 - 12:51:35 EST
set_next_task_scx() updates the tick dependency before __schedule()
updates rq->curr. When switching from a non-EXT task, such as idle, to
an EXT task with a finite slice, sched_update_tick_dependency() checks
the outgoing task and can allow the tick to remain stopped. The incoming
task can then fail to receive the ticks needed to expire its slice.
A finite slice is sufficient by itself to require the tick, so set
TICK_DEP_BIT_SCHED directly when transitioning to a finite slice. Keep
using sched_update_tick_dependency() when transitioning to an infinite
slice so that the scheduler evaluates all runqueue requirements before
clearing the dependency.
Fixes: 22a920209ab6 ("sched_ext: Implement tickless support")
Signed-off-by: Andrea Righi <arighi@xxxxxxxxxx>
---
kernel/sched/ext/ext.c | 14 +++++++++++---
1 file changed, 11 insertions(+), 3 deletions(-)
diff --git a/kernel/sched/ext/ext.c b/kernel/sched/ext/ext.c
index e75e2fd5ab7e3..dc20a8eed8f6c 100644
--- a/kernel/sched/ext/ext.c
+++ b/kernel/sched/ext/ext.c
@@ -2982,12 +2982,20 @@ static void set_next_task_scx(struct rq *rq, struct task_struct *p, bool first)
*/
if ((p->scx.slice == SCX_SLICE_INF) !=
(bool)(rq->scx.flags & SCX_RQ_CAN_STOP_TICK)) {
- if (p->scx.slice == SCX_SLICE_INF)
+ if (p->scx.slice == SCX_SLICE_INF) {
rq->scx.flags |= SCX_RQ_CAN_STOP_TICK;
- else
+ sched_update_tick_dependency(rq);
+ } else {
rq->scx.flags &= ~SCX_RQ_CAN_STOP_TICK;
- sched_update_tick_dependency(rq);
+ /*
+ * The rq still references the outgoing scheduling context.
+ * A finite slice is sufficient by itself to require the tick.
+ */
+ if (tick_nohz_full_cpu(cpu_of(rq)))
+ tick_nohz_dep_set_cpu(cpu_of(rq),
+ TICK_DEP_BIT_SCHED);
+ }
/*
* For now, let's refresh the load_avgs just when transitioning
--
2.55.0