Skip to content

Commit 97e13ec

Browse files
arighihtejun
authored andcommitted
sched_ext: Skip per-CPU tasks in scx_bpf_reenqueue_local()
scx_bpf_reenqueue_local() can be invoked from ops.cpu_release() to give tasks that are queued to the local DSQ a chance to migrate to other CPUs, when a CPU is taken by a higher scheduling class. However, there is no point re-enqueuing tasks that can only run on that particular CPU, as they would simply be re-added to the same local DSQ without any benefit. Therefore, skip per-CPU tasks in scx_bpf_reenqueue_local(). Signed-off-by: Andrea Righi <[email protected]> Signed-off-by: Tejun Heo <[email protected]>
1 parent 71d0788 commit 97e13ec

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

kernel/sched/ext.c

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6621,8 +6621,12 @@ __bpf_kfunc u32 scx_bpf_reenqueue_local(void)
66216621
* CPUs disagree, they use %ENQUEUE_RESTORE which is bypassed to
66226622
* the current local DSQ for running tasks and thus are not
66236623
* visible to the BPF scheduler.
6624+
*
6625+
* Also skip re-enqueueing tasks that can only run on this
6626+
* CPU, as they would just be re-added to the same local
6627+
* DSQ without any benefit.
66246628
*/
6625-
if (p->migration_pending)
6629+
if (p->migration_pending || is_migration_disabled(p) || p->nr_cpus_allowed == 1)
66266630
continue;
66276631

66286632
dispatch_dequeue(rq, p);

0 commit comments

Comments
 (0)