From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (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 E694A346AFF; Thu, 22 Jan 2026 21:09:42 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1769116183; cv=none; b=KXMnqPBK5CxwTaVXZQHLOXbyodY/ZSIMFi2dMgdfHvX8AWgISrTA7KedVj/ai8KKQ2m7y4kv7d4YIGV+RN00s1arMrbsqah9okIp1WoR1bQ3u7qSDynpr4QoNgosBMaj1EnTBn7D4TF7EqnXzxTnXHe0IWcchdvH7SDDJOZijDA= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1769116183; c=relaxed/simple; bh=t7rqMgsvSr1YpvQGuQMKvBpiRwX2rBxkxGjTmf9ueW4=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=gbx1zqQ7O7CBYah2XW8OdlCCU6dQck5u2h3X5mwgixdtL5wKqKBzsF3sEakEQuwANoHrq5zDjVqQClABznGUjsLEsmNMydPVtlIoqLaRfm2U6txeFSb6waVuRB03XxYuf8GrCvocrjSh7aJCJlAuW0XEKDwyQLcAgoaE4ch47mo= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=lVcKdEbE; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="lVcKdEbE" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 920DEC116C6; Thu, 22 Jan 2026 21:09:36 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1769116180; bh=t7rqMgsvSr1YpvQGuQMKvBpiRwX2rBxkxGjTmf9ueW4=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=lVcKdEbEkziPCVr2qdmtF39k16VnPdbueuA3fypGBnbB2viUfmauGVyq0psXl1RUX HpJmDFcd4Jhe7Eu5z5Pg58il7K3wtdFf+4owZeo8LSTkcFwi3dnG+4bqK/ePAX5oQu 06Hfhjgn3JhaMmEq8i2/TnaBdP8qCYnEoSWTylsgnaSNIXysDcjGzf+sWXUVx338Mr 28Wo3It4clbHYptOS9w2l6QhDJ7RGG9MwLlVpoMrWHovNW+Pu1PAkgz6ug0XfudMhV 1Xkr8Hojo7mIfO8MmnNx1ZXnGk2MhycUE9Rce+PbkQEI646n3QReZqtem9JPbQBm7k 3a9svRNQuqacQ== Date: Thu, 22 Jan 2026 21:09:34 +0000 From: Simon Horman To: Breno Leitao Cc: Andrew Lunn , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , pmladek@suse.com, john.ogness@linutronix.de, Greg Kroah-Hartman , Steven Rostedt , Sergey Senozhatsky , Andrew Morton , netdev@vger.kernel.org, linux-kernel@vger.kernel.org, asantostc@gmail.com, efault@gmx.de, gustavold@gmail.com, calvin@wbinvd.org, jv@jvosburgh.net, mpdesouza@suse.com, kernel-team@meta.com Subject: Re: [PATCH net-next v2 3/5] netconsole: convert to NBCON console infrastructure Message-ID: References: <20260120-nbcon-v2-0-b61f960587a8@debian.org> <20260120-nbcon-v2-3-b61f960587a8@debian.org> Precedence: bulk X-Mailing-List: netdev@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: <20260120-nbcon-v2-3-b61f960587a8@debian.org> On Tue, Jan 20, 2026 at 08:23:49AM -0800, Breno Leitao wrote: > Convert netconsole from the legacy console API to the NBCON framework. > NBCON provides threaded printing which unblocks printk()s and flushes in > a thread, decoupling network TX from printk() when netconsole is > in use. > > Since netconsole relies on the network stack which cannot safely operate > from all atomic contexts, mark both consoles with > CON_NBCON_ATOMIC_UNSAFE. (See discussion in [1]) > > CON_NBCON_ATOMIC_UNSAFE restricts write_atomic() usage to emergency > scenarios (panic) where regular messages are sent in threaded mode. > > Implementation changes: > - Unify write_ext_msg() and write_msg() into netconsole_write() > - Add device_lock/device_unlock callbacks to manage target_list_lock > - Use nbcon_enter_unsafe()/nbcon_exit_unsafe() around network > operations. > - If nbcon_enter_unsafe() fails, just return given netconsole lost > the ownership of the console. > - Set write_thread and write_atomic callbacks (both use same function) > > Link: https://lore.kernel.org/all/b2qps3uywhmjaym4mht2wpxul4yqtuuayeoq4iv4k3zf5wdgh3@tocu6c7mj4lt/ [1] > Signed-off-by: Breno Leitao > --- > drivers/net/netconsole.c | 97 ++++++++++++++++++++++++++++++------------------ > 1 file changed, 60 insertions(+), 37 deletions(-) > > diff --git a/drivers/net/netconsole.c b/drivers/net/netconsole.c ... > +static void netconsole_device_lock(struct console *con __always_unused, > + unsigned long *flags) > +{ > + spin_lock_irqsave(&target_list_lock, *flags); > +} > + > +static void netconsole_device_unlock(struct console *con __always_unused, > + unsigned long flags) > +{ > spin_unlock_irqrestore(&target_list_lock, flags); > } > Hi Breno, I'm wondering if we could consider the following annotations, as "suggested" by Sparse[1]. diff --git a/drivers/net/netconsole.c b/drivers/net/netconsole.c index c5d7e97fe2a7..79e39a6c5343 100644 --- a/drivers/net/netconsole.c +++ b/drivers/net/netconsole.c @@ -1772,12 +1772,14 @@ static void netconsole_write_basic(struct console *con __always_unused, static void netconsole_device_lock(struct console *con __always_unused, unsigned long *flags) +__acquires(&target_list_lock) { spin_lock_irqsave(&target_list_lock, *flags); } static void netconsole_device_unlock(struct console *con __always_unused, unsigned long flags) +__releases(&target_list_lock) { spin_unlock_irqrestore(&target_list_lock, flags); } [1] This particular commit of Sparse, from Al Viro's tree: https://git.kernel.org/pub/scm/linux/kernel/git/viro/sparse.git/commit/?id=2634e39bf02697a18fece057208150362c985992 Which addresses this mess: https://lore.kernel.org/all/bf5b9a62-a120-421e-908d-1404c42e0b60@kernel.org/