🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: linux.kernel.netdev
Article #27130

Re: [PATCH 1/2] netconsole: give the console of each target a unique name

#27130
From: Andy Shevchenko
Date: Fri, 04 Dec 2026 20:44
106 lines
14039 bytes
On Fri, Dec 04, 2026 at 12:01:51PM -0800, Chris Down wrote:
> Since commit 0d97bae9abbe ("netconsole: register one console per
> target") the console of a target is called netcons_<target name>. Only
> 15 characters of that fit in the name of a console and a target made
> through configfs always has index 0, so targets whose names start with
> the same seven characters get consoles with the same name and index.
> For example, with targets called target_alpha and target_beta:
> 
>     # grep netcons /proc/consoles
>     netcons_target_0     -W- (E  N   )
>     netcons_target_0     -W- (E  N   )
> 
> The targets which netcons_torture.sh creates all register as
> netcons_netcons0 in the same way. A target called cmdline5 which was
> not set up by netconsole= is cut to netcons_cmdline0 as well, and that
> is already the console of the first target from the command line.
> 
> That commit said that names could collide, and on its own all this
> means is that /proc/consoles can't tell these consoles apart. It
> becomes a real problem once something is keyed by the name. The
> per-console loglevel series [0] adds /sys/class/console/<name><index>
> for each console, which is also where the replay trigger for
> netconsole is expected to go [1]. With that series applied on top,
> enabling target_beta above prints a stack trace with
> 
>     sysfs: cannot create duplicate filename '/devices/virtual/console/netcons_target_0'
> 
> and the target is left without a directory in /sys/class/console, so
> there is no way to set its loglevel.
> 
> To fix this, let's give a new target the lowest index which no other
> target with the same console name has. The targets above become
> netcons_target_0 and netcons_target_1. A console name shorter than 15
> characters, like netcons_foo, can only belong to one target, so target
> foo keeps index 0 and is still netcons_foo0.
> 
> The index is chosen when the target is created, and not when its
> console is registered, so that the console keeps its name while the
> target is disabled and enabled again. Choosing it means looking at
> every other target. A target is on target_list or
> target_cleanup_list, except while process_resume_target() has taken it
> off both, which it does with dynamic_netconsole_mutex held.
> make_netconsole_target() thus takes that mutex and
> target_cleanup_list_lock as well as target_list_lock.
> 
> Numbering all the consoles from one counter would be simpler, but then
> target foo is no longer always netcons_foo0, and target a with index
> 10 would show up under the same name as target a1 with index 0.
> 
> I ran into this while testing the per-console loglevel series on top
> of net-next, with the two targets above. With this patch they get
> different names in /proc/consoles and, with that series applied, a
> directory each in /sys/class/console. The netconsole selftests still
> pass.

> [0]: https://lore.kernel.org/r/84b8d91693e56f6026271bc40553bcb6657ab24d.1764272407.git.chris@chrisdown.name
> [1]: https://lore.kernel.org/r/at84qygscue8crQi@gmail.com
> 

Convert them to Link tags in a form of Link: $URL [0] and so on...
With that, drop the blank line.

> Fixes: 0d97bae9abbe ("netconsole: register one console per target")
> Signed-off-by: Chris Down <chris@chrisdown.name>
> ---

...

> +/* Return the lowest index that no target uses together with the console name
> + * @name. A target is on target_list or on target_cleanup_list, unless
> + * process_resume_target() is resuming it under dynamic_netconsole_mutex, so
> + * the caller holds that mutex and the locks of both lists.
> + */

You should decide consistently which style (network or usual) of multi-line
comment should this driver use.

...

> +	lockdep_assert_held(&dynamic_netconsole_mutex);
> +	lockdep_assert_held(&target_cleanup_list_lock);
> +	lockdep_assert_held(&target_list_lock);

Would __must_hold() also help compiler to catch some problematic cases at
compile-time?

...

>  /*
>   * Group operations and type for netconsole_subsys.
>   */

You see, this is different style.

...

> +	/* netcons_<name> is cut to fit, so targets can share it. printk shows
> +	 * the index after the name, which is 0 unless the name is taken.
> +	 */

Same here.

-- 
With Best Regards,
Andy Shevchenko
Technical Details
Message-ID: <axMmKtBfzEW00KSR@ashevche-desk.local>
Path: mbox-mo1.pugleaf.net!news-fra.pugleaf.net!feed-eu-txt.newsdeef.eu!feed-eu-ch.newsdeef.eu!srl.newsdeef.eu!news.mb-net.net!open-news-network.org!news.nntp4.net!nntp.xenet.de!news.neodome.net!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-377626-linux-kernel-netdev=dewy.ru
References: <cover.1796410817.git.chris@chrisdown.name> <17873a1a6af2e6523697df22d83bb0a25b5298bc.1796410817.git.chris@chrisdown.name>

Show Full Headers
Complete Article Headers
Path: mbox-mo1.pugleaf.net!news-fra.pugleaf.net!feed-eu-txt.newsdeef.eu!feed-eu-ch.newsdeef.eu!srl.newsdeef.eu!news.mb-net.net!open-news-network.org!news.nntp4.net!nntp.xenet.de!news.neodome.net!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-377626-linux-kernel-netdev=dewy.ru
From: andriy.shevchenko@intel.com (Andy Shevchenko)
Newsgroups: linux.kernel.netdev
Subject: Re: [PATCH 1/2] netconsole: give the console of each target a unique
 name
Date: Fri, 4 Dec 2026 22:44:26 +0200
Organization: Usenet Network
Message-ID: <axMmKtBfzEW00KSR@ashevche-desk.local>
References: <cover.1796410817.git.chris@chrisdown.name>
 <17873a1a6af2e6523697df22d83bb0a25b5298bc.1796410817.git.chris@chrisdown.name>
MIME-Version: 1.0
Content-Type: text/plain; charset=us-ascii
Injection-Info: usenet.network;
	logging-data="2861390"; mail-complaints-to="abuse@usenet.network"
Cancel-Lock: sha1:1W/oG2SosujYWMgZJ85x+7YXrRA= sha256:tZtMWA6fkqaBpK6kPBjL8SH67oc3FQkCjL7P3ZY3NDM=
	sha1:fqHYO4Nvb+7dy6wz/y4uHVhgZrA= sha256:Wnur3r9lMrxavn96QKcf9glCOIPfIYBxry0rCollLPA=
Content-Disposition: inline
List-ID: <netdev.vger.kernel.org>
X-Mailpost-Empty-Hdrs: X-Spam-Level
X-Received: from localhost (localhost [127.0.0.1])
	by mail.dewy.ru (Postfix) with ESMTP id 93BDA117CDE; Fri,  4 Dec 2026 23:45:12 +0300 (MSK)
X-Virus-Scanned: Debian amavisd-new at usenet.network
X-Spam-Flag: NO
X-Spam-Score: -3.44
X-Spam-Status: No, score=-3.44 tagged_above=-9999 required=6.31
	tests=[DCC_REPUT_70_89=0.1, DKIMWL_WL_HIGH=-0.142, DKIM_SIGNED=0.1,
	DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1,
	HEADER_FROM_DIFFERENT_DOMAINS=0.001, MAILING_LIST_MULTI=-1,
	RCVD_IN_DNSWL_MED=-2.3, SPF_HELO_NONE=0.001, SPF_PASS=-0.001,
	URIBL_BLOCKED=0.001] autolearn=ham autolearn_force=no
X-Authentication-Results: mail.dewy.ru (amavisd-new); dkim=pass (2048-bit key)
	header.d=intel.com
X-Received: from mail.dewy.ru ([127.0.0.1])
	by localhost (mail.dewy.ru [127.0.0.1]) (amavisd-new, port 10024)
	with ESMTP id bA3J6DbctE5B;
	Fri,  4 Dec 2026 23:45:09 +0300 (MSK)
X-Received-SPF: Pass (mailfrom) identity=mailfrom; client-ip=172.234.253.10; helo=sea.lore.kernel.org; envelope-from=netdev+bounces-377626-linux-kernel-netdev=dewy.ru@vger.kernel.org; receiver=<UNKNOWN> 
X-Authentication-Results: OpenDMARC; dmarc=fail (p=none dis=none) header.from=intel.com
X-Received: from sea.lore.kernel.org (sea.lore.kernel.org [172.234.253.10])
	by mail.dewy.ru (Postfix) with ESMTPS id 0B422117C8B; Fri,  4 Dec 2026 23:45:00 +0300 (MSK)
X-Received: from smtp.subspace.kernel.org (conduit.subspace.kernel.org [100.77.114.92])
	by sea.lore.kernel.org (Postfix) with ESMTP id 97B7C3B0EC; Fri,  4 Dec 2026 20:44:35 +0000 (UTC)
X-Authentication-Results: smtp.subspace.kernel.org; arc=pass header.oldest-pass=0 smtp.remote-ip=127.0.0.1
X-ARC-Seal: i=2; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=pass;
	t=1796417075;
	b=12H6ycy+0zwxQ8u89nxM8NWUHJiKNrhmr7dowtCLuWHK3SF6asm7jS4USLT0Cks3qrVU
	 OMlrym8w8uKbpy7wmil03NGqHN6BGO5mKd765pB344SOQTCPPswK0Ke1q53UdlZx48pt1
	 3UD4KZe+mZiwOpfEf4sn7EM+nIcy2odrL0ltlxMGF6cf6X832Fi9ou68ph3lBoDZGtsIj
	 01S2LUozwgUh7MkDYyJJfKD9jvqQIwfM+yfiMdWWk+Y+q/OVzyAOXI0jKEt6iV2mAcE1v
	 0GjzYta+/IkAudFyscI9K1SAbsC2NyIImiAeqlwLHObG9F+a8IxlQMw51LbsIKI9KRw==
X-ARC-Message-Signature: i=2; d=subspace.kernel.org; s=arc20261015;
	a=rsa-sha256; c=relaxed/relaxed; t=1796417075;
	h=X-Original-To:Received:DMARC-Filter:DKIM-Signature:
	 X-CSE-ConnectionGUID:X-CSE-MsgGUID:X-IronPort-AV:X-IronPort-AV:
	 Received:X-CSE-ConnectionGUID:X-CSE-MsgGUID:X-ExtLoop1:X-IronPort-AV:
	 Received:Date:From:To:Cc:Subject:Message-ID:References:X-Mailing-List:
	 List-Id:List-Post:List-Help:List-Subscribe:List-Unsubscribe:
	 List-Owner:Precedence:MIME-Version:Content-Type:Content-Disposition:
	 In-Reply-To:Organization;
	bh=NBipODLpjFZmmlLzZbx6bcHCsZNZSz8OmVmtCWkAfhc=;
	b=bMXUyOIlBINyMCKhiWRpGY//bRWFdMSSuLJWl9SpczyvDrqxbjePatiJUK0NaeoATVaa
	 QdVWIiipzCt9JCpuU3E2F+oT0v6q+kOpmqadlpNhhWx/Y+oysai88UgJJpynVfiiZ8Wct
	 SpBgbbaTFL3o1Idr3vc1KTbe/dzbjPBKzj3qFSMU0d9rw7hOJYpYfqgzK0onHNQQpH0rD
	 8SQer9KKgksSFKJ5ZN6su2mfPyYxa0atmM9gKQotK/yID8k1IFD4/K3LObgFqQY2n9/kB
	 tvPeJoe07RsmNlBJp4QPWsFmp0M8jSqoduFEA+aDKb2BpoYZDaC61TBjBwolIJVjJjg==
X-ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; 
	dkim=pass header.d=intel.com header.i=@intel.com header.a=rsa-sha256 header.s=Intel header.b=S9SRZNOR;
	dmarc=pass header.from=intel.com;
	spf=pass smtp.mailfrom=intel.com;
	arc=pass header.oldest-pass=0 smtp.remote-ip=127.0.0.1
X-Received: from localhost.localdomain (localhost [127.0.0.1])
	by smtp.subspace.kernel.org (Postfix) with ESMTP id 5230E606A339;
	Fri,  4 Dec 2026 20:44:35 +0000 (UTC)
X-Authentication-Results: smtp.subspace.kernel.org;
	dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.a=rsa-sha256 header.s=Intel header.b=S9SRZNOR
X-Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=192.198.163.4
X-ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none;
	t=1796417074;
	b=m7sF2E85y0qdk8AfrKMidnlLkpPz4PJSIQYsZDOGbUBDPvo/W5iXJWOfLpuYpZiKhoE4
	 Uf2ZQiF8IU0UR8ZEULlKrlwbxcuEdrw9OWEoPRwirDVb6DSShP0mxBJ+le8JI2y6vNnQe
	 u2nvOX3+1KDtv8fXPkfN8cOLW0rb0wX7e5qG3hNnr6BaX1kTR4hDtoY8GHGLg+adld4AO
	 O8xuQtJWO6BCdwmXEF8ozh69ThhZg5lEB0G6SjXfBIAff6Tyl6+OmF3jvR7im7tbP6NEz
	 leWb/CyfcaUogUb2+Ll74WAiCj1r4GvPx2W0WLZY7GaN3+GTx5pMxA6rmtUMkSHNguA==
X-ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015;
	a=rsa-sha256; c=relaxed/relaxed; t=1796417074;
	h=DMARC-Filter:DKIM-Signature:X-CSE-ConnectionGUID:X-CSE-MsgGUID:
	 X-IronPort-AV:X-IronPort-AV:Received:X-CSE-ConnectionGUID:
	 X-CSE-MsgGUID:X-ExtLoop1:X-IronPort-AV:Received:Date:From:To:Cc:
	 Subject:Message-ID:References:MIME-Version:Content-Type:
	 Content-Disposition:In-Reply-To:Organization;
	bh=NBipODLpjFZmmlLzZbx6bcHCsZNZSz8OmVmtCWkAfhc=;
	b=ku2dYdfFkelEpp2hkMP9qeY7ll93VWR73nhKYYCPsd6T9gYgUK674BnwTVDEMy8h5uwO
	 NAgJnD3HQk0Xzw6jwG067QqLTYRti2yVDtEfbyhOhzX2QJI72paWDRKzlOFQPahowh09m
	 jWUm2mJa+CI1hUzkIvuY3yLFGky1c+r1Aw8AXEzZgFsFSfP5NqLotZi+aJwDtR+f3+ozD
	 LfwNezxSo1uajJFMV0FQtwuJ7QLYX7frw37TVvX6qDMywDsPXoRq55jyTaeaINb+frQ/f
	 KVbyT52CbIDGN3RqaMvs077cBaGaUWu9We0tIFY+8ndYXc1WBpQ11Hav8E/BraCNIOg==
X-ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; 
	dmarc=pass header.from=intel.com;
	spf=pass smtp.mailfrom=intel.com;
	dkim=pass header.d=intel.com header.i=@intel.com header.a=rsa-sha256 header.s=Intel header.b=S9SRZNOR;
	arc=none smtp.remote-ip=192.198.163.4
X-Received: from mgamail.intel.com (mgamail.intel.com [192.198.163.4])
	(using TLSv1.2 with cipher ECDHE-ECDSA-AES256-GCM-SHA384 (256/256 bits))
	(No client certificate requested)
	by smtp.subspace.kernel.org (Postfix) with ESMTPS id 206A7606A332;
	Fri,  4 Dec 2026 20:44:32 +0000 (UTC)
X-DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org 206A7606A332
X-Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=intel.com
X-Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=intel.com
X-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple;
  d=intel.com; i=@intel.com; q=dns/txt; s=Intel;
  t=1796417074; x=1827953074;
  h=date:from:to:cc:subject:message-id:references:
   mime-version:in-reply-to;
  bh=ZfqkhERz72J/LnPq/KnLivm5pp9FfBMC1LDyOnBU2Ms=;
  b=S9SRZNORdP3hcHOShzWluAkFJrskkEz7RUlYXbzH8nsOR7p0j4NnBJSD
   uyrGtGmIZgySlZgaiMUcNuJb1vCJ1BLxuYaogGnBwIv5W6k0ooFLE7vhY
   CjR2MUWCNoUGQWnEgBvNXBPS0RrJO3krs/WPAdpP8wi9RO28dQ/65PSfh
   ctzUcYq02UbQEjiVJCTSR4HfQM4aldmqFDrL8QtvdejNUNN10KvPYUY3d
   YYvM8KUy5xIHvUes1pr4n9OXTjroGjkSfRYEpf1tqntsc84E12gCQAHD1
   ukNkJgg8m3zHP6IodjQrnJZKdNiv5m1zeWpx7fY8Ns9kpeocKhwe+8U4u
   Q==;
X-CSE-ConnectionGUID: zqw9PwWGQfKaezzLYHHnzg==
X-CSE-MsgGUID: O1Uxo9hmTA+aD1Go34/skA==
X-IronPort-AV: E=McAfee;i="6800,10657,11986"; a="160791"
X-IronPort-AV: E=Sophos;i="6.29,79,1794902400"; 
   d="scan'208";a="160791"
X-Received: from fmviesa011.fm.intel.com ([10.60.135.151])
  by fmvoesa114.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 04 Dec 2026 12:44:33 -0800
X-CSE-ConnectionGUID: KBhiV/sxTviWoWqEGdRCKw==
X-CSE-MsgGUID: S6HUfg39R/uTxko2sTNJ1A==
X-ExtLoop1: 1
X-IronPort-AV: E=Sophos;i="6.29,79,1794902400"; 
   d="scan'208";a="15921997"
X-Received: from alekseim-mobl.ger.corp.intel.com (HELO localhost) ([10.245.245.10])
  by smtpauth.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 04 Dec 2026 12:44:28 -0800
X-Cc: Breno Leitao <leitao@debian.org>, Andrew Lunn <andrew+netdev@lunn.ch>,
	"David S. Miller" <davem@davemloft.net>,
	Eric Dumazet <edumazet@kernel.org>,
	Jakub Kicinski <kuba@kernel.org>, Paolo Abeni <pabeni@redhat.com>,
	Shuah Khan <shuah@kernel.org>,
	Shuah Khan <skhan@linuxfoundation.org>,
	Gustavo Luiz Duarte <gustavold@gmail.com>,
	linux-kselftest@vger.kernel.org, netdev@vger.kernel.org,
	linux-kernel@vger.kernel.org, pmladek@suse.com,
	john.ogness@linutronix.de, printk@lists.linux.dev,
	kernel-team@meta.com
X-Mailing-List: netdev@vger.kernel.org
X-List-Post: <mailto:netdev@vger.kernel.org>
X-List-Help: <mailto:netdev+help@vger.kernel.org>
X-List-Subscribe: <mailto:netdev+subscribe@vger.kernel.org>
X-List-Unsubscribe: <mailto:netdev+unsubscribe@vger.kernel.org>
X-List-Owner: <mailto:netdev+owner@vger.kernel.org>
X-Precedence: list
X-In-Reply-To: <17873a1a6af2e6523697df22d83bb0a25b5298bc.1796410817.git.chris@chrisdown.name>
X-Organization: Intel Finland Oy - BIC 0357606-4 - c/o Alberga Business Park, 6
 krs, Bertel Jungin Aukio 5, 02600 Espoo