summaryrefslogtreecommitdiffstats
path: root/net/Kconfig.debug
diff options
context:
space:
mode:
authorEric Dumazet <edumazet@google.com>2021-12-05 05:21:57 +0100
committerJakub Kicinski <kuba@kernel.org>2021-12-07 01:05:07 +0100
commit4d92b95ff2f95f13df9bad0b5a25a9f60e72758d (patch)
tree0e0fa4c1662c49b683170ed02da58ab253da23d7 /net/Kconfig.debug
parentlib: add tests for reference tracker (diff)
downloadlinux-4d92b95ff2f95f13df9bad0b5a25a9f60e72758d.tar.xz
linux-4d92b95ff2f95f13df9bad0b5a25a9f60e72758d.zip
net: add net device refcount tracker infrastructure
net device are refcounted. Over the years we had numerous bugs caused by imbalanced dev_hold() and dev_put() calls. 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. This patch adds dev_hold_track() and dev_put_track(). To use these helpers, each data structure owning a refcount should also use a "netdevice_tracker" to pair the hold and put. netdevice_tracker dev_tracker; ... dev_hold_track(dev, &dev_tracker, GFP_ATOMIC); ... dev_put_track(dev, &dev_tracker); Whenever a leak happens, we will get precise stack traces of the point dev_hold_track() happened, at device dismantle phase. We will also get a stack trace if too many dev_put_track() for the same netdevice_tracker are attempted. This is guarded by CONFIG_NET_DEV_REFCNT_TRACKER option. Signed-off-by: Eric Dumazet <edumazet@google.com> Signed-off-by: Jakub Kicinski <kuba@kernel.org>
Diffstat (limited to 'net/Kconfig.debug')
-rw-r--r--net/Kconfig.debug10
1 files changed, 10 insertions, 0 deletions
diff --git a/net/Kconfig.debug b/net/Kconfig.debug
new file mode 100644
index 000000000000..fb5c70e01cb3
--- /dev/null
+++ b/net/Kconfig.debug
@@ -0,0 +1,10 @@
+# SPDX-License-Identifier: GPL-2.0-only
+
+config NET_DEV_REFCNT_TRACKER
+ bool "Enable net device refcount tracking"
+ depends on DEBUG_KERNEL && STACKTRACE_SUPPORT
+ select REF_TRACKER
+ default n
+ help
+ Enable debugging feature to track device references.
+ This adds memory and cpu costs.