Re: ref_tracker
Adrian Johnston <[email protected]> Mon, 7 Apr 2025 12:07:28 -0700
| Newsgroups | dev.linux.lists.kernelci |
|---|---|
| Message-ID | <CAMtebm+onFgWnwDjotybQOr5aWZFFZ+3=jhhA_RLgMDWst3rXw@mail.gmail.com> |
There was a LWN article that descrives it: https://lwn.net/Articles/877603/ That article claims that "A simple call to ref_tracker_dir_print() will cause the stack traces associated with any leaked references to be printed to the system log." From looking at the code: https://codebrowser.dev/linux/linux/lib/ref_tracker.c.html It seems that a double free will cause a printk(KERN_ERR...). If you have that as part of your debug build the it should just be a matter of checking the logs. This probably the most important class of bugs. Eric Dumazet <[email protected]> was the original author. The main questions I have about this tool is whether more changes would be required to capture ref-counts all across the kernel. I'm happy to follow up with him if you want me to get him involved. On Mon, Apr 7, 2025 at 6:27 AM Donald Zickus <[email protected]> wrote: > > Hi Adrian, > > On Fri, Apr 4, 2025 at 5:53 PM Adrian Johnston <[email protected]> wrote: >> >> Hello kernelci, >> >> I have exciting news. We have a reoccurring class of dangerous bugs in >> the kernel that could be identified during a CI run. >> >> The kernel comes with a reference count debugger called ref_tracker. >> And yet, every minor release of the kernel seems to fix another >> reference counting bug. Often kernel releases fix 3 or more. >> Meanwhile, the folks over on linux-debuggers aren't even sure anyone >> is using this reference counting debugger that often. >> >> Is anyone willing to flip the switch on this debugger on your staging >> machine? This seems like the kind of thing Linus should know about 20 >> minutes after merging a patch. >> >> https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/include/linux/ref_tracker.h >> https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=4e66934eaadc83b27ada8d42b60894018f3bfabf > > > It appears the Fedora / Red Hat kernels have it enabled in their debug kernels. We don't explicitly set it, it appears to be auto enabled by setting the 'DEBUG' config. Not sure if that is expected. > > How can a CI system take advantage of this? Is there a stack trace that shows up? Do we have to cat the output of a /sys or /proc file? > > Cheers, > Don > >> >> >> Thanks! >>