From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-wr1-f42.google.com (mail-wr1-f42.google.com [209.85.221.42]) (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 0F17D313E14 for ; Thu, 4 Dec 2025 10:20:41 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.221.42 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1764843644; cv=none; b=L11h2FFAYLGs3dO5mvyWw4COK/mI0BWUwMUYnjcqeaPRfhXW1HCQlGY9wGwg5vh7I0/1OQgfw26tlGJxHFMtJkDDYdkLuQqWmllitZQjOjUcocgGtgcTyNpygz4DM6p6wN0vDtZzDs1wa/amvGvehbDI/J/wmk+zy4Ks422AKeg= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1764843644; c=relaxed/simple; bh=tCGSYF8k71VY7smkDrxFp8W5v/Ah6g9z5nW1NQEbu3g=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=uWaZZ6NY9UVT+nMU4gqSYE/7W1AqCxcfUdA+1swtm3SrctXU3UAoaKkPDVZEHWjW4HP+LpFzMCr348c5LVrmkAgwkAOcXXxXZwM0lIFbhnoi0YT/DDYuqEny+VVRVRg0wZ6SCH4UPJ67b1y96xwqQWhBd7/9KJ0eeW7/PVr80HE= 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=WbWxdlt0; arc=none smtp.client-ip=209.85.221.42 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="WbWxdlt0" Received: by mail-wr1-f42.google.com with SMTP id ffacd0b85a97d-42b3d7c1321so442178f8f.3 for ; Thu, 04 Dec 2025 02:20:41 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.com; s=google; t=1764843640; x=1765448440; 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=YWndlYmmP/ziqcPNiLCxF5pZQ45lalch3dWqqxWyVdM=; b=WbWxdlt0ZxV8EW1Y8iy8/PdHJoov5ypEXL9GoLkUfhzCL32L1eYbeKUHR0X+dOgB3I ZiVJc5scwihsshk5LGXaRnUbN9mYEZppBtcDc3YZHtd4iBFxcVLaHWjtuu8AWa2aTqiJ VtRdASxTuCGYTSJAQmZD/YJMZzbd5oxxR5gmmcDGWpvkMD27MSYF+5hFsd9Y/PfOiusJ 88z+SksNJg5HtHr0VpzY2nD2Cih2GEhNQYvmM2O2P/y2w4df7n0oJlNxCkp32otBcFVL tD/t2/9uugBUAcSDCLfy0ErD9L1CEuB1bk5/2uZ1dYDz+pq0lCcJC2MxnKEqwFqZTpZH 5gfg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1764843640; x=1765448440; 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=YWndlYmmP/ziqcPNiLCxF5pZQ45lalch3dWqqxWyVdM=; b=bUhoO/kvthxjrw9qwyEUJ5hDLCtDSc7JYia5qOYJl6jMDN79n/WC99wZu2q0dQ9vem 1u+7p3WR4mk+mPCfzbHFzxpYM7OkYB8F4KestprQLljc0VNodNugNKViHWenwgD1maCa D85YaX/YlPO7gvwKk2riNWmiv3V1ceQuf5hiMR8/p84eszvZvwKgVolWlu+K+p+MTUY/ LNi7Y+k69f/K/i6/EgZNiARZdgwoQRmzesOchdR+ZyWzE1tt7RMi2FGoBMkdnely+Fy3 eQLBJhWCC0gOJBZ2TS0WVa1D3Pk57e9I6bKdB+HFdXDpstZ9GMXioQc9RXy6nwlrDTj+ r20g== X-Forwarded-Encrypted: i=1; AJvYcCXKHeH+Qoo3tw4opHUd+EgKlEwkFee/qFUjfoLTuKAkvn3LGtryIiC9nQn3bpupT5jusW3JgCwz5lmu0Zs=@vger.kernel.org X-Gm-Message-State: AOJu0Yy7xZNDJMbRWOJTfVC3+hsfUwbMJRpcoY9BUbjR9v6wDiRhInqj Z4/tvWQqo6z7Ls8l0jrSkMRIXc+cu+fCwFKP90xe0TM9WcMlNbx3a6MpiP1qRoknhpY= X-Gm-Gg: ASbGnctEvEzLElalm1YmAeRBFLrcexhjKDClN5saEHUDBYPwBRTYUMM/DdWkog6kHrW Vzve0QCtli56N/LFbO0j4zI0CfXZy3IFz+F5tgwb4TsMHsqQqcyzup9G03/ug4CdFy9m0hXW4M1 DSR+kQwlUNgo5vKd9zDjrtLFEqQ/Wbj1Rj4O4Re6dEKB1KR6M04wcfbjUjpN56aTSM/r0je/2zP c/wpYpBT7zZgGxvgHbYXK8DQph3dB13RwchmFMrWjByIqcAmbJBSnhS+SG5YKwep2NpINfksxOI ZEWWIUStWQEWeAqqJnccNkXdUQd0pJuMGXYTaI4TKOPvH6TLgew11Qi01zHc1DZDBjdCO2+zaHG vPuBJ/As6s10loDEVabTAYRci2cNLhkvBYqEyaLNu+QOiSnZYCpiukMXbxHTbufkTC9hnNlLQvo XHXSy6pScYdC5SQA== X-Google-Smtp-Source: AGHT+IGjXxBqCI3nHyvyKZ8gwjTRWgF1uFsxgb0njJqQCdjIbfZ8SPxmGGQrKiRSeV8F05NFAcnbCA== X-Received: by 2002:a5d:5d86:0:b0:42b:3907:a38b with SMTP id ffacd0b85a97d-42f79855e9amr2270006f8f.44.1764843639686; Thu, 04 Dec 2025 02:20:39 -0800 (PST) Received: from pathway.suse.cz ([176.114.240.130]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-42f7d2226c5sm2492488f8f.23.2025.12.04.02.20.38 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 04 Dec 2025 02:20:39 -0800 (PST) Date: Thu, 4 Dec 2025 11:20:37 +0100 From: Petr Mladek To: John Ogness Cc: Leo Yan , Sergey Senozhatsky , Steven Rostedt , Breno Leitao , linux@armlinux.org.uk, paulmck@kernel.org, usamaarif642@gmail.com, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, kernel-team@meta.com, rmikey@meta.com Subject: Re: [PATCH] printk/nbcon: Restore IRQ in atomic flush after each emitted record Message-ID: References: <20251202135832.156559-1-pmladek@suse.com> <87o6oheywd.fsf@jogness.linutronix.de> <20251202162639.GD724103@e132581.arm.com> <87ikenyclh.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: <87ikenyclh.fsf@jogness.linutronix.de> On Wed 2025-12-03 13:33:38, John Ogness wrote: > On 2025-12-02, Leo Yan wrote: > >> I am not really happy about all the local_irq_restore() usage. Using > >> guard syntax would be nice here, but AFAICT there is no guard for > >> local_irq_save()/_restore(). > > > > Sorry for suddenly jumping in. Wouldn't guard(irqsave)() be helpful > > here? > > Thanks, I was not aware of the irqsave variant. We would want the scoped > version. So something like this? > > $ git diff -w > diff --git a/kernel/printk/nbcon.c b/kernel/printk/nbcon.c > index 3fa403f9831f..55beb64c4f4a 100644 > --- a/kernel/printk/nbcon.c > +++ b/kernel/printk/nbcon.c > @@ -1557,6 +1557,14 @@ 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) { > + /* > + * 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. > + */ > + scoped_guard(irqsave) { > if (!nbcon_context_try_acquire(ctxt, false)) > return -EPERM; > > @@ -1569,6 +1577,7 @@ static int __nbcon_atomic_flush_pending_con(struct console *con, u64 stop_seq) > return -EAGAIN; > > nbcon_context_release(ctxt); > + } > > if (!ctxt->backlog) { > /* Are there reserved but not yet finalized records? */ > Great. Thanks for hint. I am going to send v2 with this change. Best Regards, Petr