Skip to content

Commit aebe7ae

Browse files
committed
sched_ext: bypass mode shouldn't depend on ops.select_cpu()
Bypass mode was depending on ops.select_cpu() which can't be trusted as with the rest of the BPF scheduler. Always enable and use scx_select_cpu_dfl() in bypass mode. Signed-off-by: Tejun Heo <[email protected]> Acked-by: David Vernet <[email protected]>
1 parent cc3e1ca commit aebe7ae

File tree

1 file changed

+15
-13
lines changed

1 file changed

+15
-13
lines changed

kernel/sched/ext.c

Lines changed: 15 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -3126,7 +3126,7 @@ static int select_task_rq_scx(struct task_struct *p, int prev_cpu, int wake_flag
31263126
if (unlikely(wake_flags & WF_EXEC))
31273127
return prev_cpu;
31283128

3129-
if (SCX_HAS_OP(select_cpu)) {
3129+
if (SCX_HAS_OP(select_cpu) && !scx_rq_bypassing(task_rq(p))) {
31303130
s32 cpu;
31313131
struct task_struct **ddsp_taskp;
31323132

@@ -3191,7 +3191,7 @@ void __scx_update_idle(struct rq *rq, bool idle)
31913191
{
31923192
int cpu = cpu_of(rq);
31933193

3194-
if (SCX_HAS_OP(update_idle)) {
3194+
if (SCX_HAS_OP(update_idle) && !scx_rq_bypassing(rq)) {
31953195
SCX_CALL_OP(SCX_KF_REST, update_idle, cpu_of(rq), idle);
31963196
if (!static_branch_unlikely(&scx_builtin_idle_enabled))
31973197
return;
@@ -4254,21 +4254,23 @@ bool task_should_scx(struct task_struct *p)
42544254
* the DISABLING state and then cycling the queued tasks through dequeue/enqueue
42554255
* to force global FIFO scheduling.
42564256
*
4257-
* a. ops.enqueue() is ignored and tasks are queued in simple global FIFO order.
4258-
* %SCX_OPS_ENQ_LAST is also ignored.
4257+
* - ops.select_cpu() is ignored and the default select_cpu() is used.
42594258
*
4260-
* b. ops.dispatch() is ignored.
4259+
* - ops.enqueue() is ignored and tasks are queued in simple global FIFO order.
4260+
* %SCX_OPS_ENQ_LAST is also ignored.
42614261
*
4262-
* c. balance_scx() does not set %SCX_RQ_BAL_KEEP on non-zero slice as slice
4263-
* can't be trusted. Whenever a tick triggers, the running task is rotated to
4264-
* the tail of the queue with core_sched_at touched.
4262+
* - ops.dispatch() is ignored.
42654263
*
4266-
* d. pick_next_task() suppresses zero slice warning.
4264+
* - balance_scx() does not set %SCX_RQ_BAL_KEEP on non-zero slice as slice
4265+
* can't be trusted. Whenever a tick triggers, the running task is rotated to
4266+
* the tail of the queue with core_sched_at touched.
42674267
*
4268-
* e. scx_bpf_kick_cpu() is disabled to avoid irq_work malfunction during PM
4269-
* operations.
4268+
* - pick_next_task() suppresses zero slice warning.
42704269
*
4271-
* f. scx_prio_less() reverts to the default core_sched_at order.
4270+
* - scx_bpf_kick_cpu() is disabled to avoid irq_work malfunction during PM
4271+
* operations.
4272+
*
4273+
* - scx_prio_less() reverts to the default core_sched_at order.
42724274
*/
42734275
static void scx_ops_bypass(bool bypass)
42744276
{
@@ -4338,7 +4340,7 @@ static void scx_ops_bypass(bool bypass)
43384340

43394341
rq_unlock_irqrestore(rq, &rf);
43404342

4341-
/* kick to restore ticks */
4343+
/* resched to restore ticks and idle state */
43424344
resched_cpu(cpu);
43434345
}
43444346
}

0 commit comments

Comments
 (0)