From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-wm1-f49.google.com (mail-wm1-f49.google.com [209.85.128.49]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id C2496287265 for ; Tue, 2 Dec 2025 10:34:20 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.49 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1764671663; cv=none; b=baVSpe3j3dP7NfWg4IoOqzuyGPVmIaYZSJZ5ZahmdFQc58oDkDbOo0DLgsk10SoiapD5VKIFeE9KNeQCtkmjZWqbkcPODFGr4wB3QwSlRaeEyG+K+OhAK7PElLp3TUDrVbBPqqEK8sXBhUxZX48wQ05N1gTBpZpRpJ4HsYqIC0M= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1764671663; c=relaxed/simple; bh=dKNkxnGI1Vb9cvC/vQVth+ZNLU11I8mYKZFPdPFpxYk=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=ZdVk2P3IkwDk4t0SWYH0+rAIUP8L+b/8cJOOwy181U8wQEQnIM/BStiQhtJGqVcK0XU2GBljlElfLWRlYCB+wtprfWiMiqVMWl218Wn/jO5Fu1cRC1WTz2OM8PhbCmkUhW+/IiflwBCtbHLH7hB76BT5bt8ogCxxkyZFOQF+5lw= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=suse.com; spf=pass smtp.mailfrom=suse.com; dkim=pass (2048-bit key) header.d=suse.com header.i=@suse.com header.b=Dkeb8Y+G; arc=none smtp.client-ip=209.85.128.49 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=suse.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=suse.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=suse.com header.i=@suse.com header.b="Dkeb8Y+G" Received: by mail-wm1-f49.google.com with SMTP id 5b1f17b1804b1-4775ae77516so52198655e9.1 for ; Tue, 02 Dec 2025 02:34:20 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.com; s=google; t=1764671659; x=1765276459; darn=vger.kernel.org; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:from:to:cc:subject:date:message-id:reply-to; bh=WSoUc9eXKj28dLovTJJzuv8gw1Sz+Xl88pkdspKf/1M=; b=Dkeb8Y+GZsOL/PZQhLqnqZ/vwyWXA8YKKsK4fejBJ+xTwXfSoFi9znOnHVWXOamQjT nLqk1x3JkXUerkGEGKBqtWs7V8SCbPMlVSqJK4kkxC47DehVdR2+rPktWqAbcw9CqxvQ u9FvVcb0NqZq/LXW6UnCH/WaGbA6t/KwHRwKdwVyR+vxe9ZZumj28Izw6usL6Gwnw6f3 L93haUxxcyTkQNmHEZl9Sa17MdlWZr8xjPqjfakRA2WkFKiJRT417XYZWNvVz6V9rsrE luA9GHLDGQ+lTfM9+rCfC90uPQN8bAk5PzDQHW/LjtATME/zKhroTswSQuoW3cmSRaua OLcA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1764671659; x=1765276459; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:x-gm-gg:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=WSoUc9eXKj28dLovTJJzuv8gw1Sz+Xl88pkdspKf/1M=; b=RY9IgMEqptOtetxaNWSQNaWWxSaZGwtPlIgOE4C5bWxBnysRVCAmqtQS1inQLdD1Bd 9fkLGbsL8ARhvHtfP4F9ZkbEjWbSXTAieEuC/hQWskSrsqY5dj9yidw0m5g5xrHlrtxx Lv68nwrrIOOkgwESGWvdOQPITizlgW5dlQwpFKvj05puwB8tfkNX36SDW/9fhCzSOdOl eLa+t7EV0LrBk31xJwJSaaMCtetDqNZrzm3Z0AWJwMdYBC3UbEVEdtLWAcoXo3sA29x0 PAnCraivS9csRsirS9pQH/B3R1DdCf0uvEwJOHxTpyfWXlDhUIv+FGrrQsIoFj+W3kv/ HxVw== X-Forwarded-Encrypted: i=1; AJvYcCWaLzp9pqBaexvzgL4u8QJtBo96I02ygvqT+qMHbeNUxiNP/v/MAFWPv4aEIr0NDQo7OExh5D+0O0Q9wWs=@vger.kernel.org X-Gm-Message-State: AOJu0Yx/1CLgzyWoRVUgyhjxPAv70sFKLrdnwMg9+V8VFoKQdC4BVGMU IN8nW0oW2x6fOXgUS+n1tTYPyne1XQaQ+3uHSlShFsIPG3MZMDTezp3SwkAiaSQEy+k= X-Gm-Gg: ASbGncss/wOcEeT1qPnxDJEbVdiiYxdei/va1RKn8pNIIZ96J2ojfDLOkWrFf5s0JhL pxT3M/kDXbSX4ZB99aeshRJ7NRjpxfYyeRvRZgv0d6UvmgvKx9r6nj/YUUHM2D27blyiEGPTipG S7HJxpqWJ8ZvPlj6zEbNiAYFfVYkq6vgJcrziCZrBgqREJ/R7oI3X8nU7gYloph0yNa/H2UqbuA I2817L1PfPy4I3zFpXuPWwnFeZhL1iB0AWHGYV1GELsRXoC/QX+70WxhuLSvGONPLj8+hBZNkly CnNjik1tWPrktR5hetueVtP+L3/9zRW/MJb8C10vIlrYo3jqgJVCgdVfuHmll/OElcprUpJIS+m kxD70G7oQHHZXN4lJxFdUUTdS59XYApbrVCCxIQEhJdhTd3UWWT4cPdKOuF5PGoctu8GhpqB2pz 8JrQgf93VkL6FDRw== X-Google-Smtp-Source: AGHT+IGbpka828FERUZav1n2Fjj4tJ15j7Syx7WwdflVn1Se46VoLOy2vA2Eeq1tNjGmfsFWL8W1rA== X-Received: by 2002:a05:600c:4591:b0:477:b642:9dbf with SMTP id 5b1f17b1804b1-477c1132adbmr410647675e9.32.1764671659029; Tue, 02 Dec 2025 02:34:19 -0800 (PST) Received: from pathway.suse.cz ([176.114.240.130]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-4790b0e21e8sm376689015e9.15.2025.12.02.02.34.17 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 02 Dec 2025 02:34:18 -0800 (PST) Date: Tue, 2 Dec 2025 11:34:15 +0100 From: Petr Mladek To: John Ogness Cc: Breno Leitao , 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) Message-ID: References: <87ecpefjee.fsf@jogness.linutronix.de> <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; charset=us-ascii Content-Disposition: inline In-Reply-To: <87bjkificj.fsf@jogness.linutronix.de> On Mon 2025-12-01 14:27:32, John Ogness wrote: > 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(). Great catch! I did not think about this code path. > 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. I agree. It might be possible to create a special variant for the nbcon_device_release() code path. But it probably is not worth it. I am going to mention this in the commit message and send it as proper patch. Thanks a lot for review and feedback. Best Regards, Petr