[PATCH 1/2] sched_ext: Fix the running task keeping its protection into bypass
From: Tejun Heo
Date: Sat Oct 17 2026 - 01:37:42 EST
Protection ends when the scheduler enters bypass, so that bypass scheduling
can cut every task's slice. scx_bypass() clears it for the queued tasks by
cycling them, and strips the running task's in the same walk over
rq->scx.runnable_list. The running task is never on that list.
set_next_task_scx() takes it off and put_prev_task_scx() puts it back, so
the strip never runs. A protected running task then keeps its slice into
bypass, where the tick's attempts to cut it are refused.
Strip the running task's protection outside the walk.
Fixes: 9cfc6ab34a31 ("sched_ext: Add SCX_TASK_PROTECTED")
Signed-off-by: Tejun Heo <tj@xxxxxxxxxx>
---
kernel/sched/ext/ext.c | 17 ++++++++++-------
1 file changed, 10 insertions(+), 7 deletions(-)
diff --git a/kernel/sched/ext/ext.c b/kernel/sched/ext/ext.c
index 2c213153bdab..d6689bf8e769 100644
--- a/kernel/sched/ext/ext.c
+++ b/kernel/sched/ext/ext.c
@@ -6318,6 +6318,16 @@ void scx_bypass(struct scx_sched *sch, bool bypass)
continue;
}
+ /*
+ * Bypass trumps protection. Cycling the queued tasks below
+ * clears theirs. The current task isn't on the runnable list,
+ * so strip its protection here.
+ */
+ p = rq->curr;
+ if (bypass && p->sched_class == &ext_sched_class &&
+ scx_is_descendant(scx_task_sched(p), sch))
+ scx_task_slice_ended(rq, p);
+
/*
* The use of list_for_each_entry_safe_reverse() is required
* because each task is going to be removed from and added back
@@ -6330,13 +6340,6 @@ void scx_bypass(struct scx_sched *sch, bool bypass)
if (!scx_is_descendant(scx_task_sched(p), sch))
continue;
- /*
- * Bypass trumps protection. Cycling clears for queued
- * tasks but current task needs explicit stripping.
- */
- if (bypass && task_current(rq, p))
- scx_task_slice_ended(rq, p);
-
/* cycling deq/enq is enough, see the function comment */
scoped_guard (sched_change, p, DEQUEUE_SAVE | DEQUEUE_MOVE) {
/* nothing */ ;
--
2.56.0