From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-wm1-f48.google.com (mail-wm1-f48.google.com [209.85.128.48]) (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 E5786303C93 for ; Mon, 24 Nov 2025 13:55:07 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.48 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1763992511; cv=none; b=huZsIDSez7x0TXl/sjZFgtqGeT7P3Y7MuNTsDIQQrZYWXl3etyy8g3h4HL1GE1kL+alIqk2GKcONa4ytq+33LKFRcwDdgzK+pZDy+8whELoEtOfwv+Fi19n5DPBa/szzmQAuAiD8W8OMJyutFAEZgTofUUwfb66dPXHSC4R1k0k= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1763992511; c=relaxed/simple; bh=/CKSvAOlVY8BjN8XbCmfdPH2F1Z/MzSriDHooJwKonA=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=K7YTIHlvpzchYgp3jjw6yX4vcPXQh+YbJLbiaCxmWk+soMm36Grfa8kTOCneZRHjDtHUan7n0SxY2kBDJTPGrDKs1MTz0I2SRpMiV8cr0LSARbSGG0jX6BFZZfHJnXr0UqiMVLhNd0DS3bSYs+1BzjS7rw/GXY7eYbFrXF7ozVg= 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=QjSaNPlJ; arc=none smtp.client-ip=209.85.128.48 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="QjSaNPlJ" Received: by mail-wm1-f48.google.com with SMTP id 5b1f17b1804b1-4779a637712so26190025e9.1 for ; Mon, 24 Nov 2025 05:55:07 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.com; s=google; t=1763992506; x=1764597306; 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=YPuHiWYXlxCT3REvX5xilRSzoHSOopPnik0KnitVPIc=; b=QjSaNPlJFOSKJAyKnonLAh8vyfbteye7+90MDqGKQBWFwCM8zYJSrd5ZWIHmnsOWxv Y6X0lwfjn86zUPBJZYIdnAPzwboxNslbZUuBFqdBhbuc4OEROzrCQGnLjAUUUMnsOm0C tmRms3HjweOWsvLDTFcyGaTPvpUHSn+9GejzsuejgNG1YH5S+G4gC6Dthqxq6wYJeD1p Nz9Dcmdi4bPCAKvQlDDRjzm1L32aAOIH+UkRR1Gy4NYMDg8z/T5p8dV8v71yAqj1yZuv AG8I7xh8uJqdzxPYekUoEKNGT89RRu0MT/g5d+L0Bm9gD7Yp1zJU/UN5a97EYY8u+Tvv lMYA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1763992506; x=1764597306; 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=YPuHiWYXlxCT3REvX5xilRSzoHSOopPnik0KnitVPIc=; b=gICgm8IUM65r74/4CIXT4k48qslkM9UyOF6StKHre9qEGMDLBtLeenuwgVZ9Jn3RXe YkCo1hVR5j3MNfYWCyo1SjAjg4RfrZBZPFgaoEFs5CQJFLhr10RNVKsLd1PGca/a6inY wP7ZkRdOXCC6jdjtm0wD4Osl+57NzNNW6MwEVHDHxyddRxlZ4NZ5uqv8UspeJM5+Wm+R 78MszHmW3Ak/n0QwCmoXE3XuTPPT6UfhNTWT35+gOsF8Ab7Nb+bIhHi2ZCF8hQz9DCtw OTJI4CUvX6dJ01VL/SVwnOQjsv4KIkBQko2hARbyML98t2PnEmWwIROfZzStrlzFqTYj Ge+A== X-Forwarded-Encrypted: i=1; AJvYcCVz0JhLJu8iyqbCGUUN3xuOAR8/dGDvXAJjA03o9oVm0VruVX6v50h9lieYqDYkF7WIyResPDb7wwYUhCA=@vger.kernel.org X-Gm-Message-State: AOJu0YxBdC2yhb8BmziFs1MdiaiZXA7cBuZ4nyMAp8vVxNj0nfmm2cld kQW7xk6Nk6BeeKN9XeX+mMp9157rXtZGdbRU9R74tv3SL1fla62KSUGajrBEuaGA9/I= X-Gm-Gg: ASbGncss5PTQ0aKlFYD1zr9MESV8T4QXIghJ5RQxN5lVP/40MrhK1leGOWTGYHdEuQz Hplh2nu3GuVnRfBrsbDY3ygadKYqTgfOSSkx3B+km8bREsp7NxWpCD07kewwKgLBkANeVC6HFMG 9777DxgjifkBcFHPnwQtJRaJ7v5KT0Ul8RkfVCUKAGPpTvmVY64z476aLBsyyjUvt4LhIQGvmKS EKQP52JvEhSqhZWWCZsMLTbMw5/NdhsG0MEa4Ord46q9XbV19I8+aAnS9aKU0/q6W7HowMRAMLC Hfq0AD4/kGJOL/ePpir4gPyYBi/KXQ5d6xz5oaq9gQlRWSx2AoNnabe2OjIwGKZAKljvwdz6hSm NUJtEtq+kNRgcbUsAqtFZ5Vnab5fmi03gOqRjV/rb5k9ZCFaelVAdzOYvO9ev4fcQAl6PDQ3O5P CyrOpLQwpVxn82LQ== X-Google-Smtp-Source: AGHT+IG1aXy33KmNHg9WN5SPhjEuMzD0hduDeGynMkb23F8zv3/FcRZI9YIQut5OtqH8of2UvaqP+w== X-Received: by 2002:a05:600c:1ca0:b0:477:75eb:a643 with SMTP id 5b1f17b1804b1-477c0165b4emr139649225e9.4.1763992506054; Mon, 24 Nov 2025 05:55:06 -0800 (PST) Received: from pathway.suse.cz ([176.114.240.130]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-42cb7f49a7bsm28133751f8f.19.2025.11.24.05.55.03 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 24 Nov 2025 05:55:05 -0800 (PST) Date: Mon, 24 Nov 2025 14:55:02 +0100 From: Petr Mladek To: Breno Leitao Cc: Jakub Kicinski , horms@kernel.org, efault@gmx.de, john.ogness@linutronix.de, Andrew Lunn , "David S. Miller" , Eric Dumazet , Paolo Abeni , netdev@vger.kernel.org, linux-kernel@vger.kernel.org, calvin@wbinvd.org, asml.silence@gmail.com, kernel-team@meta.com, gustavold@gmail.com, asantostc@gmail.com Subject: Re: [PATCH RFC net-next 2/2] netconsole: add CONFIG_NETCONSOLE_NBCON for nbcon support Message-ID: References: <20251121-nbcon-v1-0-503d17b2b4af@debian.org> <20251121-nbcon-v1-2-503d17b2b4af@debian.org> 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: <20251121-nbcon-v1-2-503d17b2b4af@debian.org> On Fri 2025-11-21 03:26:08, Breno Leitao wrote: > Add optional support for the nbcon infrastructure to netconsole via a new > CONFIG_NETCONSOLE_NBCON compile-time option. > > The nbcon infrastructure provides a lock-free, priority-based console > system that supports atomic printing from any context including NMI, > with safe handover mechanisms between different priority levels. This > makes it particularly suitable for crash-safe kernel logging. > > When disabled (default), netconsole uses the legacy console callbacks, > maintaining full backward compatibility. > > PS: .write_atomic and .write_thread uses the same callback, given that > there is no safe .write_atomic, so .write_atomic is called as the last > resource. This is what CON_NBCON_ATOMIC_UNSAFE is telling nbcon. Makes sense. CON_NBCON_ATOMIC_UNSAFE also explains why target_list_lock need not be synchronized with nbcon context locking [*]. The _unsafe_ .write_atomic() callback might be called only by the final nbcon_atomic_flush_unsafe() when even the nbcon context synchronization can be ignored. [*] For example, see how port->lock is synchronized with the nbcon context by uart_port_lock() wrapper. > --- a/drivers/net/Kconfig > +++ b/drivers/net/Kconfig > @@ -369,6 +369,20 @@ config NETCONSOLE_PREPEND_RELEASE > message. See for > details. > > +config NETCONSOLE_NBCON > + bool "Use nbcon infrastructure (EXPERIMENTAL)" > + depends on NETCONSOLE > + default n > + help > + Enable nbcon support for netconsole. This uses the new lock-free Strictly speaking, it is not lock-free. The main feature is that it is threaded so that it does not block the printk() caller. Nbcon consoles also support synchronous flushing in emergecy situations. But it does not work with netconsoles because they do not support atomic operations. They are flushed only by the final desperate flush in panic() when all locks are ignored. > + console infrastructure which supports threaded and atomic printing. > + Given that netconsole does not support atomic operations, the current > + implementation focuses on threaded callbacks, unless the host is > + crashing, then it uses an unsafe atomic callbacks. This feature is > + available for both extended and non-extended consoles. > + > + If unsure, say N to use the legacy console infrastructure. > + > config NETPOLL > def_bool NETCONSOLE > > diff --git a/drivers/net/netconsole.c b/drivers/net/netconsole.c > index f4b1706fb081..2943f00b83f6 100644 > --- a/drivers/net/netconsole.c > +++ b/drivers/net/netconsole.c > @@ -1724,6 +1724,57 @@ static void send_ext_msg_udp(struct netconsole_target *nt, const char *msg, > extradata_len); > } > > +#ifdef CONFIG_NETCONSOLE_NBCON > +static void netcon_write_nbcon(struct console *con, > + struct nbcon_write_context *wctxt, > + bool extended) > +{ > + struct netconsole_target *nt; > + > + lockdep_assert_held(&target_list_lock); > + > + list_for_each_entry(nt, &target_list, list) { > + if (nt->extended != extended || !nt->enabled || > + !netif_running(nt->np.dev)) > + continue; > + > + if (!nbcon_enter_unsafe(wctxt)) > + continue; > + > + if (extended) > + send_ext_msg_udp(nt, wctxt->outbuf, wctxt->len); > + else > + write_msg_target(nt, wctxt->outbuf, wctxt->len); If you accepted the rename in the 1st patch then this would be ;-) if (extended) send_ext_msg_udp(nt, wctxt->outbuf, wctxt->len); else send_msg_udp(nt, wctxt->outbuf, wctxt->len); > + > + nbcon_exit_unsafe(wctxt); > + } > +} Otherwise, it looks good from my POV. Best Regards, Petr