From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from galois.linutronix.de (Galois.linutronix.de [193.142.43.55]) (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 DF970312835 for ; Mon, 1 Dec 2025 13:21:34 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=193.142.43.55 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1764595296; cv=none; b=NOAapsApAv6F6YFuPyYQn/zhmBdBOPmLsG3biq1eDFLa25mHRmCXiHUVsHsO0Gy0w5GoTyN/3fB0doZ3XO//KmH9z+dt/A0pVNhSIGjjPkhBG6JEoSDyhUkQpTtM2Pb27Cz8xQ6zdSwtaamOg8IXTIrHswBiW3rg5rqufgEClF0= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1764595296; c=relaxed/simple; bh=ViGp9lE/iuK+FU5phExo/3/9wZBwxOwGDcn19KTwqvs=; h=From:To:Cc:Subject:In-Reply-To:References:Date:Message-ID: MIME-Version:Content-Type; b=nAiS/HQX/vbN6GcuFc55USpDqx8ZUPNsLQbbNryCRxSvA+ovZ8mg5BB/kOoHwSKPBNciuahgfoValLJzLjj/HPaZolla8rTdcKnp9SatQffhQbFLtjWRNh4jauy0hHMKEf2VzXltXU5SI7J/TZr0fy33gHHmB+9N5pjVgegkjHk= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linutronix.de; spf=pass smtp.mailfrom=linutronix.de; dkim=pass (2048-bit key) header.d=linutronix.de header.i=@linutronix.de header.b=YVE7OLEf; dkim=permerror (0-bit key) header.d=linutronix.de header.i=@linutronix.de header.b=7scM4e8T; arc=none smtp.client-ip=193.142.43.55 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.b="YVE7OLEf"; dkim=permerror (0-bit key) header.d=linutronix.de header.i=@linutronix.de header.b="7scM4e8T" From: John Ogness DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1764595293; 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: in-reply-to:in-reply-to:references:references; bh=2borD2eJcv573vytYZct+VW+TwAVkVqTnJeZ2AHkFyo=; b=YVE7OLEf2UppUJ8b8RcAmr60ws/MZRmpYAucHLVc2qLD7AvRERxObt9KkwgEGWohLNrWsk q5e96FBQjWP6ixgecsFF/qH/u6ELFrr0aeASdKNYt9sMyPej7tim/v+wOqaBsKiq+l1LeW VD4oVgew+y3jujI4oGX4aeBYNYzJUzZlRhfuI8+eZdLZEa8K2Gne5nSMr/LBIwrCvObHI9 On5In87JA8Ld5Ap0jwVZMOeYmCdGEsqbY5qjrnpzENuBGEALn7lCniQBJzlXyJT04TGVaj E4UYn6/wUsMeuuiQN1ZwMeyRpzZM4HBinS0eiS/YndS1CudzJCGSWfWihzmnAQ== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1764595293; 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: in-reply-to:in-reply-to:references:references; bh=2borD2eJcv573vytYZct+VW+TwAVkVqTnJeZ2AHkFyo=; b=7scM4e8TjAtX0Ht+aHL+Y6W/ycyyj3wa94Xl5rb9kVmetQJGz9HmBqSVryRx9KO6E7ZTqm cld8lqlvp126H/Aw== To: Petr Mladek , Breno Leitao Cc: linux@armlinux.org.uk, paulmck@kernel.org, usamaarif642@gmail.com, leo.yan@arm.com, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, kernel-team@meta.com, rmikey@meta.com Subject: Re: CSD lockup during kexec due to unbounded busy-wait in pl011_console_write_atomic (arm64) In-Reply-To: <87ecpefjee.fsf@jogness.linutronix.de> References: <87ecpefjee.fsf@jogness.linutronix.de> Date: Mon, 01 Dec 2025 14:27:32 +0106 Message-ID: <87bjkificj.fsf@jogness.linutronix.de> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain On 2025-12-01, John Ogness wrote: >> diff --git a/kernel/printk/nbcon.c b/kernel/printk/nbcon.c >> index 3fa403f9831f..6b8becb6ecd9 100644 >> --- a/kernel/printk/nbcon.c >> +++ b/kernel/printk/nbcon.c >> @@ -1549,6 +1549,7 @@ static int __nbcon_atomic_flush_pending_con(struct console *con, u64 stop_seq) >> { >> struct nbcon_write_context wctxt = { }; >> struct nbcon_context *ctxt = &ACCESS_PRIVATE(&wctxt, ctxt); >> + unsigned long flags; >> int err = 0; >> >> ctxt->console = con; >> @@ -1557,18 +1558,31 @@ static int __nbcon_atomic_flush_pending_con(struct console *con, u64 stop_seq) >> ctxt->allow_unsafe_takeover = nbcon_allow_unsafe_takeover(); >> >> while (nbcon_seq_read(con) < stop_seq) { >> - if (!nbcon_context_try_acquire(ctxt, false)) >> + /* >> + * Atomic flushing does not use console driver synchronization >> + * (i.e. it does not hold the port lock for uart consoles). >> + * Therefore IRQs must be disabled to avoid being interrupted >> + * and then calling into a driver that will deadlock trying >> + * to acquire console ownership. >> + */ >> + local_irq_save(flags); >> + if (!nbcon_context_try_acquire(ctxt, false)) { >> + local_irq_restore(flags); >> return -EPERM; >> + } >> >> /* >> * nbcon_emit_next_record() returns false when the console was >> * handed over or taken over. In both cases the context is no >> * longer valid. >> */ >> - if (!nbcon_emit_next_record(&wctxt, true)) >> + if (!nbcon_emit_next_record(&wctxt, true)) { >> + local_irq_restore(flags); >> return -EAGAIN; >> + } >> >> nbcon_context_release(ctxt); >> + local_irq_restore(flags); > > Using local_irq_save()/_restore() here is not acceptable for PREEMPT_RT > because __nbcon_atomic_flush_pending_con() is also used by > nbcon_device_release(). After thinking about this more, this would be acceptable. If printk_get_console_flush_type() is reporting nbcon_atomic==true, then the system is in a state where latencies are irrelevant. John Ogness