summaryrefslogtreecommitdiff
path: root/kernel
diff options
context:
space:
mode:
authorTejun Heo <tj@kernel.org>2026-10-16 19:37:16 -1000
committerTejun Heo <tj@kernel.org>2026-10-17 04:35:31 -1000
commit30fb2b1e4d41a641a059f295a717ffa0e24307e7 (patch)
treee0e73db5e5da9ccc45b6a8e4d9f55abd01d05c74 /kernel
parent43e1ef14a47257ebf7e3bb3ab9a6df9c6f817c5f (diff)
downloadlinux-30fb2b1e4d41a641a059f295a717ffa0e24307e7.tar.gz
linux-30fb2b1e4d41a641a059f295a717ffa0e24307e7.zip
sched_ext: Fix the running task keeping its protection into bypass
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@kernel.org> Reviewed-by: Andrea Righi <arighi@nvidia.com>
Diffstat (limited to 'kernel')
-rw-r--r--kernel/sched/ext/ext.c17
1 files 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
@@ -6319,6 +6319,16 @@ void scx_bypass(struct scx_sched *sch, bool bypass)
}
/*
+ * 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
* to the runnable_list during iteration. Because they're added
@@ -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 */ ;