From: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
To: Peter Zijlstra <peterz@infradead.org>
Cc: syzbot <syzbot+6835d5c11145e4f77057@syzkaller.appspotmail.com>,
linux-kernel@vger.kernel.org, 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: [RFC PATCH v2] sched: irq: cpu-hotplug race vs set_cpus_allowed_ptr()
Date: Tue, 13 Oct 2026 15:43:40 +0200 [thread overview]
Message-ID: <20261013134340.Ua8DuZTD@linutronix.de> (raw)
In-Reply-To: <20261013064617.jw7Sk6un@linutronix.de>
On 2026-10-13 08:46:19 [+0200], To Peter Zijlstra wrote:
> > I am struggling to follow along. The actual fail scenario is a
> > combination of hotplug *and* migrate_disable()? Can we get a picture?
>
> let me grab the reproducer and a few tracepoints to make an accurate
> drawing.
CPU1 is actually doing nothing. And migrate_disable() is involved way
later:
CPU0
_cpu_down(1)
set_cpu_dying(1)
/* CPU1 is now present in ONLINE and DYING mask */
<idle or whatever>
try_to_wake_up(p)
-> select_fallback_rq() -> falls back to CPU0 because CPU1 is not available
<irq-thread>
irq_thread_check_affinity()
set_cpus_allowed_ptr(, 1)
/* cpu_valid_mask = cpu_online_mask */
-> affine_move_task(dest_cpu = 1);
-> stop_one_cpu_nowait()
/* switch to migration_cpu_stop-0 */
migration_cpu_stop()
-> __migrate_task(arg->dest_cpu = 1) /* returns rq of 0 */
< back to irq-thread >
set_cpus_allowed_ptr(, 1) return with cpus_ptr set to CPU1 while running
on CPU0.
A schedule out (and sleep) at this point is fine, try_to_wake_up() will
again go to select_fallback_rq() and schedule the task on 0 with proper
::cpus_ptr.
If instead the task does
migrate_disable()
schedule() /* remain running on RQ */
-> migrate_disable_switch()
-> set_cpus_allowed_common()
-> p->cpus_ptr = ctx->new_mask; = CPU0
Once back on CPU0, migrate_enable() does:
___migrate_enable()
-> __set_cpus_allowed_ptr(SCA_MIGRATE_ENABLE | &p->cpus_mask)
/* ::cpus_mask has still the 1 set. There was no wakeup, task
remained on RQ so the mask is not fixed */
Now affine_move_task() will expect task_struct::migration_pending to be
set but it was never set. The task would have remained on the current
CPU (0) if the previous set_cpus_allowed_ptr() would not have set an
invalid CPU mask.
Sebastian
prev parent reply other threads:[~2026-10-13 13:43 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-10-12 10:39 Sebastian Andrzej Siewior
2026-10-12 14:19 ` Juri Lelli
2026-10-12 14:30 ` Peter Zijlstra
2026-10-13 6:46 ` Sebastian Andrzej Siewior
2026-10-13 13:43 ` Sebastian Andrzej Siewior [this message]
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=20261013134340.Ua8DuZTD@linutronix.de \
--to=bigeasy@linutronix.de \
--cc=bsegall@google.com \
--cc=dietmar.eggemann@arm.com \
--cc=juri.lelli@redhat.com \
--cc=kprateek.nayak@amd.com \
--cc=linux-kernel@vger.kernel.org \
--cc=mgorman@suse.de \
--cc=mingo@redhat.com \
--cc=peterz@infradead.org \
--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®