From: Peter Zijlstra <peterz@infradead.org>
To: Karl Mehltretter <kmehltretter@gmail.com>
Cc: Sebastian Andrzej Siewior <bigeasy@linutronix.de>,
linux-kernel@vger.kernel.org,
syzbot <syzbot+6835d5c11145e4f77057@syzkaller.appspotmail.com>,
Thomas Gleixner <tglx@kernel.org>, Radu Rendec <radu@rendec.net>,
Ingo Molnar <mingo@redhat.com>,
Juri Lelli <juri.lelli@redhat.com>,
Vincent Guittot <vincent.guittot@linaro.org>,
Dietmar Eggemann <dietmar.eggemann@arm.com>,
Steven Rostedt <rostedt@goodmis.org>,
Ben Segall <bsegall@google.com>, Mel Gorman <mgorman@suse.de>,
Valentin Schneider <vschneid@redhat.com>,
K Prateek Nayak <kprateek.nayak@amd.com>
Subject: Re: [PATCH v3] sched: Reset cpumask if __migrate_task() failed for migration_cpu_stop()
Date: Wed, 2 Dec 2026 15:42:40 +0100 [thread overview]
Message-ID: <20261202144240.GG2668564@noisy.programming.kicks-ass.net> (raw)
In-Reply-To: <20261128172430.69629-1-kmehltretter@gmail.com>
On Sat, Nov 28, 2026 at 06:24:30PM +0100, Karl Mehltretter wrote:
> On Thu, 26 Nov 2026 11:40:49 +0100, Peter Zijlstra wrote:
> > if (task_on_rq_queued(p)) {
> > + int cpu = arg->dest_cpu;
> > +
> > update_rq_clock(rq);
> > - rq = __migrate_task(rq, &rf, p, arg->dest_cpu);
> > + if (!is_cpu_allowed(p, cpu))
> > + cpu = select_fallback_rq(rq->cpu, p);
> > +
> > + rq = move_queued_task(rq, &rf, p, cpu);
>
> This deadlocks.
>
> select_fallback_rq() can end up in set_cpus_allowed_force(), which takes
> rq->lock again.
>
> That's similar issue as af13e5e437dc ("sched: Fix the do_set_cpus_allowed()
> locking fix").
>
> With your diff on tip/sched/core, IRQ/user affinity changes racing with CPU
> hotplug hang on both RT and !RT (arm64 KVM):
>
> WARNING: possible recursive locking detected
> migration/0/21 is trying to acquire lock:
> ffff00003fd7e620 (&rq->__lock){-...}-{2:2}, at: ___task_rq_lock+0x68/0x140
> but task is already holding lock:
> ffff00003fd7e620 (&rq->__lock){-...}-{2:2}, at: migration_cpu_stop+0xac/0x370
> ___task_rq_lock+0x68/0x140
> set_cpus_allowed_force+0x54/0x100
> select_fallback_rq+0xf4/0x180
> migration_cpu_stop+0x35c/0x370
>
> Dropping rq->lock around select_fallback_rq() and rechecking
> task_rq(p) == rq and task_on_rq_queued(p) before updating the clock
> gets the test through on both RT and !RT.
Durr. Dropping rq lock here makes my head hurt. Perhaps I'll try and
make __select_fallback_rq() or somesuch. I'll have a poke.
> > if (task_rq(p) == rq && task_on_rq_queued(p))
> > - rq = __migrate_task(rq, &rf, p, cpu);
> > + rq = move_queued_task(rq, &rf, p, cpu);
> [...]
> > - struct rq *dest_rq = __migrate_task(rq, &rf, p, cpu);
> > + struct rq *dest_rq = move_queued_task(rq, &rf, p, cpu);
>
> Don't you still need the is_cpu_allowed() check here? Both push stoppers
> do select_fallback_rq() before taking rq->lock.
All hold p->pi_lock, and hence IRQs and preemption are disabled, the
affinity mask it locked and hotplug will wait for an RCU grace period
due to deactivate_cpu or somesuch.
next prev parent reply other threads:[~2026-12-02 14:42 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-20 17:16 Sebastian Andrzej Siewior
2026-11-21 13:20 ` Karl Mehltretter
2026-11-21 14:39 ` Karl Mehltretter
2026-11-25 17:20 ` Peter Zijlstra
2026-11-25 19:37 ` Sebastian Andrzej Siewior
2026-11-26 10:40 ` Peter Zijlstra
2026-11-28 17:24 ` Karl Mehltretter
2026-12-02 14:26 ` Sebastian Andrzej Siewior
2026-12-02 14:42 ` Peter Zijlstra [this message]
2026-12-02 14:12 ` Sebastian Andrzej Siewior
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20261202144240.GG2668564@noisy.programming.kicks-ass.net \
--to=peterz@infradead.org \
--cc=bigeasy@linutronix.de \
--cc=bsegall@google.com \
--cc=dietmar.eggemann@arm.com \
--cc=juri.lelli@redhat.com \
--cc=kmehltretter@gmail.com \
--cc=kprateek.nayak@amd.com \
--cc=linux-kernel@vger.kernel.org \
--cc=mgorman@suse.de \
--cc=mingo@redhat.com \
--cc=radu@rendec.net \
--cc=rostedt@goodmis.org \
--cc=syzbot+6835d5c11145e4f77057@syzkaller.appspotmail.com \
--cc=tglx@kernel.org \
--cc=vincent.guittot@linaro.org \
--cc=vschneid@redhat.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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®