From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=192.198.163.4 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== 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== 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 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) DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org 206A7606A332 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=intel.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=intel.com 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 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" 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" 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 Date: Fri, 4 Dec 2026 22:44:26 +0200 From: Andy Shevchenko To: Chris Down Cc: Breno Leitao , Andrew Lunn , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Shuah Khan , Shuah Khan , Gustavo Luiz Duarte , 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 Message-ID: References: <17873a1a6af2e6523697df22d83bb0a25b5298bc.1796410817.git.chris@chrisdown.name> X-Mailing-List: netdev@vger.kernel.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <17873a1a6af2e6523697df22d83bb0a25b5298bc.1796410817.git.chris@chrisdown.name> Organization: Intel Finland Oy - BIC 0357606-4 - c/o Alberga Business Park, 6 krs, Bertel Jungin Aukio 5, 02600 Espoo 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_. 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/ > 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 > --- ... > +/* 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_ 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