Re: [PATCH v3] sched_ext: include SCX_OPS_TRACK_MIGRATION
From: Tejun Heo
Date: Wed Jun 25 2025 - 19:07:16 EST
Hello,
On Tue, Jun 24, 2025 at 11:03:14AM +0800, Henry Huang wrote:
...
> We will traverse the per-CPU map information in ops.select_cpu() to select
> the appropriate CPU. To reduce the competition for the rq spinlock, tasks are
> likely to run on the CPU selected by ops.select_cpu().
>
> However, I can think of two scenarios where passive migration may occur:
> 1. set_task_allowed_cpus
> 2. cpu_stop
What do you mean by "passive migration"? The above two cases would still
travel ops.enqueue(). There are cases where ops.select_cpu()'s return value
or the local DSQ that ops.dispatch() targeted are overridden, mostly when
the CPU goes down inbetween. Are you referring to those cases?
> There may also be some passive migration scenarios that we haven't thought of.
> This could lead to incorrect information in the per-CPU map. Therefore,
> we hope to track enqueue_task_scx and dequeue_task_scx to ensure that the
> information in the per-CPU map is accurate.
Even in such cases, wouldn't something like the following work?
void my_running(struct task_struct *p)
{
struct my_task_ctx *taskc;
if (!(taskc = lookup_task_ctx(p)))
return;
if (taskc->cpu != scx_bpf_task_cpu(p)) {
/* update other stuff */
taskc->cpu = scx_bpf_task_cpu(p);
}
}
Thanks.
--
tejun