Skip to content

net: add preliminary netdev refcount tracking

Eric Dumazet linux-mm netdev 3 versions – In review

Get series with b4
b4 am [email protected]

Versions newest first · linked by author and title

  1. v3 Latest23 patches 28 repliesIn review
  2. v223 patches 4 repliesSuperseded
  3. v119 patches 13 repliesSuperseded

Patches in v3 No applies recorded yet

#Subject and filesSizeRepliesApplied
1/23lib: add reference counting tracking infrastructureinclude/linux/ref_tracker.h lib/Kconfig lib/Makefile +1 more+220 -012 replies
2/23lib: add tests for reference trackerlib/Kconfig.debug lib/Makefile lib/test_ref_tracker.c+126 -10 replies
3/23net: add net device refcount tracker infrastructureinclude/linux/netdevice.h lib/Kconfig.debug net/Kconfig.debug +1 more+64 -00 replies
4/23net: add net device refcount tracker to struct netdev_rx_queueinclude/linux/netdevice.h net/core/net-sysfs.c+4 -20 replies
5/23net: add net device refcount tracker to struct netdev_queueinclude/linux/netdevice.h net/core/net-sysfs.c+4 -20 replies
6/23net: add net device refcount tracker to ethtool_phys_id()net/ethtool/ioctl.c+3 -20 replies
7/23net: add net device refcount tracker to dev_ifsioc()net/core/dev_ioctl.c+3 -20 replies
8/23drop_monitor: add net device refcount trackerinclude/net/devlink.h net/core/drop_monitor.c+7 -30 replies
9/23net: dst: add net device refcount tracking to dst_entryinclude/linux/netdevice.h include/net/dst.h net/core/dst.c +2 more+29 -90 replies
10/23ipv6: add net device refcount tracker to rt6_probe_deferred()net/ipv6/route.c+3 -20 replies
11/23sit: add net device refcount tracking to ip_tunnelinclude/net/ip_tunnels.h net/ipv6/sit.c+5 -20 replies
12/23ipv6: add net device refcount tracker to struct ip6_tnlinclude/net/ip6_tunnel.h net/ipv6/ip6_gre.c net/ipv6/ip6_tunnel.c +1 more+9 -80 replies
13/23net: add net device refcount tracker to struct neighbourinclude/net/neighbour.h net/core/neighbour.c+3 -20 replies
14/23net: add net device refcount tracker to struct pneigh_entryinclude/net/neighbour.h net/core/neighbour.c+5 -40 replies
15/23net: add net device refcount tracker to struct neigh_parmsinclude/net/neighbour.h net/core/neighbour.c+4 -30 replies
16/23net: add net device refcount tracker to struct netdev_adjacentnet/core/dev.c+4 -30 replies
17/23ipv6: add net device refcount tracker to struct inet6_devinclude/net/if_inet6.h net/ipv6/addrconf.c net/ipv6/addrconf_core.c+4 -30 replies
18/23ipv4: add net device refcount tracker to struct in_deviceinclude/linux/inetdevice.h net/ipv4/devinet.c+4 -20 replies
19/23net/sched: add net device refcount tracker to struct Qdiscinclude/net/sch_generic.h net/sched/sch_generic.c+3 -30 replies
20/23net: linkwatch: add net device refcount trackerinclude/linux/netdevice.h net/core/link_watch.c+4 -20 replies
21/23net: failover: add net device refcount trackerinclude/net/failover.h net/core/failover.c+3 -20 replies
22/23ipmr, ip6mr: add net device refcount tracker to struct vif_deviceinclude/linux/mroute_base.h net/ipv4/ipmr.c net/ipv6/ip6mr.c+6 -20 replies
23/23netpoll: add net device refcount tracker to struct netpolldrivers/net/netconsole.c include/linux/netpoll.h net/core/netpoll.c+4 -30 replies

Reviews trailers per patch

1 of 23 patches has a Reviewed-by or Acked-by.

PatchDmitry VyukovEric Dumazet
1/23R-b R-b
2/23
3/23
4/23
5/23
6/23
7/23
8/23
9/23
10/23
11/23
12/23
13/23
14/23
15/23
16/23
17/23
18/23
19/23
20/23
21/23
22/23
23/23

Trailers given in replies are filled; those carried in the patches from earlier versions are outlined with dashes.

Read the v3 thread

Cover letter [PATCH v3 net-next 00/23] net: add preliminary netdev refcount tracking

From: Eric Dumazet <[email protected]>

Two first patches add a generic infrastructure, that will be used to get tracking of refcount increments/decrements.

The general idea is to be able to precisely pair each decrement with a corresponding prior increment. Both share a cookie, basically a pointer to private data storing stack traces.

The third patch adds dev_hold_track() and dev_put_track() helpers (CONFIG_NET_DEV_REFCNT_TRACKER)

Then a series of 20 patches converts some dev_hold()/dev_put() pairs to new hepers : dev_hold_track() and dev_put_track().

Hopefully this will be used by developpers and syzbot to root cause bugs that cause netdevice dismantles freezes.

With CONFIG_PCPU_DEV_REFCNT=n option, we were able to detect some class of bugs, but too late (when too many dev_put() were happening).

Another series will be sent after this one is merged.

v3: moved NET_DEV_REFCNT_TRACKER to net/Kconfig.debug
added "depends on DEBUG_KERNEL && STACKTRACE_SUPPORT" to hopefully get rid of kbuild reports for ARCH=nios2 Reworded patch 3 changelog.
Added missing htmldocs (Jakub)

v2: added four additional patches,
added netdev_tracker_alloc() and netdev_tracker_free() addressed build error (kernel bots),
use GFP_ATOMIC in test_ref_tracker_timer_func()

Eric Dumazet (23):
lib: add reference counting tracking infrastructure
lib: add tests for reference tracker
net: add net device refcount tracker infrastructure
net: add net device refcount tracker to struct netdev_rx_queue
net: add net device refcount tracker to struct netdev_queue
net: add net device refcount tracker to ethtool_phys_id()
net: add net device refcount tracker to dev_ifsioc()
drop_monitor: add net device refcount tracker
net: dst: add net device refcount tracking to dst_entry
ipv6: add net device refcount tracker to rt6_probe_deferred()
sit: add net device refcount tracking to ip_tunnel
ipv6: add net device refcount tracker to struct ip6_tnl
net: add net device refcount tracker to struct neighbour
net: add net device refcount tracker to struct pneigh_entry
net: add net device refcount tracker to struct neigh_parms
net: add net device refcount tracker to struct netdev_adjacent
ipv6: add net device refcount tracker to struct inet6_dev
ipv4: add net device refcount tracker to struct in_device net/sched: add net device refcount tracker to struct Qdisc
net: linkwatch: add net device refcount tracker
net: failover: add net device refcount tracker
ipmr, ip6mr: add net device refcount tracker to struct vif_device
netpoll: add net device refcount tracker to struct netpoll

 drivers/net/netconsole.c    |   2 +-
 include/linux/inetdevice.h  |   2 +
 include/linux/mroute_base.h |   2 +
 include/linux/netdevice.h   |  68 ++++++++++++++++++
 include/linux/netpoll.h     |   1 +
 include/linux/ref_tracker.h |  73 +++++++++++++++++++
 include/net/devlink.h       |   4 ++
 include/net/dst.h           |   1 +
 include/net/failover.h      |   1 +
 include/net/if_inet6.h      |   1 +
 include/net/ip6_tunnel.h    |   1 +
 include/net/ip_tunnels.h    |   3 +
 include/net/neighbour.h     |   3 +
 include/net/sch_generic.h   |   2 +-
 lib/Kconfig                 |   5 ++
 lib/Kconfig.debug           |  15 ++++
 lib/Makefile                |   4 +-
 lib/ref_tracker.c           | 140 ++++++++++++++++++++++++++++++++++++
 lib/test_ref_tracker.c      | 115 +++++++++++++++++++++++++++++
 net/Kconfig.debug           |  11 +++
 net/core/dev.c              |  10 ++-
 net/core/dev_ioctl.c        |   5 +-
 net/core/drop_monitor.c     |   6 +-
 net/core/dst.c              |   8 +--
 net/core/failover.c         |   4 +-
 net/core/link_watch.c       |   4 +-
 net/core/neighbour.c        |  18 ++---
 net/core/net-sysfs.c        |   8 +--
 net/core/netpoll.c          |   4 +-
 net/ethtool/ioctl.c         |   5 +-
 net/ipv4/devinet.c          |   4 +-
 net/ipv4/ipmr.c             |   3 +-
 net/ipv4/route.c            |   7 +-
 net/ipv6/addrconf.c         |   4 +-
 net/ipv6/addrconf_core.c    |   2 +-
 net/ipv6/ip6_gre.c          |   8 +--
 net/ipv6/ip6_tunnel.c       |   4 +-
 net/ipv6/ip6_vti.c          |   4 +-
 net/ipv6/ip6mr.c            |   3 +-
 net/ipv6/route.c            |  10 +--
 net/ipv6/sit.c              |   4 +-
 net/sched/sch_generic.c     |   4 +-
 42 files changed, 521 insertions(+), 62 deletions(-)
 create mode 100644 include/linux/ref_tracker.h
 create mode 100644 lib/ref_tracker.c
 create mode 100644 lib/test_ref_tracker.c
 create mode 100644 net/Kconfig.debug
Signature · 1 line
2.34.1.400.ga245620fadb-goog