Re: [PATCH v3] sched: Reset cpumask if __migrate_task() failed for migration_cpu_stop()
From: Karl Mehltretter
Date: Sat Nov 21 2026 - 08:20:43 EST
On Fri, 20 Nov 2026 18:16:58 +0100, Sebastian Andrzej Siewior wrote:
> if (task_on_rq_queued(p)) {
> update_rq_clock(rq);
> rq = __migrate_task(rq, &rf, p, arg->dest_cpu);
> + if (rq != cpu_rq(arg->dest_cpu)) {
> + struct affinity_context ac = {
> + .new_mask = cpumask_of(rq->cpu),
> + };
> +
> + do_set_cpus_allowed(p, &ac);
> + }
do_set_cpus_allowed() updates the rq clock a second time here, through
sched_change_begin() without DEQUEUE_NOCLOCK. With WARN_DOUBLE_CLOCK
enabled:
WARNING: kernel/sched/core.c:881 at update_rq_clock+0x4c7/0x560, CPU#0: migration/0/22
Stopper: migration_cpu_stop+0x0/0xbe0 <- __set_cpus_allowed_ptr_locked+0xd1e/0x19c0
sched_change_begin+0x14d/0x660
migration_cpu_stop+0x5f6/0xbe0
cpu_stopper_thread+0x25e/0x3f0
Seen on v7.4-rc3 with this patch (RT and non-RT) with sched_setaffinity() loops
while another loop writes off and on to /sys/devices/system/cpu/smt/control.
Thanks,
Karl