perf: enable libtraceevent dynamic linking
PATCH 1/1 perf: enable libtraceevent dynamic linking
Currently we support only static linking with kernel's libtraceevent (tools/lib/traceevent). This patch adds libtraceevent package detection and support to link perf with it dynamically.
The libtraceevent package status is displayed with:
$ make VF=1 LIBTRACEEVENT_DYNAMIC=1 ... ... libtraceevent: [ on ]
Default behavior remains the same (static linking).
--- tools/build/Makefile.feature | 1 + tools/build/feature/Makefile | 4 ++++ tools/build/feature/test-libtraceevent.c | 12 ++++++++++++ tools/perf/Makefile.config | 9 +++++++++ tools/perf/Makefile.perf | 8 ++++++-- 5 files changed, 32 insertions(+), 2 deletions(-) create mode 100644 tools/build/feature/test-libtraceevent.c
tools/build/Makefile.feature +1 -0
@@ -52,6 +52,7 @@ FEATURE_TESTS_BASIC := \ libpython-version \ libslang \ libslang-include-subdir \ + libtraceevent \ libcrypto \ libunwind \ pthread-attr-setaffinity-np \
tools/build/feature/Makefile +4 -0
@@ -36,6 +36,7 @@ FILES= \ test-libpython-version.bin \ test-libslang.bin \ test-libslang-include-subdir.bin \ + test-libtraceevent.bin \ test-libcrypto.bin \ test-libunwind.bin \ test-libunwind-debug-frame.bin \
@@ -196,6 +197,9 @@ $(OUTPUT)test-libslang.bin: $(OUTPUT)test-libslang-include-subdir.bin: $(BUILD) -lslang +$(OUTPUT)test-libtraceevent.bin: + $(BUILD) -ltraceevent + $(OUTPUT)test-libcrypto.bin: $(BUILD) -lcrypto
tools/build/feature/test-libtraceevent.c new file +12 -0
@@ -0,0 +1,12 @@ +// SPDX-License-Identifier: GPL-2.0 +#include <traceevent/trace-seq.h> + +int main (void ) +{ +int rv =0 ; +struct trace_seq s; +trace_seq_init (&s); + rv += !(s.state ==TRACE_SEQ__GOOD ); +trace_seq_destroy (&s); +return rv; +}
tools/perf/Makefile.config +9 -0
@@ -1079,6 +1079,15 @@ ifdef LIBPFM4 endif endif +ifdef LIBTRACEEVENT_DYNAMIC + $(call feature_check,libtraceevent) + ifeq ($(feature-libtraceevent), 1) + EXTLIBS += -ltraceevent + else + dummy := $(error Error: No libtraceevent devel library found, please install libtraceevent-devel); + endif +endif + # Among the variables below, these: # perfexecdir # perf_include_dir
tools/perf/Makefile.perf +6 -2
@@ -128,6 +128,8 @@ include ../scripts/utilities.mak # # Define BUILD_BPF_SKEL to enable BPF skeletons # +# Define LIBTRACEEVENT_DYNAMIC to enable libtraceevent dynamic linking +# # As per kernel Makefile, avoid funny character set dependencies unexport LC_ALL
@@ -309,7 +311,6 @@ endif LIBTRACEEVENT = $(TE_PATH)libtraceevent.a export LIBTRACEEVENT - LIBTRACEEVENT_DYNAMIC_LIST = $(PLUGINS_PATH)libtraceevent-dynamic-list #
@@ -374,12 +375,15 @@ endif export PERL_PATH -PERFLIBS = $(LIBAPI) $(LIBTRACEEVENT) $(LIBSUBCMD) $(LIBPERF) +PERFLIBS = $(LIBAPI) $(LIBSUBCMD) $(LIBPERF) ifndef NO_LIBBPF ifndef LIBBPF_DYNAMIC PERFLIBS += $(LIBBPF) endif endif +ifndef LIBTRACEEVENT_DYNAMIC + PERFLIBS += $(LIBTRACEEVENT) +endif # We choose to avoid "if .. else if .. else .. endif endif" # because maintaining the nesting to match is a pain. If
Signature · 1 line
2.18.4
On Wed, Apr 28, 2021 at 11:20:23AM +0200, Michael Petlan wrote:
SNIP
Quoted 13 lines
unexport
LC_ALLtools/perf/Makefile.perf +0
-1@@ -309,7 +311,6 @@ endif LIBTRACEEVENT = $(TE_PATH)libtraceevent.a export LIBTRACEEVENT - LIBTRACEEVENT_DYNAMIC_LIST = $(PLUGINS_PATH)libtraceevent-dynamic-list #@@ -374,12 +375,15 @@ endif export PERL_PATH
tools/perf/Makefile.perf endif · line 386
Quoted 10 lines
tools/perf/Makefile.perf +4
-1-PERFLIBS = $(LIBAPI) $(LIBTRACEEVENT) $(LIBSUBCMD) $(LIBPERF) +PERFLIBS = $(LIBAPI) $(LIBSUBCMD) $(LIBPERF) ifndef NO_LIBBPF ifndef LIBBPF_DYNAMIC PERFLIBS += $(LIBBPF) endif endif +ifndef LIBTRACEEVENT_DYNAMIC + PERFLIBS += $(LIBTRACEEVENT) +endif
there's also install-traceevent-plugins target called during install, which should be skipped for LIBTRACEEVENT_DYNAMIC
jirka
Quoted 6 lines
tools/perf/Makefile.perf +0
-0# We choose to avoid "if .. else if .. else .. endif endif" # because maintaining the nesting to match is a pain. IfSignature · 1 line
2.18.4
Quoted 17 lines · Jiri Olsa
On Wed, Apr 28, 2021 at 11:20:23AM +0200, Michael Petlan wrote:
SNIP
Quoted 13 lines
unexport
LC_ALLtools/perf/Makefile.perf +0
-1@@ -309,7 +311,6 @@ endif LIBTRACEEVENT = $(TE_PATH)libtraceevent.a export LIBTRACEEVENT - LIBTRACEEVENT_DYNAMIC_LIST = $(PLUGINS_PATH)libtraceevent-dynamic-list #@@ -374,12 +375,15 @@ endif export PERL_PATH
Quoted 13 lines
tools/perf/Makefile.perf endif · line 386
Quoted 10 lines
tools/perf/Makefile.perf +4
-1-PERFLIBS = $(LIBAPI) $(LIBTRACEEVENT) $(LIBSUBCMD) $(LIBPERF) +PERFLIBS = $(LIBAPI) $(LIBSUBCMD) $(LIBPERF) ifndef NO_LIBBPF ifndef LIBBPF_DYNAMIC PERFLIBS += $(LIBBPF) endif endif +ifndef LIBTRACEEVENT_DYNAMIC + PERFLIBS += $(LIBTRACEEVENT) +endifthere's also install-traceevent-plugins target called during install, which should be skipped for
LIBTRACEEVENT_DYNAMIC
Oh, didn't notice that. Thanks.
However, it seems that's not all what we miss in the patch. Seems that libtraceevent-dynamic-list should be also taken from external libtraceevent, when linked dynamically, shouldn't it.
Quoted 10 lines
jirka
Quoted 6 lines
tools/perf/Makefile.perf +0
-0# We choose to avoid "if .. else if .. else .. endif endif" # because maintaining the nesting to match is a pain. IfSignature · 1 line
2.18.4
Arnaldo Carvalho de Melo
maintainerEm Fri, Apr 30, 2021 at 02:59:00PM +0200, Michael Petlan escreveu:
Quoted 32 lines · Jiri Olsa
Quoted 17 lines · Michael Petlan
SNIP
Quoted 13 lines
unexport
LC_ALLtools/perf/Makefile.perf +0
-1@@ -309,7 +311,6 @@ endif LIBTRACEEVENT = $(TE_PATH)libtraceevent.a export LIBTRACEEVENT - LIBTRACEEVENT_DYNAMIC_LIST = $(PLUGINS_PATH)libtraceevent-dynamic-list #@@ -374,12 +375,15 @@ endif export PERL_PATHQuoted 13 lines
tools/perf/Makefile.perf endif · line 386
Quoted 10 lines
tools/perf/Makefile.perf +4
-1-PERFLIBS = $(LIBAPI) $(LIBTRACEEVENT) $(LIBSUBCMD) $(LIBPERF) +PERFLIBS = $(LIBAPI) $(LIBSUBCMD) $(LIBPERF) ifndef NO_LIBBPF ifndef LIBBPF_DYNAMIC PERFLIBS += $(LIBBPF) endif endif +ifndef LIBTRACEEVENT_DYNAMIC + PERFLIBS += $(LIBTRACEEVENT) +endifthere's also install-traceevent-plugins target called during install, which should be skipped for
LIBTRACEEVENT_DYNAMIC
Quoted 6 lines
Oh, didn't notice that. Thanks.
However, it seems that's not all what we miss in the patch. Seems that libtraceevent-dynamic-list should be also taken from external libtraceevent, when linked dynamically, shouldn't it.
Please send patches on top of what you already sent, that I have already merged and sent upstream, since it is opt-in.
- Arnaldo
Quoted 35 lines · Arnaldo Carvalho de Melo
Em Fri, Apr 30, 2021 at 02:59:00PM +0200, Michael Petlan escreveu:
Quoted 34 lines · Jiri Olsa
Quoted 17 lines · Michael Petlan
SNIP
Quoted 13 lines
unexport
LC_ALLtools/perf/Makefile.perf +0
-1@@ -309,7 +311,6 @@ endif LIBTRACEEVENT = $(TE_PATH)libtraceevent.a export LIBTRACEEVENT - LIBTRACEEVENT_DYNAMIC_LIST = $(PLUGINS_PATH)libtraceevent-dynamic-list #@@ -374,12 +375,15 @@ endif export PERL_PATHQuoted 13 lines
tools/perf/Makefile.perf endif · line 386
Quoted 10 lines
tools/perf/Makefile.perf +4
-1-PERFLIBS = $(LIBAPI) $(LIBTRACEEVENT) $(LIBSUBCMD) $(LIBPERF) +PERFLIBS = $(LIBAPI) $(LIBSUBCMD) $(LIBPERF) ifndef NO_LIBBPF ifndef LIBBPF_DYNAMIC PERFLIBS += $(LIBBPF) endif endif +ifndef LIBTRACEEVENT_DYNAMIC + PERFLIBS += $(LIBTRACEEVENT) +endifthere's also install-traceevent-plugins target called during install, which should be skipped for
LIBTRACEEVENT_DYNAMICOh, didn't notice that. Thanks.
Quoted 7 lines
Quoted 4 lines
However, it seems that's not all what we miss in the patch. Seems that libtraceevent-dynamic-list should be also taken from external libtraceevent, when linked dynamically, shouldn't it.
Please send patches on top of what you already sent, that I have already merged and sent upstream, since it is opt-in.
OK, this is great. I can already use the patch downstream, and polish it later.
Thank you!
Quoted 4 lines
- Arnaldo