mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Jeff Layton <jlayton@kernel.org>
To: Eric Dumazet <edumazet@google.com>, Jakub Kicinski <kuba@kernel.org>
Cc: Andrew Lunn <andrew@lunn.ch>,
	Andrew Morton <akpm@linux-foundation.org>,
	"David S. Miller" <davem@davemloft.net>,
	Paolo Abeni <pabeni@redhat.com>, Simon Horman <horms@kernel.org>,
	Kuniyuki Iwashima <kuniyu@amazon.com>,
	Qasim Ijaz <qasdev00@gmail.com>,
	Nathan Chancellor <nathan@kernel.org>,
	 linux-kernel@vger.kernel.org, netdev@vger.kernel.org
Subject: Re: [PATCH v4 7/7] net: register debugfs file for net_device refcnt tracker
Date: Fri, 25 Apr 2025 08:40:09 -0400	[thread overview]
Message-ID: <9580167080271af15ef6f1f9d9baa586539bc34e.camel@kernel.org> (raw)
In-Reply-To: <CANn89iJn53KF8CG4Q8D97sFy0hhkLrgWbFwHfJb8-w2DudZdZw@mail.gmail.com>

On Thu, 2025-04-24 at 16:07 -0700, Eric Dumazet wrote:
> On Thu, Apr 24, 2025 at 3:52 PM Jakub Kicinski <kuba@kernel.org> wrote:
> 
> > But with all that said, I guess you still want the "meaningful" ID for
> > the netns, and that one is in fact stable :S
> 
> We could add a stable id for net devices, and use it for this purpose
> 
> diff --git a/include/linux/netdevice.h b/include/linux/netdevice.h
> index 0321fd952f70887735ac789d72f72948a3879832..339d09167eaf7f58fc877fa470c94175237ce534
> 100644
> --- a/include/linux/netdevice.h
> +++ b/include/linux/netdevice.h
> @@ -2544,6 +2544,8 @@ struct net_device {
> 
>         struct hwtstamp_provider __rcu  *hwprov;
> 
> +       u64                     permanent_id;
> +
>         u8                      priv[] ____cacheline_aligned
>                                        __counted_by(priv_len);
>  } ____cacheline_aligned;
> diff --git a/net/core/dev.c b/net/core/dev.c
> index d1a8cad0c99c47996e8bda44bf220266a5e51102..9d2d45e0246fab99ad3e7523885224bd114fa686
> 100644
> --- a/net/core/dev.c
> +++ b/net/core/dev.c
> @@ -10954,6 +10954,9 @@ int register_netdevice(struct net_device *dev)
>  {
>         int ret;
>         struct net *net = dev_net(dev);
> +       static atomic64_t permanent_id;
> +
> +       dev->permanent_id = atomic64_inc_return(&permanent_id);
> 
>         BUILD_BUG_ON(sizeof(netdev_features_t) * BITS_PER_BYTE <
>                      NETDEV_FEATURE_COUNT);

That would give us uniqueness, but the name doesn't mean anything and
it wouldn't be trivial to track down which ref_tracker/netdev-* file
refers to which device.

If we're going to go that route, we're probably better off just
embedding the address in the name using a "netdev@%px" format.
-- 
Jeff Layton <jlayton@kernel.org>

  reply	other threads:[~2025-04-25 12:40 UTC|newest]

Thread overview: 22+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-04-18 14:24 [PATCH v4 0/7] ref_tracker: add ability to register a debugfs file for a ref_tracker_dir Jeff Layton
2025-04-18 14:24 ` [PATCH v4 1/7] ref_tracker: don't use %pK in pr_ostream() output Jeff Layton
2025-04-23 23:46   ` Jakub Kicinski
2025-04-23 23:56     ` Jeff Layton
2025-04-18 14:24 ` [PATCH v4 2/7] ref_tracker: add a top level debugfs directory for ref_tracker Jeff Layton
2025-04-18 14:24 ` [PATCH v4 3/7] ref_tracker: have callers pass output function to pr_ostream() Jeff Layton
2025-04-18 14:24 ` [PATCH v4 4/7] ref_tracker: allow pr_ostream() to print directly to a seq_file Jeff Layton
2025-04-18 14:24 ` [PATCH v4 5/7] ref_tracker: add ability to register a file in debugfs for a ref_tracker_dir Jeff Layton
2025-04-18 14:24 ` [PATCH v4 6/7] net: add ref_tracker_dir_debugfs() calls for netns refcount tracking Jeff Layton
2025-04-18 14:24 ` [PATCH v4 7/7] net: register debugfs file for net_device refcnt tracker Jeff Layton
2025-04-23 23:53   ` Jakub Kicinski
2025-04-24  0:04     ` Jeff Layton
2025-04-24  0:32       ` Jakub Kicinski
2025-04-24 10:56         ` Jeff Layton
2025-04-24 12:10           ` Andrew Lunn
2025-04-24 22:52             ` Jakub Kicinski
2025-04-24 23:07               ` Eric Dumazet
2025-04-25 12:40                 ` Jeff Layton [this message]
2025-04-25 12:46               ` Jeff Layton
2025-04-23 23:44 ` [PATCH v4 0/7] ref_tracker: add ability to register a debugfs file for a ref_tracker_dir Jakub Kicinski
2025-04-23 23:48   ` Jeff Layton
2025-04-23 23:56     ` Jakub Kicinski

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=9580167080271af15ef6f1f9d9baa586539bc34e.camel@kernel.org \
    --to=jlayton@kernel.org \
    --cc=akpm@linux-foundation.org \
    --cc=andrew@lunn.ch \
    --cc=davem@davemloft.net \
    --cc=edumazet@google.com \
    --cc=horms@kernel.org \
    --cc=kuba@kernel.org \
    --cc=kuniyu@amazon.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=nathan@kernel.org \
    --cc=netdev@vger.kernel.org \
    --cc=pabeni@redhat.com \
    --cc=qasdev00@gmail.com \
    /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

all inboxes | Powered by JetHome®