From: Jeff Layton <jlayton@kernel.org>
To: "David S. Miller" <davem@davemloft.net>,
Eric Dumazet <edumazet@google.com>,
Jakub Kicinski <kuba@kernel.org>,
Paolo Abeni <pabeni@redhat.com>, Simon Horman <horms@kernel.org>,
Andrew Morton <akpm@linux-foundation.org>
Cc: Andrew Lunn <andrew@lunn.ch>,
netdev@vger.kernel.org, linux-kernel@vger.kernel.org,
Jeff Layton <jlayton@kernel.org>
Subject: [PATCH v2 1/2] ref_tracker: add a top level debugfs directory for ref_tracker
Date: Tue, 08 Apr 2025 09:36:37 -0400 [thread overview]
Message-ID: <20250408-netns-debugfs-v2-1-ca267f51461e@kernel.org> (raw)
In-Reply-To: <20250408-netns-debugfs-v2-0-ca267f51461e@kernel.org>
Add a new "ref_tracker" directory in debugfs. Each individual refcount
tracker can add a directory or files under there to display info about
currently-held references.
Signed-off-by: Jeff Layton <jlayton@kernel.org>
---
include/linux/ref_tracker.h | 3 +++
lib/ref_tracker.c | 15 +++++++++++++++
2 files changed, 18 insertions(+)
diff --git a/include/linux/ref_tracker.h b/include/linux/ref_tracker.h
index 8eac4f3d52547ccbaf9dcd09962ce80d26fbdff8..16fb6ec0cc7adc24457cfab13ee3994d85c15b39 100644
--- a/include/linux/ref_tracker.h
+++ b/include/linux/ref_tracker.h
@@ -22,6 +22,9 @@ struct ref_tracker_dir {
};
#ifdef CONFIG_REF_TRACKER
+#ifdef CONFIG_DEBUG_FS
+extern struct dentry *ref_tracker_debug_dir;
+#endif /* CONFIG_DEBUG_FS */
static inline void ref_tracker_dir_init(struct ref_tracker_dir *dir,
unsigned int quarantine_count,
diff --git a/lib/ref_tracker.c b/lib/ref_tracker.c
index cf5609b1ca79361763abe5a3a98484a3ee591ff2..136723eab6b17ae07132c659fd1d8b0690d8c2d9 100644
--- a/lib/ref_tracker.c
+++ b/lib/ref_tracker.c
@@ -12,6 +12,8 @@
#define REF_TRACKER_STACK_ENTRIES 16
#define STACK_BUF_SIZE 1024
+struct dentry *ref_tracker_debug_dir;
+
struct ref_tracker {
struct list_head head; /* anchor into dir->list or dir->quarantine */
bool dead;
@@ -273,3 +275,16 @@ int ref_tracker_free(struct ref_tracker_dir *dir,
return 0;
}
EXPORT_SYMBOL_GPL(ref_tracker_free);
+
+#ifdef CONFIG_DEBUG_FS
+#include <linux/debugfs.h>
+
+static int __init ref_tracker_debug_init(void)
+{
+ ref_tracker_debug_dir = debugfs_create_dir("ref_tracker", NULL);
+ if (IS_ERR(ref_tracker_debug_dir))
+ return PTR_ERR(ref_tracker_debug_dir);
+ return 0;
+}
+late_initcall(ref_tracker_debug_init);
+#endif /* CONFIG_DEBUG_FS */
--
2.49.0
next prev parent reply other threads:[~2025-04-08 13:36 UTC|newest]
Thread overview: 16+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-04-08 13:36 [PATCH v2 0/2] net: add debugfs files for showing netns refcount tracking info Jeff Layton
2025-04-08 13:36 ` Jeff Layton [this message]
2025-04-10 4:27 ` [PATCH v2 1/2] ref_tracker: add a top level debugfs directory for ref_tracker Kuniyuki Iwashima
2025-04-10 12:05 ` Andrew Lunn
2025-04-08 13:36 ` [PATCH v2 2/2] net: add debugfs files for showing netns refcount tracking info Jeff Layton
2025-04-10 4:24 ` Kuniyuki Iwashima
2025-04-10 12:36 ` Andrew Lunn
2025-04-10 13:08 ` Jeff Layton
2025-04-10 13:23 ` Jeff Layton
2025-04-10 14:12 ` Andrew Lunn
2025-04-10 14:41 ` Jeff Layton
2025-04-13 11:40 ` Jeff Layton
2025-04-13 19:32 ` Andrew Lunn
2025-04-14 12:20 ` Jeff Layton
2025-04-14 12:46 ` Andrew Lunn
2025-04-14 12:48 ` Jeff Layton
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=20250408-netns-debugfs-v2-1-ca267f51461e@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=linux-kernel@vger.kernel.org \
--cc=netdev@vger.kernel.org \
--cc=pabeni@redhat.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