From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-wm1-f53.google.com (mail-wm1-f53.google.com [209.85.128.53]) (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 C5B1C20C48A for ; Thu, 29 Jan 2026 15:19:13 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.53 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1769699955; cv=none; b=ZMobNEF04QLj9WwH2q8NKItLjdakhv/6AGDmoAH/K0F9SRFXhrunxmIpLlWOijq39p5ps3RnxjqlZ4NHMMHBaihxo8FFRxIe0K27IgsoQ+H+hRWGCQ53q7Kks4lbHfe8wuNfqwuFGj8J5oJ3zTgQ6uA93MU9Y9MDMfqSk7Mv21U= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1769699955; c=relaxed/simple; bh=+tmrzRllSFS3UuYo3ZY8r+bPOjC6VUQ2B+vahz2nAVg=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=qw5loyrB+DEmAo+oFaZsr0U71kpXabX8R2z47cjQcDQlQWOZGSzt+FiCiiEdUOgkjn0VjsEceWpxnspU4nEoWF48gLyWqBMGnEt8a7HlDj/1iIcV2dkCkLdTMExFGVYHPJ38dWEAKBPoZ755oEs1TEt5iHmQ5iBZs9BtGT04ydI= 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=JtUxkb2f; arc=none smtp.client-ip=209.85.128.53 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="JtUxkb2f" Received: by mail-wm1-f53.google.com with SMTP id 5b1f17b1804b1-4806f80cac9so7074685e9.1 for ; Thu, 29 Jan 2026 07:19:13 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.com; s=google; t=1769699952; x=1770304752; 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=MsXQrimwewQ8w9Fgh0pLIlGot9P2osFHXzwl6y2/yiU=; b=JtUxkb2fg1gE6rezHHyO/F3n9KTJvBt52O1kDQLFP4aBvEhDX7WKVxT85Pbe++Uzkl R2iwCu2deClFOvBFwuVikR/dMC/9oYLzqFgWXC4ERvByVL4p86bkmI547fh5UOaBYQwj ZehZpyXLBvGzZFITnEYjnBRYiC2aZPOYl85LPoN2Q2VzVHwDUQDWbt6YZkIJTbToQbnw wQWg1uN2EHltHi4HT1+lw/bfK40VY23rM27uNukbe1mAJtBnhcOMi4LyGTqcXdBkodNn MxYAXhq3It+9D1sCvANj0YKRPcW7s3OsWFak4xq5mTVedZxsTXv849JPN/ywMdhPaBEH 2rUw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1769699952; x=1770304752; 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=MsXQrimwewQ8w9Fgh0pLIlGot9P2osFHXzwl6y2/yiU=; b=It3boUZBFw8h5mkyR5XYABDwLModRKJDINeNXhP9/mJvSUtbfucfTdqBdr90Pfd7vU HOidEBzPV2a0fmtY1LtlbPzhR+Ohho5tjrQ4AxMTins81ZGScPCQTwgwGcGaeDBXa9PB Xho2OpHUslO3H6RXvmawG+hfJrg3H+iYASQSvlhTWPUyNxD02BfW8pckdj3E9Rgt9NGH MxnVXLQER7uG5vOGDzvqAcOkxwMrmXBZFSdptn4j8bbWAoN/fSRA9Srs+Xo983X1slBw 2+v/SNNebTPAkEP7jO7IQFCrFSCeizWXan5seNK+sRsqsDfq8EKANc6p1Rb8ROaEYwF4 NjYg== X-Forwarded-Encrypted: i=1; AJvYcCW0hf7iczy7x6C7OKN6/vcifPCPWyaRnexSxWBi/jNhjqneG3855ddX2p9NjoTB0+nQmasu0iXDRFlp6pc=@vger.kernel.org X-Gm-Message-State: AOJu0Ywq90SLwD/JxZR3UjL28CHQbKg1N7XbgrhGkypgBMp2fqgN9Jh1 YRkoLxAMZnnBljlO61xU3XpcsVIKTafdSNRVoW5/x63d26x2onf6NoPwU2/g+iSvLXM= X-Gm-Gg: AZuq6aKlAzjZyKJD0S0uNAEGEPE+UJH1KQQWsBrW7Oq0yp6jCrcZy5eK+f7SOaAddHD 9RqlR8pMZs++Ms2yOp+pXpx7iwqp2UEKU0HNtbjWMA5VRf03I4HAfMTylAsJByW+dUQn/wkje6x GeFUCzHUexw/b8Hk5IFcRMT+DewdDon8QOUbg2ArLQkC4vGTTp3uApNRAL45drWJ+xGyMA7dqCU 7dLQxkFQGbKANdukKapdOYPyCFU9Cjcy+QfF3NMMBroDevK0f3fKvGYVO2aj0ZCqLWamap8p6sl gnz822N29WfAcYUG2edyunFhTdD1K/izbBr142NFXC3c//19h96QmEhQpQlnsFkNV/Vx/ZM5GUx oY+sScI7f2VxZWHA9y4RGPeqxFXontIB9HweDtR16nCsruz0maIvWjKxi7xtsMGQWrpTLmP3ll0 SAN/sF0T5hvqkIVogtXYWNANPG X-Received: by 2002:a05:600c:46d5:b0:477:5897:a0c4 with SMTP id 5b1f17b1804b1-48069c3fb85mr106936725e9.4.1769699952070; Thu, 29 Jan 2026 07:19:12 -0800 (PST) Received: from pathway.suse.cz ([176.114.240.130]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-48066c40e04sm201022335e9.13.2026.01.29.07.19.10 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 29 Jan 2026 07:19:11 -0800 (PST) Date: Thu, 29 Jan 2026 16:19:08 +0100 From: Petr Mladek To: Breno Leitao Cc: Andrew Lunn , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , 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 v5 3/4] netconsole: convert to NBCON console infrastructure Message-ID: References: <20260128-nbcon-v5-0-93b4ddbc181a@debian.org> <20260128-nbcon-v5-3-93b4ddbc181a@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: <20260128-nbcon-v5-3-93b4ddbc181a@debian.org> On Wed 2026-01-28 06:17:39, 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. I was just curious and scratched my head around this a bit. If I get it correctly then it might fail only in a single situation. It actually should never happen on systems which stop CPUs by NMI. My thiking is: 1. nbcon->write_thread() is called only from the dedicated kthread so that there is always only one instance. It might actually be called also by the legacy loop when a boot console is registed. But the kthread is blocked in this case. Anyway, the callback is serialized also using netcon->device_lock(). 2. nbcon->write_atomic() is called only by the final nbcon_atomic_flush_unsafe() because of CON_NBCON_ATOMIC_UNSAFE. nbcon_enter_unsafe() always succeeds here because the _usafe_ takeover is allowed. 3. No other lock is synchronized with nbcon context. It is acceptable because nbcon->write_atomic() is called only by nbcon_atomic_flush_unsafe() where the nbcon context synchronization is ignored anyway. So, nbcon_enter_unsafe() might fail only in netcon->write_thread() when the kthread is still running on another CPU while nbcon_atomic_flush_unsafe() is called on the panic CPU. And it should never happen when the non-panic CPUs are stopped by NMI. By other words, the nbcon context synchronization does not have much value when CON_NBCON_ATOMIC_UNSAFE is used. It is acceptable from my POV. I write this just to make the expectations clear. I wish, I had time to write a more comprehensible documentation about the printk design... > - 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 Feel free to use: Reviewed-by: Petr Mladek Best Regards, Petr