From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=193.142.43.55 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796220780; b=ClVZlk/sEa6Wk3Gxm52Vb8xmAYbxSfQ485M3/LDK8R5CAJ99h9wt96Kjvv/LBtNHfStq Qh9blWYSrPQq3CWEryIlSQda6/+sSNu+ggaxXsqXOJtLjJH6TbvpgU8rK38fEYAHsUo/Q ZPcLjlwWkOD3DG+HRULIqDlnKcgG3O1Ruykzh1mLNflG0KW/n+mdXISoGw8p+uqVLjkI0 RX7QhWQjYMv/oeYcXgkOVb+DNGOaG/v3KLtbPna5AggVDHwGVFviDYogc3fJqKfQYrUQr mGRTWAZAo/SQtVAsjbcPyCoVaen1fHG1we1ToYBFRvpBN9A9gF5bHVIbLhRWvXtTyLQ== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796220780; h=DMARC-Filter:Date:DKIM-Signature:DKIM-Signature:From:To:Cc:Subject: Message-ID:References:MIME-Version:Content-Type:Content-Disposition: Content-Transfer-Encoding:In-Reply-To; bh=5DTe/jHdNWQdJf8dsCX4naLhT0+TB+2PDujEeKYiDqM=; b=ORS/VVBBRvlcenrqEAN5+5/3JosRzXneHXuyHW1MNkxIl2iZ2hCq8kajVK8/rfmiqhwk CuvxIb6dOS0e2bovAQJY09lcCJhBwjkv6k+8rc+sJVZtQXU8IvJ175bxUbR1NW6kThIjL /ZS+696FWvh/dXCpEudZOXqO0paoKI2jBMPL9I4dFi8NAUJVYWqHWJfM8kpfBjs6IK/UP 3VAiNvBviwUsgQ3zO0RHXH0cczAp8Ok1EzEIHztkgcR6ozAKZZLrul7qQNHt8/vxGCJpW /yuVLOtN/by3pcS0jdEfnvaKDXs4T0+9F9aolj3zsAF1MNcuivDrfzMjfVaMA9ai77A== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass header.from=linutronix.de; spf=pass smtp.mailfrom=linutronix.de; dkim=pass header.d=linutronix.de header.i=@linutronix.de header.a=rsa-sha256 header.s=2020 header.b=QRCUm3ZS; dkim=pass header.d=linutronix.de header.i=@linutronix.de header.a=ed25519-sha256 header.s=2020e header.b="m/RLldE0"; arc=none smtp.remote-ip=193.142.43.55 Received: from galois.linutronix.de (Galois.linutronix.de [193.142.43.55]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1) server-digest SHA256) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id BE36C606A680 for ; Wed, 2 Dec 2026 14:12:59 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org BE36C606A680 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linutronix.de Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linutronix.de Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=linutronix.de header.i=@linutronix.de header.a=rsa-sha256 header.s=2020 header.b=QRCUm3ZS; dkim=pass header.d=linutronix.de header.i=@linutronix.de header.a=ed25519-sha256 header.s=2020e header.b=m/RLldE0 Date: Wed, 2 Dec 2026 15:12:55 +0100 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1796220777; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=5DTe/jHdNWQdJf8dsCX4naLhT0+TB+2PDujEeKYiDqM=; b=QRCUm3ZSv+wxJvDpV5XFIBV0B62WhOFr1dZqMp/QzcvzRZeTwJCbyAb9T+YwPwZjXQS3t3 756cQt8yf0D7Is+4wbWwqHEMwoIW7Dr0HBDDAzuaQRswo6QOkda8l1AhxZR6DOL7IkkhA+ XfnjY1zMpXrh6Xl1OGgkmlcf0DY7+QAQey7Usytfa5GB7tB79FBl3j1ZUaXeMadrSUe642 N8Y6KFUrDs9k1q12gm792Qjw5z7PfIKaG9b+I/cqiB4qZrmseqNXxAnreYxQgO+khbz47/ 06zhGo8p/8ZNKk/v4tMDK8huuWZ7lwoX3Lfad8zomQt4t2O4czVVTewPc2SbSQ== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1796220777; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=5DTe/jHdNWQdJf8dsCX4naLhT0+TB+2PDujEeKYiDqM=; b=m/RLldE0QDfFIDZKUS9tTWf9P0egu3hMLswTsoRs/laOuv60HnyNdoSietycQQUJHYHJdn 9n04zixbjbpl/+CA== From: Sebastian Andrzej Siewior To: Peter Zijlstra Cc: linux-kernel@vger.kernel.org, syzbot , Thomas Gleixner , Radu Rendec , Ingo Molnar , Juri Lelli , Vincent Guittot , Dietmar Eggemann , Steven Rostedt , Ben Segall , Mel Gorman , Valentin Schneider , K Prateek Nayak Subject: Re: [PATCH v3] sched: Reset cpumask if __migrate_task() failed for migration_cpu_stop() Message-ID: <20261202141255.mZhPlX_h@linutronix.de> References: <20261120171658.Cf9qIU-Y@linutronix.de> <20261125172018.GD2668564@noisy.programming.kicks-ass.net> <20261125193735.qrxCdHTx@linutronix.de> <20261126104049.GC49833@noisy.programming.kicks-ass.net> X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: quoted-printable 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. > >=20 > > 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. >=20 > 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=E2=80=A6 =E2=80=A6 > 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(). >=20 > 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.=20 > 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(). >=20 > 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: | =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D | 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/0= x360 | | 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+0= x5c/0x360 | #1: ffff88817bc2e220 (&rq->__lock){-...}-{2:2}, at: migration_cpu_stop+0= x72/0x360 | | stack backtrace: | CPU: 0 UID: 0 PID: 21 Comm: migration/0 Not tainted 7.4.0-rc5+ #16 PREEMP= T_{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: | | 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 | Sebastian