tracing: Add eventfs file to help with debugging any more issues
Steven Rostedt
maintainerLinus,
tracing: Add eventfs file to help with debugging any more issues
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.
Please pull the latest trace-v6.6-rc1-2 tree, which can be found at:
git://git.kernel.org/pub/scm/linux/kernel/git/trace/linux-trace.git
trace-v6.6-rc1-2
Tag SHA1: 48380652486eacb149420e083516fb159b475d13 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)
Quoted 6 lines · Steven Rostedt
tracing: Add eventfs file to help with debugging any more issues
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.
Honestly, this is neither a bug-fix, nor does it seem to make any sense at all in the main tree.
This really feels like a "temporary debug patch for tracing developers".
Linus
Steven Rostedt
maintainerQuoted 4 lines · On Fri, 15 Sep 2023 12:28:57 -0700 Linus Torvalds…
Quoted 3 lines · Steven Rostedt
tracing: Add eventfs file to help with debugging any more issues
Quoted 8 lines
Quoted 3 lines
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.
Honestly, this is neither a bug-fix, nor does it seem to make any sense at all in the main tree.
This really feels like a "temporary debug patch for tracing developers".
I wouldn't say its temporary, especially since it can be used to see what's happening internally.
I'm OK with it not going in now, but instead I'll wrap an ifdef around it and move it to my queue for the next merge window. I still would like to keep these "what's going on internally" available, as I'll ask people to enable them when they report an issue.
There's a few other files that do similar things that have been very useful for such cases.
-- Steve
Quoted 5 lines · Steven Rostedt
I'm OK with it not going in now, but instead I'll wrap an ifdef around it and move it to my queue for the next merge window. I still would like to keep these "what's going on internally" available, as I'll ask people to enable them when they report an issue.
Honestly, you copied the pattern from the /proc filesystem.
The /proc filesyustem is widely used and has never had this kind of random debugging code in mainline.
Seriously, that eventfs_file thing is not worthy of this kind of special debug code.
That debug code seems to be approaching the same order of size as all the code evetfs_file code itself is.
There's a point where this kind of stuff just becomes ridiculous. At least wait until there's a *reason* to debug a simple linked list of objects.
If you have a hard time figuring out what the eventfs entries are, maybe you should just have made "iterate_shared" show them, and then you could use fancy tools like "ls" to see what the heck is up in that directory?
Linus
Steven Rostedt
maintainerQuoted 8 lines · On Fri, 15 Sep 2023 13:50:17 -0700 Linus Torvalds…
Quoted 5 lines · Steven Rostedt
I'm OK with it not going in now, but instead I'll wrap an ifdef around it and move it to my queue for the next merge window. I still would like to keep these "what's going on internally" available, as I'll ask people to enable them when they report an issue.
Honestly, you copied the pattern from the /proc filesystem.
I didn't actually copy it, even though the /proc filesystem does something similar (I didn't even know that it did until I presented this idea for eventfs in LSFMM, and someone told me that /proc did so too).
I tried to look at how /proc does things and I couldn't really use it as easily, because proc uses its own set of "proc_ops", and I had some different requirements.
Quoted 3 lines
The /proc filesyustem is widely used and has never had this kind of random debugging code in mainline.
Again, it is implemented differently.
Quoted 6 lines
Seriously, that
eventfs_filething is not worthy of this kind of special debug code.That debug code seems to be approaching the same order of size as all the code
evetfs_filecode itself is.
You mean the event_show.c code?
Quoted 10 lines
There's a point where this kind of stuff just becomes ridiculous. At least wait until there's a *reason* to debug a simple linked list of objects.
If you have a hard time figuring out what the eventfs entries are, maybe you should just have made "
iterate_shared" show them, and then you could use fancy tools like "ls" to see what the heck is up in that directory?
I was more interested in what did not exist than what existed. I wanted to make sure that things were cleaned up properly. One of my tests that I used was to do a: find /sys/kernel/tracing/events, and then run my ring_buffer memory size stress test (that keeps increasing the size of the ring buffer to make sure it fails safely when it runs out of memory). Then I check to make sure all the unused dentries and inodes were reclaimed nicely, as they hang around until a reclaim is made.
It did prove useful for the initial debugging, but it also helped a lot for the new code I have saved for the next merge window. That code changes the internal interface quite drastically.
The current code has meta data for every file in the eventfs (defined by the eventfs_file structure). The new code has meta data only for the events themselves (which map to the directories) and I remove the eventfs_file entirely. It uses a callback from the eventfs code to create the dentries and inodes of the files on the fly (there's no meta data representing the individual files).
https://lore.kernel.org/linux-trace-kernel/[email protected]/
Now I use this debug file to know what files are added, and more importantly, not added.
Are you entirely against this file, or is it fine if it's just wrapped around an CONFIG_EVENTFS_DEBUG?
-- Steve
Quoted 3 lines · Steven Rostedt
Are you entirely against this file, or is it fine if it's just wrapped around an
CONFIG_EVENTFS_DEBUG?
Honestly, I think its' extra code that we'd carry around - probably for much too long - with absolutely _zero_ indication that it's actually worth it.
Not worth asking people about, but also not worth carrying around.
You worry about bugs in it now, because it's new code. That's normal. That doesn't make your debug interface worth any kind of future.
Keep it around as a private patch. Send it out to people if there are actual issues that might indicate this debug support would helkp. And if it has shown itself to be useful several times, at that point you have an argument for the code.
As it is, right now I look at that code and I see extra BS that we'll carry around forever that helps *zero* users, and I find it very questionable whether it would help you.
And if you really think that people need to know what the events exist in eventfs, then dammit, make 'readdir()' see them. Not some stupid specialty debug interface. That's what filesystems *have* readdir for.
Linus
Quoted 4 lines · Linus Torvalds
And if you really think that people need to know what the events exist in eventfs, then dammit, make '
readdir()' see them. Not some stupid specialty debug interface. That's what filesystems *have* readdir for.
.. alternatively, if you have noticed that it's just a pain to not be able to see the data, instead of introducing this completely separate and illogical debug interface, just say "ok, it was a mistake, let's go back to just keeping things in dentries since we can _see_ those".
Put another way: this is all self-inflicted damage, and you seem to argue for this debug interface purely on "I can't see what's going on any more, the old model was really nice because you could *see* the events".
To me, if that's really a major issue, that just says "ok, this eventfs abstraction was mis-designed, and hid data that the main developer actually wants".
We don't add new debug interfaces just because you screwed up the design. Fix it.
Linus
Steven Rostedt
maintainerQuoted 12 lines · On Fri, 15 Sep 2023 14:35:40 -0700 Linus Torvalds…
Quoted 4 lines · Linus Torvalds
And if you really think that people need to know what the events exist in eventfs, then dammit, make '
readdir()' see them. Not some stupid specialty debug interface. That's what filesystems *have* readdir for... alternatively, if you have noticed that it's just a pain to not be able to see the data, instead of introducing this completely separate and illogical debug interface, just say "ok, it was a mistake, let's go back to just keeping things in dentries since we can _see_ those".
Quoted 4 lines
Put another way: this is all self-inflicted damage, and you seem to argue for this debug interface purely on "I can't see what's going on any more, the old model was really nice because you could *see* the events".
The entire tracing infrastructure was created because of the "I can't see what's going on" ;-) Not everyone is as skilled with printk as you.
The old eventfs model was too costly because of the memory footprint, which was the entire objective of this code patch. The BPF folks told me they looked into use a tracing instance but said it added too much memory overhead to do so. That's when I noticed that the copy of the entire events directory that an instance has was the culprit, and needed to be fixed.
Quoted 7 lines
To me, if that's really a major issue, that just says "ok, this eventfs abstraction was mis-designed, and hid data that the main developer actually wants".
We don't add new debug interfaces just because you screwed up the design. Fix it.
This interface is used to make sure that things are being freed, and the overhead is low. The bugs it found was where ref counts were screwed up, and things were permanently there or just leaked in general.
Not sure what design you want fixed.
But I get your point. I will agree that this interface will likely be mostly useful for the first year or two after the new code is added. But after a few years, we could delete it too. If it's a debug option I highly doubt that any distro will keep it on and anything will actually depend on it.
I'm not going to fight for it. I can just keep this code in patchwork that could be easily available, or even in a git branch on my own tree.
Consider this pull request dropped.
-- Steve
Steven Rostedt
maintainerQuoted 3 lines · On Fri, 15 Sep 2023 18:01:18 -0400 Steven Rostedt <[email protected]> wrote:
Quoted 3 lines
To me, if that's really a major issue, that just says "ok, this eventfs abstraction was mis-designed, and hid data that the main developer actually wants".
Just to clarify the objective of the show_event_dentries file was the heisenberg effect.
Just doing a 'ls' in the eventfs will create the dentries.
I'm interested in knowing that the dentries do not exist before the 'ls', so I look at that file to make sure they are not there.
Then I do an 'ls' where I see all the files.
I then look at the file again to make sure the ref counts are correct.
I then run a memory pressure test, and look at the file to make sure that the dentries are all cleaned up.
For kicks I'll do another 'ls' and see all the files again.
You may be correct that once I did the above, the code could be considered working. My fear is that something might change in vfs that causes it to break, and this file could be useful in catching that.
But if it never breaks, then the file becomes useless, which I guess is what you are saying.
I'll keep the code around locally, and if vfs ever changes and breaks this code where this file helps in solving it, I'll then do another pull request to put this file upstream ;-)
-- Steve