| Message ID | 20250625-perf_libtraceevent-v1-1-0bf7620bc6c9@bootlin.com |
|---|---|
| State | New |
| Headers | show |
| Series | package/linux-tools: perf: build with libtraceevent support when it is selected | expand |
Hi Alexis, On Wed, 25 Jun 2025 22:54:01 +0200 Alexis Lothoré <alexis.lothore@bootlin.com> wrote: > When trying to perform a custom uprobe recording on a target with perf > built by buildroot, the recording step fails as perf can not record > uprobes without libtraceevent support: > > $ perf probe -x linked_list insert_name index > Target program is compiled without optimization. Skipping prologue. > Probe on address 0x808 to force probing at the function entry. > > Added new event: > probe_linked_list:insert_name (on insert_name in /root/gdb/linked_list with index) > > perf is not linked with libtraceevent, to use the new probe you can use tracefs: > > cd /sys/kernel/tracing/ > echo 1 > events/probe_linked_list/insert_name/enable > echo 1 > tracing_on > cat trace_pipe > Before removing the probe, echo 0 > events/probe_linked_list/insert_name/enable > $ perf record -e probe_linked_list:insert_name ./linked_list > event syntax error: 'probe_linked_list:insert_name' > \___ unsupported tracepoint > > libtraceevent is necessary for tracepoint support > Run 'perf list' for a list of valid events > > Usage: perf record [<options>] [<command>] > or: perf record [<options>] -- <command> [<options>] > > -e, --event <event> event selector. use 'perf list' to list available events > > libtraceevent support for perf has been disabled with commit > b4ab45a5c1db ("package/linux-tools: disable libtracevent detection") > because there was no libtraceevent package in buildroot to replace the > former libtraceevent removed from the kernel sources. Since then, commit > 1474f1b34b17 ("package/libtraceevent: new package") has introduced a > libtraceevent package. We can then expose again the possibility to build > perf with libtraceevent support. > > Make buildroot perf makefile detect if libtraceevent package has been > enabled, and if so, allow to build perf with libtraceevent support. > > Signed-off-by: Alexis Lothoré <alexis.lothore@bootlin.com> > --- > To: buildroot@buildroot.org > Cc: Thomas Petazzoni <thomas.petazzoni@bootlin.com> > Cc: Luca Ceresoli <luca.ceresoli@bootlin.com> > Cc: Olivier Benjamin <olivier.benjamin@bootlin.com> > --- > It is worth noting that there is a bug in perf makefile kernel that > affects many kernel versions (up to 6.10) and that prevents perf from > building correctly when enabling libtraceevent support (see 440cf77625e3 > ("perf: build: Setup PKG_CONFIG_LIBDIR for cross compilation") in > linux). Thanks for the research! And apparently the mentioned commit was applied in 6.11 and not backported to 6.10 and previous stable releases. Shouldn't it be backported? This looks like a fix, doesn't it? > Should the libtraceevent then be explicitely enabled by the > user, rather than automatically enabling it when libtraceevent package > is selected ? Should the fix be backported to the currently-supported stable kernel versions, I'd say we can automatically enable libtraceevent support. Otherwise I'm not sure... Mentioning the issue and pointing to the fix commit in the Kconfig help text is another option. Luca
Hi Luca, >> It is worth noting that there is a bug in perf makefile kernel that >> affects many kernel versions (up to 6.10) and that prevents perf from >> building correctly when enabling libtraceevent support (see 440cf77625e3 >> ("perf: build: Setup PKG_CONFIG_LIBDIR for cross compilation") in >> linux). > > Thanks for the research! > > And apparently the mentioned commit was applied in 6.11 and not > backported to 6.10 and previous stable releases Yes, you are right, my mistake. > Shouldn't it be backported? This looks like a fix, doesn't it? Indeed. The original author on kernel side did not bring any Fixes tag so it may have slipped through the stable kernels, but I can try to submit it for current stable/LTS kernels. >> Should the libtraceevent then be explicitely enabled by the >> user, rather than automatically enabling it when libtraceevent package >> is selected ? > > Should the fix be backported to the currently-supported stable kernel > versions, I'd say we can automatically enable libtraceevent support. > Otherwise I'm not sure... Mentioning the issue and pointing to the fix > commit in the Kconfig help text is another option. Mentioning the kernel version fixing the issue in the KConfig help sounds relevant, but maybe having the exact kernel commit only in the BR commit description is enough ? If so, I can prepare a v2 with the updated Kconfig. Thanks Alexis
diff --git a/package/linux-tools/linux-tool-perf.mk.in b/package/linux-tools/linux-tool-perf.mk.in index d67318571aa4deefde5b38effe1ade0b87f4627b..1e19ee7f1c4e46d210c079d796f9461f2bfaae08 100644 --- a/package/linux-tools/linux-tool-perf.mk.in +++ b/package/linux-tools/linux-tool-perf.mk.in @@ -28,7 +28,6 @@ PERF_MAKE_FLAGS = \ NO_LIBPERL=1 \ NO_LIBPYTHON=1 \ NO_LIBBIONIC=1 \ - NO_LIBTRACEEVENT=1 \ NO_SHELLCHECK=1 # We need to pass an argument to ld for setting the emulation when @@ -128,6 +127,12 @@ PERF_MAKE_FLAGS += CORESIGHT=1 # bare "ifdef CORESIGHT" constructs. endif +ifeq ($(BR2_PACKAGE_LIBTRACEEVENT),y) +PERF_DEPENDENCIES += libtraceevent +else +PERF_MAKE_FLAGS += NO_LIBTRACEEVENT=1 +endif + # We really do not want to build the perf documentation, because it # has stringent requirement on the documentation generation tools, # like xmlto and asciidoc), which may be lagging behind on some
When trying to perform a custom uprobe recording on a target with perf built by buildroot, the recording step fails as perf can not record uprobes without libtraceevent support: $ perf probe -x linked_list insert_name index Target program is compiled without optimization. Skipping prologue. Probe on address 0x808 to force probing at the function entry. Added new event: probe_linked_list:insert_name (on insert_name in /root/gdb/linked_list with index) perf is not linked with libtraceevent, to use the new probe you can use tracefs: cd /sys/kernel/tracing/ echo 1 > events/probe_linked_list/insert_name/enable echo 1 > tracing_on cat trace_pipe Before removing the probe, echo 0 > events/probe_linked_list/insert_name/enable $ perf record -e probe_linked_list:insert_name ./linked_list event syntax error: 'probe_linked_list:insert_name' \___ unsupported tracepoint libtraceevent is necessary for tracepoint support Run 'perf list' for a list of valid events Usage: perf record [<options>] [<command>] or: perf record [<options>] -- <command> [<options>] -e, --event <event> event selector. use 'perf list' to list available events libtraceevent support for perf has been disabled with commit b4ab45a5c1db ("package/linux-tools: disable libtracevent detection") because there was no libtraceevent package in buildroot to replace the former libtraceevent removed from the kernel sources. Since then, commit 1474f1b34b17 ("package/libtraceevent: new package") has introduced a libtraceevent package. We can then expose again the possibility to build perf with libtraceevent support. Make buildroot perf makefile detect if libtraceevent package has been enabled, and if so, allow to build perf with libtraceevent support. Signed-off-by: Alexis Lothoré <alexis.lothore@bootlin.com> --- To: buildroot@buildroot.org Cc: Thomas Petazzoni <thomas.petazzoni@bootlin.com> Cc: Luca Ceresoli <luca.ceresoli@bootlin.com> Cc: Olivier Benjamin <olivier.benjamin@bootlin.com> --- It is worth noting that there is a bug in perf makefile kernel that affects many kernel versions (up to 6.10) and that prevents perf from building correctly when enabling libtraceevent support (see 440cf77625e3 ("perf: build: Setup PKG_CONFIG_LIBDIR for cross compilation") in linux). Should the libtraceevent then be explicitely enabled by the user, rather than automatically enabling it when libtraceevent package is selected ? --- package/linux-tools/linux-tool-perf.mk.in | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) --- base-commit: f28f34e200bbadf0aea32110c72f7199e65fb0b9 change-id: 20250625-perf_libtraceevent-17e46ee28f90 Best regards,