tracing: Trigger a warning on build if a tracepoint is defined but unused
Get series with b4
b4 am [email protected]Versions newest first
- v1 Latest3 patches 5 repliesIn review
Patches in v1 No applies recorded yet
| # | Subject and files | Size | Replies | Applied |
|---|---|---|---|---|
| 1/3 | sorttable: Move ELF parsing into scripts/elf-parse.[ch]scripts/ scripts/ scripts/ +2 more | +542 | 2 replies | |
| 2/3 | tracing: Add a tracepoint verification check at build timeinclude/ include/ kernel/ +3 more | +260 | 0 replies | |
| 3/3 | tracepoint: Do not warn for unused event that is exportedinclude/ | +4 | 0 replies |
Reviews trailers per patch
No Reviewed-by, Acked-by or Tested-by trailers for v1 yet.
Cover letter [for-next][PATCH 0/3] tracing: Trigger a warning on build if a tracepoint is defined but unused
Stephen,
I plan on pushing this to my for-next branch, which will add this to the linux-next tree. When the kconfig option "TRACEPOINT_WARN_ON_UNUSED" is enabled, it will warn whenever a tracepoint is created but not used. This is similar to adding a static variable or function and not using it. This means that an allmodconfig and allyesconfig builds may start having warnings that will get bisected down to this commit. The bug is not this commit though, but whatever has created an event but never used it. As tracepoints can take up to 5K of memory, even when not used, this is a waste and should be fixed.
I hope that adding this to linux-next will start the push to clean up these unused tracepoints that are in the kernel, as well as prevent new ones from being added. Hopefully by the time the merge window rolls around, most of these will be cleaned up and this can be merged upstream without triggering warnings.
I built this against all archs in my tree (26 of them) with a allyesconfig. Unfortunately, only 10 build successfully with that (they all build successfully with defconfig and this option with tracing enabled). This detected 178 unique tracepoints that are defined and not used:
$ grep '^warning:' /work/autotest/cross-unused-traceevnts.log | sort -u |wc -l 178
Among them, 78 tracepoints were created and never referenced.
$ grep '^warning:' /work/autotest/cross-unused-traceevents.log | sort -u |cut -d"'" -f2 |
while read a ; do if ! git grep -q trace_$a ; then echo $a; fi ; done | wc -l
78The 100 remaining are likely in strange #ifdef CONFIG combinations where an allyesconfig defines the tracepoint but doesn't enable the code that uses them.
Expect even more warnings with different combos of config settings, as this will warn whenever a tracepoint is defined but not used.
-- Steve
git://git.kernel.org/pub/scm/linux/kernel/git/trace/linux-trace.git
unused-tracepoints/for-next
Head SHA1: d492e79ec6892ce1928a4c929ea29c0d5986e117
Steven Rostedt (3):
sorttable: Move ELF parsing into scripts/elf-parse.[ch]
tracing: Add a tracepoint verification check at build time
tracepoint: Do not warn for unused event that is exported
----
include/asm-generic/vmlinux.lds.h | 1 + include/linux/tracepoint.h | 12 + kernel/trace/Kconfig | 10 + scripts/Makefile | 6 + scripts/Makefile.vmlinux | 2 + scripts/elf-parse.c | 198 ++++++++++++++++ scripts/elf-parse.h | 305 ++++++++++++++++++++++++ scripts/link-vmlinux.sh | 4 + scripts/sorttable.c | 477 +++----------------------------------- scripts/tracepoint-update.c | 232 ++++++++++++++++++ 10 files changed, 804 insertions(+), 443 deletions(-) create mode 100644 scripts/elf-parse.c create mode 100644 scripts/elf-parse.h create mode 100644 scripts/tracepoint-update.c