From: Andy Shevchenko <andriy.shevchenko@intel.com>
To: Chris Down <chris@chrisdown.name>
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
Subject: Re: [PATCH 1/2] netconsole: give the console of each target a unique name
Date: Fri, 4 Dec 2026 22:44:26 +0200 [thread overview]
Message-ID: <axMmKtBfzEW00KSR@ashevche-desk.local> (raw)
In-Reply-To: <17873a1a6af2e6523697df22d83bb0a25b5298bc.1796410817.git.chris@chrisdown.name>
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
next prev parent reply other threads:[~2026-12-04 20:44 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-12-04 20:01 [PATCH 0/2] netconsole: give the console of each target a unique name Chris Down
2026-12-04 20:01 ` [PATCH 1/2] " Chris Down
2026-12-04 20:44 ` Andy Shevchenko [this message]
2026-12-04 20:01 ` [PATCH 2/2] selftests: netconsole: check that targets get distinct console names Chris Down
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=axMmKtBfzEW00KSR@ashevche-desk.local \
--to=andriy.shevchenko@intel.com \
--cc=andrew+netdev@lunn.ch \
--cc=chris@chrisdown.name \
--cc=davem@davemloft.net \
--cc=edumazet@kernel.org \
--cc=gustavold@gmail.com \
--cc=john.ogness@linutronix.de \
--cc=kernel-team@meta.com \
--cc=kuba@kernel.org \
--cc=leitao@debian.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-kselftest@vger.kernel.org \
--cc=netdev@vger.kernel.org \
--cc=pabeni@redhat.com \
--cc=pmladek@suse.com \
--cc=printk@lists.linux.dev \
--cc=shuah@kernel.org \
--cc=skhan@linuxfoundation.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox