From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from confino.investici.org (confino.investici.org [93.190.126.19]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id EC62C242D7B for ; Tue, 7 Jul 2026 20:59:22 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=93.190.126.19 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1783457964; cv=none; b=MaOS+Gg088m+jae9swsFeQQ7JbI0yVjOEAcbIgIgKLmi4QhtPn6CEwP2B/05SlAwoeokaPQhpoi9u+/CoHLRVTIWCHj+FvPqvGdujN2oqNP8nwi4jkMYOKY6tBBaLdqwlWbjsTj2pMi6c1Q6VoXEy1eD+yjkxmntk7wcW1nPEFU= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1783457964; c=relaxed/simple; bh=d2PAwKlFiHGfsAAI1Col4LVFB+1OFDQy038zIrfi+6c=; h=From:To:Cc:Subject:Date:Message-ID:MIME-Version; b=OedbDz8jYvn8RcnJj74RYCOGlIDRGvb2k+SaZJg+sGtVb3nsdnzymVUB9N8SEizyfD0j+7SzxN2aAWGAjcIB+6dI5NKwY3fplG129JQmkryCmxaPN0+KNJtj2ryrBMEVuAquIiyLOQiPYsSJik47v+cK2TZoHk3UeKhkzY1fjok= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=grrlz.net; spf=pass smtp.mailfrom=grrlz.net; dkim=pass (1024-bit key) header.d=grrlz.net header.i=@grrlz.net header.b=IM3dpk25; arc=none smtp.client-ip=93.190.126.19 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=grrlz.net Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=grrlz.net Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=grrlz.net header.i=@grrlz.net header.b="IM3dpk25" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=grrlz.net; s=stigmate; t=1783457960; bh=fXYuMVnxn3p3b+j5PokRHMKqFteZB/injCZf9feKKJs=; h=From:To:Cc:Subject:Date:From; b=IM3dpk25/CgDLxgI5gxNHpWrQDJ3k5JNggx4tm2H1TwuAdKQ15woAH2mwXQwj/+Bd BdOzxvCX8prlV4UZb+PPmWPtfqSUP1QAGGwHarByQWduh9zInWn9mer8UpICk5LWkw X/wf8QXqyzFOg90S/q5snZ9cdaj7L2HxsEivsbCI= Received: from mx1.investici.org (unknown [127.0.0.1]) by confino.investici.org (Postfix) with ESMTP id 4gvtrS5qpDz10yb; Tue, 07 Jul 2026 20:59:20 +0000 (UTC) Received: by mx1.investici.org (Postfix) id 4gvtrS1VZrz10x8; Tue, 07 Jul 2026 20:59:20 +0000 (UTC) From: Bradley Morgan To: akpm@linux-foundation.org Cc: pmladek@suse.com, feng.tang@linux.alibaba.com, linux-kernel@vger.kernel.org, include@grrlz.net Subject: [PATCH] panic: make force_cpu redirect work from an NMI Date: Tue, 7 Jul 2026 20:59:21 +0000 Message-ID: <20260707205921.15247-1-include@grrlz.net> X-Mailer: git-send-email 2.53.0 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit nmi_panic sets panic_cpu first. Bail only on a different owner, and hand panic_cpu to the target after the IPI. Found by sashiko [1]. [1] https://sashiko.dev/#/patchset/20260707183253.9793-1-include@grrlz.net Signed-off-by: Bradley Morgan --- kernel/panic.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/kernel/panic.c b/kernel/panic.c index e46c37b39c40..95ebf2bb0bf9 100644 --- a/kernel/panic.c +++ b/kernel/panic.c @@ -396,8 +396,8 @@ static bool panic_try_force_cpu(const char *fmt, va_list args) return false; } - /* Another panic already in progress */ - if (panic_in_progress()) + /* Bail only if a different CPU is already handling it. */ + if (panic_in_progress() && atomic_read(&panic_cpu) != this_cpu) return false; /* Which CPU won the race? */ @@ -440,6 +440,9 @@ static bool panic_try_force_cpu(const char *fmt, va_list args) return false; } + /* Hand panic_cpu to the target so it wins its own panic_try_start. */ + atomic_set(&panic_cpu, panic_force_cpu); + /* IPI/NMI sent, this CPU should stop */ return true; } -- 2.53.0