All of lore.kernel.org
 help / color / mirror / Atom feed
From: Eric Dumazet <eric.dumazet@gmail.com>
To: "David S . Miller" <davem@davemloft.net>,
	Jakub Kicinski <kuba@kernel.org>
Cc: netdev <netdev@vger.kernel.org>,
	Dmitry Vyukov <dvyukov@google.com>,
	Eric Dumazet <edumazet@google.com>,
	Eric Dumazet <eric.dumazet@gmail.com>
Subject: [PATCH net-next 04/19] net: add net device refcount tracker to struct netdev_rx_queue
Date: Wed,  1 Dec 2021 19:21:24 -0800	[thread overview]
Message-ID: <20211202032139.3156411-5-eric.dumazet@gmail.com> (raw)
In-Reply-To: <20211202032139.3156411-1-eric.dumazet@gmail.com>

From: Eric Dumazet <edumazet@google.com>

This helps debugging net device refcount leaks.

Signed-off-by: Eric Dumazet <edumazet@google.com>
---
 include/linux/netdevice.h | 2 ++
 net/core/net-sysfs.c      | 4 ++--
 2 files changed, 4 insertions(+), 2 deletions(-)

diff --git a/include/linux/netdevice.h b/include/linux/netdevice.h
index 3ddced0fa20f5c7a4548c340788214ea909a265f..01006e02f8e66fc3ee16890d3bbdb49e3e7386b6 100644
--- a/include/linux/netdevice.h
+++ b/include/linux/netdevice.h
@@ -741,6 +741,8 @@ struct netdev_rx_queue {
 #endif
 	struct kobject			kobj;
 	struct net_device		*dev;
+	netdevice_tracker		dev_tracker;
+
 #ifdef CONFIG_XDP_SOCKETS
 	struct xsk_buff_pool            *pool;
 #endif
diff --git a/net/core/net-sysfs.c b/net/core/net-sysfs.c
index affe34d71d313498d8fae4a319696250aa3aef0a..27a7ac2e516f65dbfdb2a2319e6faa27c7dd8f31 100644
--- a/net/core/net-sysfs.c
+++ b/net/core/net-sysfs.c
@@ -1004,7 +1004,7 @@ static void rx_queue_release(struct kobject *kobj)
 #endif
 
 	memset(kobj, 0, sizeof(*kobj));
-	dev_put(queue->dev);
+	dev_put_track(queue->dev, &queue->dev_tracker);
 }
 
 static const void *rx_queue_namespace(struct kobject *kobj)
@@ -1044,7 +1044,7 @@ static int rx_queue_add_kobject(struct net_device *dev, int index)
 	/* Kobject_put later will trigger rx_queue_release call which
 	 * decreases dev refcount: Take that reference here
 	 */
-	dev_hold(queue->dev);
+	dev_hold_track(queue->dev, &queue->dev_tracker, GFP_KERNEL);
 
 	kobj->kset = dev->queues_kset;
 	error = kobject_init_and_add(kobj, &rx_queue_ktype, NULL,
-- 
2.34.0.rc2.393.gf8c9666880-goog


  parent reply	other threads:[~2021-12-02  3:22 UTC|newest]

Thread overview: 42+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-12-02  3:21 [PATCH net-next 00/19] net: add preliminary netdev refcount tracking Eric Dumazet
2021-12-02  3:21 ` [PATCH net-next 01/19] lib: add reference counting tracking infrastructure Eric Dumazet
2021-12-02  8:12   ` Dmitry Vyukov
2021-12-02 16:05     ` Eric Dumazet
2021-12-02  3:21 ` [PATCH net-next 02/19] lib: add tests for reference tracker Eric Dumazet
2021-12-02  3:31   ` Eric Dumazet
2021-12-02  9:03   ` kernel test robot
2021-12-02  9:03     ` kernel test robot
2021-12-02 19:25   ` kernel test robot
2021-12-02 19:25     ` kernel test robot
2021-12-02 19:46     ` Eric Dumazet
2021-12-02 19:46       ` Eric Dumazet
2021-12-03  7:37       ` Dmitry Vyukov
2021-12-03  7:37         ` Dmitry Vyukov
2021-12-02  3:21 ` [PATCH net-next 03/19] net: add dev_hold_track() and dev_put_track() helpers Eric Dumazet
2022-05-23 18:03   ` Jakub Kicinski
2022-05-23 18:14     ` Eric Dumazet
2022-05-23 18:26       ` Jakub Kicinski
2021-12-02  3:21 ` Eric Dumazet [this message]
2021-12-02  3:21 ` [PATCH net-next 05/19] net: add net device refcount tracker to struct netdev_queue Eric Dumazet
2021-12-02  3:21 ` [PATCH net-next 06/19] net: add net device refcount tracker to ethtool_phys_id() Eric Dumazet
2021-12-02  3:21 ` [PATCH net-next 07/19] net: add net device refcount tracker to dev_ifsioc() Eric Dumazet
2021-12-02  3:21 ` [PATCH net-next 08/19] drop_monitor: add net device refcount tracker Eric Dumazet
2021-12-02  5:40   ` kernel test robot
2021-12-02  5:40     ` kernel test robot
2021-12-02  5:57     ` Eric Dumazet
2021-12-02  5:57       ` Eric Dumazet
2021-12-02  3:21 ` [PATCH net-next 09/19] net: dst: add net device refcount tracking to dst_entry Eric Dumazet
2021-12-02  3:21 ` [PATCH net-next 10/19] ipv6: add net device refcount tracker to rt6_probe_deferred() Eric Dumazet
2021-12-02  3:21 ` [PATCH net-next 11/19] sit: add net device refcount tracking to ip_tunnel Eric Dumazet
2021-12-02  3:21 ` [PATCH net-next 12/19] ipv6: add net device refcount tracker to struct ip6_tnl Eric Dumazet
2021-12-02  3:21 ` [PATCH net-next 13/19] net: add net device refcount tracker to struct neighbour Eric Dumazet
2021-12-02  3:21 ` [PATCH net-next 14/19] net: add net device refcount tracker to struct pneigh_entry Eric Dumazet
2021-12-02  3:21 ` [PATCH net-next 15/19] net: add net device refcount tracker to struct neigh_parms Eric Dumazet
2021-12-02  3:21 ` [PATCH net-next 16/19] net: add net device refcount tracker to struct netdev_adjacent Eric Dumazet
2021-12-02  3:21 ` [PATCH net-next 17/19] ipv6: add net device refcount tracker to struct inet6_dev Eric Dumazet
2021-12-02  3:21 ` [PATCH net-next 18/19] ipv4: add net device refcount tracker to struct in_device Eric Dumazet
2021-12-02  3:21 ` [PATCH net-next 19/19] net/sched: add net device refcount tracker to struct Qdisc Eric Dumazet
2021-12-02 12:49 ` [PATCH net-next 00/19] net: add preliminary netdev refcount tracking dust.li
2021-12-02 15:13   ` Eric Dumazet
2021-12-03  3:46     ` dust.li
2021-12-03  4:06       ` Eric Dumazet

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=20211202032139.3156411-5-eric.dumazet@gmail.com \
    --to=eric.dumazet@gmail.com \
    --cc=davem@davemloft.net \
    --cc=dvyukov@google.com \
    --cc=edumazet@google.com \
    --cc=kuba@kernel.org \
    --cc=netdev@vger.kernel.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.