mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
To: Peter Zijlstra <peterz@infradead.org>
Cc: 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:12:55 +0100	[thread overview]
Message-ID: <20261202141255.mZhPlX_h@linutronix.de> (raw)
In-Reply-To: <20261126104049.GC49833@noisy.programming.kicks-ass.net>

On 2026-11-26 11:40:49 [+0100], Peter Zijlstra wrote:
> > > So the problem begins here, by selecting a CPU that isn't guarded to
> > > remain online until after the operation completes.
> > 
> > Right, we don't enforce this so everyone without a CPU-HP lock held has
> > a problem here. From irq_thread_check_affinity() perspective, it is fine
> > because once the CPU goes down, there will be another update aligning
> > the thread with the CPU that has been picked to serve the interrupt.
> 
> Right, that is true in this case. But will that always be true for
> people that 'forget' hotplug.

We could have one interface for tglx and one for everyone else with a
warning with the HP lock is missing. I added a warning there and the
first one was kthread_affine_node() with a warning why it is okay if we
miss the CPU…

…
> Right -- so the printk is gated with p->mm, which kthreads will mostly
> fail. So even if the timing was different and we'd have hit
> select_fallback_rq() we'd not have seen a printk().
> 
> However, the 'fixup' is different, select_fallback_rq() will set the
> widest possible mask, while this will set only the one CPU.

Yes, the current CPU we were on anyway. 

> Then there also are __balance_push_cpu_stop() and
> sched_non_preferred_cpu_push_stop() that use __migrate_task(). AFAICT
> both of those should also be able to hit this task, both of them run it
> through select_fallback_rq().
> 
> Does something like so make sense? That routes them all through
> select_fallback_rq().

The box freezes. migration_cpu_stop() takes the rq and then
select_fallback_rq() does the same:

| ============================================
| WARNING: possible recursive locking detected
| 7.4.0-rc5+ #16 Not tainted
| --------------------------------------------
| migration/0/21 is trying to acquire lock:
| ffff88817bc2e220 (&rq->__lock){-...}-{2:2}, at: ___task_rq_lock+0x4d/0x100
|
| but task is already holding lock:
| ffff88817bc2e220 (&rq->__lock){-...}-{2:2}, at: migration_cpu_stop+0x72/0x360
|
| other info that might help us debug this:
|  Possible unsafe locking scenario:
|
|        CPU0
|        ----
|   lock(&rq->__lock);
|   lock(&rq->__lock);
|
|  *** DEADLOCK ***
|
|  May be due to missing lock nesting notation
|
| locks held by migration/0/21: 2, on CPU#0:
|  #0: ffff888102b55f80 (&p->pi_lock){-...}-{2:2}, at: migration_cpu_stop+0x5c/0x360
|  #1: ffff88817bc2e220 (&rq->__lock){-...}-{2:2}, at: migration_cpu_stop+0x72/0x360
|
| stack backtrace:
| CPU: 0 UID: 0 PID: 21 Comm: migration/0 Not tainted 7.4.0-rc5+ #16 PREEMPT_{RT,(lazy)}
| Hardware name: QEMU Standard PC (Q35 + ICH9, 2009), BIOS 2026.11+ds-1 11/26/2026
| Stopper: migration_cpu_stop+0x0/0x360 <- affine_move_task+0x459/0x620
| Call Trace:
| Call Trace:
|  <TASK>
|  dump_stack_lvl+0x5b/0x80
|  print_deadlock_bug.cold+0xc0/0xe2
|  __lock_acquire+0x1515/0x27e0
|  lock_acquire+0xc2/0x2b0
|  _raw_spin_lock_nested+0x2a/0x40
|  ___task_rq_lock+0x4d/0x100
|  set_cpus_allowed_force+0x45/0xd0
|  select_fallback_rq+0x128/0x140
|  migration_cpu_stop+0x34c/0x360
|  cpu_stopper_thread+0x9d/0x140
|  smpboot_thread_fn+0xf5/0x240
|  kthread+0xe4/0x120
|  ret_from_fork+0x2ba/0x390
|  ret_from_fork_asm+0x11/0x20
|  </TASK>

Sebastian

      parent reply	other threads:[~2026-12-02 14:12 UTC|newest]

Thread overview: 9+ 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:12       ` 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=20261202141255.mZhPlX_h@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®