tracefs: Add show_events_dentries
Steven Rostedt
maintainerPATCH 1/1 tracefs: Add show_events_dentries
While debugging the eventfs dynamic file creation issues, creating a file in tracefs that exposed what dentries that were created along with their ref counts proved invaluable.
git://git.kernel.org/pub/scm/linux/kernel/git/trace/linux-trace.git
trace/urgent
Head SHA1: d6f358d6fff619cebbc547f2bdd3ec66ade04954
Steven Rostedt (Google) (1):
tracefs: Add show_events_dentries
----
fs/tracefs/Makefile | 1 + fs/tracefs/event_inode.c | 42 +------------ fs/tracefs/event_show.c | 147 ++++++++++++++++++++++++++++++++++++++++++++ fs/tracefs/internal.h | 44 +++++++++++++ include/linux/tracefs.h | 2 + kernel/trace/trace_events.c | 3 + 6 files changed, 198 insertions(+), 41 deletions(-) create mode 100644 fs/tracefs/event_show.c --------------------------- commit d6f358d6fff619cebbc547f2bdd3ec66ade04954 Author: Steven Rostedt (Google) <[email protected]> Date: Wed Sep 13 11:36:28 2023 -0400
tracefs: Add show_events_dentries
Add a file in tracefs that shows the "events" allocated entries and the dentries that are attached to them. This is used to see what dentries have been dynamically allocated as well as their current ref counts.
~# cat /sys/kernel/tracing/events/sched/sched_switch/enable 0
~# grep -A4 sched_switch /sys/kernel/tracing/show_events_dentries sched_switch/ dentry: (1)
enable dentry: (0)
id
filter
trigger
The first value is the name of the file or directory. If a dentry is allocated, then a "dentry: (<ref-count>)" is displayed showing the address of the dentry as well as its ref count.
fs/tracefs/Makefile +1 -0
@@ -1,6 +1,7 @@ # SPDX-License-Identifier: GPL-2.0-only tracefs-objs := inode.o tracefs-objs += event_inode.o +tracefs-objs += event_show.o obj-$(CONFIG_TRACING) += tracefs.o
fs/tracefs/event_inode.c +1 -41
48 lines not on this page · raw message
fs/tracefs/event_show.c new file +147 -0
147 lines not on this page · raw message
fs/tracefs/internal.h +44 -0
55 lines not on this page · raw message
include/linux/tracefs.h +2 -0
@@ -58,6 +58,8 @@ struct dentry *tracefs_create_instance_dir(const char *name, struct dentry *parebool tracefs_initialized (void ); +extern const struct file_operations eventfs_show_dentry_fops; +#endif /* CONFIG_TRACING */ #endif
kernel/trace/trace_events.c +3 -0
@@ -3639,6 +3639,9 @@ create_event_toplevel_files(struct dentry *parent, struct trace_array *tr)return -ENOMEM ; } +trace_create_file ("show_events_dentries" ,TRACE_MODE_READ , parent, d_events, + &eventfs_show_dentry_fops); + error =eventfs_add_events_file ("enable" ,TRACE_MODE_WRITE , d_events, tr, &ftrace_tr_enable_fops);if (error)