* [PATCH] sched_ext: Skip per-CPU tasks in scx_bpf_reenqueue_local()
@ 2025-03-13 17:03 Andrea Righi
2025-03-13 17:08 ` Tejun Heo
0 siblings, 1 reply; 2+ messages in thread
From: Andrea Righi @ 2025-03-13 17:03 UTC (permalink / raw)
To: Tejun Heo, David Vernet, Changwoo Min; +Cc: Joel Fernandes, linux-kernel
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 <arighi@nvidia.com>
---
kernel/sched/ext.c | 6 +++++-
1 file changed, 5 insertions(+), 1 deletion(-)
diff --git a/kernel/sched/ext.c b/kernel/sched/ext.c
index 7b9dfee858e79..22f979f9acde2 100644
--- a/kernel/sched/ext.c
+++ b/kernel/sched/ext.c
@@ -6972,8 +6972,12 @@ __bpf_kfunc u32 scx_bpf_reenqueue_local(void)
* CPUs disagree, they use %ENQUEUE_RESTORE which is bypassed to
* the current local DSQ for running tasks and thus are not
* visible to the BPF scheduler.
+ *
+ * Also skip re-enqueueing tasks that can only run on this
+ * CPU, as they would just be re-added to the same local
+ * DSQ without any benefit.
*/
- if (p->migration_pending)
+ if (p->migration_pending || is_migration_disabled(p) || p->nr_cpus_allowed == 1)
continue;
dispatch_dequeue(rq, p);
--
2.48.1
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: [PATCH] sched_ext: Skip per-CPU tasks in scx_bpf_reenqueue_local()
2025-03-13 17:03 [PATCH] sched_ext: Skip per-CPU tasks in scx_bpf_reenqueue_local() Andrea Righi
@ 2025-03-13 17:08 ` Tejun Heo
0 siblings, 0 replies; 2+ messages in thread
From: Tejun Heo @ 2025-03-13 17:08 UTC (permalink / raw)
To: Andrea Righi; +Cc: David Vernet, Changwoo Min, Joel Fernandes, linux-kernel
On Thu, Mar 13, 2025 at 06:03:21PM +0100, Andrea Righi wrote:
> 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 <arighi@nvidia.com>
Applied to sched_ext/for-6.15.
Thanks.
--
tejun
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2025-03-13 17:08 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2025-03-13 17:03 [PATCH] sched_ext: Skip per-CPU tasks in scx_bpf_reenqueue_local() Andrea Righi
2025-03-13 17:08 ` Tejun Heo
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®