[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <CANn89iJn53KF8CG4Q8D97sFy0hhkLrgWbFwHfJb8-w2DudZdZw@mail.gmail.com>
Date: Thu, 24 Apr 2025 16:07:15 -0700
From: Eric Dumazet <edumazet@...gle.com>
To: Jakub Kicinski <kuba@...nel.org>
Cc: Andrew Lunn <andrew@...n.ch>, Jeff Layton <jlayton@...nel.org>,
Andrew Morton <akpm@...ux-foundation.org>, "David S. Miller" <davem@...emloft.net>,
Paolo Abeni <pabeni@...hat.com>, Simon Horman <horms@...nel.org>,
Kuniyuki Iwashima <kuniyu@...zon.com>, Qasim Ijaz <qasdev00@...il.com>,
Nathan Chancellor <nathan@...nel.org>, linux-kernel@...r.kernel.org, netdev@...r.kernel.org
Subject: Re: [PATCH v4 7/7] net: register debugfs file for net_device refcnt tracker
On Thu, Apr 24, 2025 at 3:52 PM Jakub Kicinski <kuba@...nel.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);
Powered by blists - more mailing lists