Skip to content

Commit 56b11a2

Browse files
captain5050acmel
authored andcommitted
perf bpf: Remove support for embedding clang for compiling BPF events (-e foo.c)
This never was in the default build for perf, is difficult to maintain as it uses clang/llvm internals so ditch it, keeping, for now, the external compilation of .c BPF into .o bytecode and its subsequent loading, that is also going to be removed, do it separately to help bisection and to properly document what is being removed and why. Committer notes: Extracted from a larger patch and removed some leftovers, namely deleting these now unused feature tests: tools/build/feature/test-clang.cpp tools/build/feature/test-cxx.cpp tools/build/feature/test-llvm-version.cpp tools/build/feature/test-llvm.cpp Testing the use of BPF events after applying this patch: To use the external clang/llvm toolchain to compile a .c event and then use libbpf to load it, to get the syscalls:sys_enter_open* tracepoints and read the filename pointer, putting it into the ring buffer right after the usual tracepoint payload for 'perf trace' to then print it: [root@quaco ~]# perf trace -e /home/acme/git/perf-tools-next/tools/perf/examples/bpf/augmented_raw_syscalls.c,open* --max-events=10 0.000 systemd-oomd/959 openat(dfd: CWD, filename: "/proc/meminfo", flags: RDONLY|CLOEXEC) = 12 0.083 abrt-dump-jour/1453 openat(dfd: CWD, filename: "/var/log/journal/d6a97235307247e09f13f326fb607e3c/system.journal", flags: RDONLY|CLOEXEC|NONBLOCK) = 4 0.063 abrt-dump-jour/1454 openat(dfd: CWD, filename: "/var/log/journal/d6a97235307247e09f13f326fb607e3c/system.journal", flags: RDONLY|CLOEXEC|NONBLOCK) = 4 0.082 abrt-dump-jour/1455 openat(dfd: CWD, filename: "/var/log/journal/d6a97235307247e09f13f326fb607e3c/system.journal", flags: RDONLY|CLOEXEC|NONBLOCK) = 4 250.124 systemd-oomd/959 openat(dfd: CWD, filename: "/proc/meminfo", flags: RDONLY|CLOEXEC) = 12 250.521 systemd-oomd/959 openat(dfd: CWD, filename: "/sys/fs/cgroup/user.slice/user-1000.slice/[email protected]/app.slice/memory.pressure", flags: RDONLY|CLOEXEC) = 12 251.047 systemd-oomd/959 openat(dfd: CWD, filename: "/sys/fs/cgroup/user.slice/user-1000.slice/[email protected]/app.slice/memory.current", flags: RDONLY|CLOEXEC) = 12 251.162 systemd-oomd/959 openat(dfd: CWD, filename: "/sys/fs/cgroup/user.slice/user-1000.slice/[email protected]/app.slice/memory.min", flags: RDONLY|CLOEXEC) = 12 251.242 systemd-oomd/959 openat(dfd: CWD, filename: "/sys/fs/cgroup/user.slice/user-1000.slice/[email protected]/app.slice/memory.low", flags: RDONLY|CLOEXEC) = 12 251.353 systemd-oomd/959 openat(dfd: CWD, filename: "/sys/fs/cgroup/user.slice/user-1000.slice/[email protected]/app.slice/memory.swap.current", flags: RDONLY|CLOEXEC) = 12 [root@quaco ~]# Same thing, but with a prebuilt .o BPF bytecode: [root@quaco ~]# perf trace -e /home/acme/git/perf-tools-next/tools/perf/examples/bpf/augmented_raw_syscalls.o,open* --max-events=10 0.000 systemd-oomd/959 openat(dfd: CWD, filename: "/proc/meminfo", flags: RDONLY|CLOEXEC) = 12 0.083 abrt-dump-jour/1453 openat(dfd: CWD, filename: "/var/log/journal/d6a97235307247e09f13f326fb607e3c/system.journal", flags: RDONLY|CLOEXEC|NONBLOCK) = 4 0.083 abrt-dump-jour/1455 openat(dfd: CWD, filename: "/var/log/journal/d6a97235307247e09f13f326fb607e3c/system.journal", flags: RDONLY|CLOEXEC|NONBLOCK) = 4 0.062 abrt-dump-jour/1454 openat(dfd: CWD, filename: "/var/log/journal/d6a97235307247e09f13f326fb607e3c/system.journal", flags: RDONLY|CLOEXEC|NONBLOCK) = 4 249.985 systemd-oomd/959 openat(dfd: CWD, filename: "/proc/meminfo", flags: RDONLY|CLOEXEC) = 12 466.763 thermald/1234 openat(dfd: CWD, filename: "/sys/class/powercap/intel-rapl/intel-rapl:0/intel-rapl:0:2/energy_uj") = 13 467.145 thermald/1234 openat(dfd: CWD, filename: "/sys/class/powercap/intel-rapl/intel-rapl:0/energy_uj") = 13 467.311 thermald/1234 openat(dfd: CWD, filename: "/sys/class/thermal/thermal_zone2/temp") = 13 500.040 cgroupify/24006 openat(dfd: 4, filename: ".", flags: RDONLY|CLOEXEC|DIRECTORY|NONBLOCK) = 5 500.295 cgroupify/24006 openat(dfd: 4, filename: "24616/cgroup.procs") = 5 [root@quaco ~]# Signed-off-by: Ian Rogers <[email protected]> Tested-by: Arnaldo Carvalho de Melo <[email protected]> Cc: Adrian Hunter <[email protected]> Cc: Alexander Shishkin <[email protected]> Cc: Andi Kleen <[email protected]> Cc: Andrii Nakryiko <[email protected]> Cc: Anshuman Khandual <[email protected]> Cc: Athira Rajeev <[email protected]> Cc: Brendan Gregg <[email protected]> Cc: Carsten Haitzler <[email protected]> Cc: Eduard Zingerman <[email protected]> Cc: Fangrui Song <[email protected]> Cc: He Kuang <[email protected]> Cc: Ingo Molnar <[email protected]> Cc: James Clark <[email protected]> Cc: Jiri Olsa <[email protected]> Cc: Kan Liang <[email protected]> Cc: Leo Yan <[email protected]> Cc: Madhavan Srinivasan <[email protected]> Cc: Mark Rutland <[email protected]> Cc: Namhyung Kim <[email protected]> Cc: Nathan Chancellor <[email protected]> Cc: "Naveen N. Rao" <[email protected]> Cc: Nick Desaulniers <[email protected]> Cc: Peter Zijlstra <[email protected]> Cc: Ravi Bangoria <[email protected]> Cc: Rob Herring <[email protected]> Cc: Tiezhu Yang <[email protected]> Cc: Tom Rix <[email protected]> Cc: Wang Nan <[email protected]> Cc: Wang ShaoBo <[email protected]> Cc: Yang Jihong <[email protected]> Cc: Yonghong Song <[email protected]> Cc: YueHaibing <[email protected]> Link: https://lore.kernel.org/lkml/[email protected] Signed-off-by: Arnaldo Carvalho de Melo <[email protected]>
1 parent 6f769c3 commit 56b11a2

File tree

17 files changed

+4
-533
lines changed

17 files changed

+4
-533
lines changed

tools/build/feature/test-clang.cpp

Lines changed: 0 additions & 28 deletions
This file was deleted.

tools/build/feature/test-cxx.cpp

Lines changed: 0 additions & 16 deletions
This file was deleted.

tools/build/feature/test-llvm-version.cpp

Lines changed: 0 additions & 12 deletions
This file was deleted.

tools/build/feature/test-llvm.cpp

Lines changed: 0 additions & 14 deletions
This file was deleted.

tools/perf/Makefile.config

Lines changed: 0 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -1127,37 +1127,6 @@ ifndef NO_JVMTI
11271127
endif
11281128
endif
11291129

1130-
USE_CXX = 0
1131-
USE_CLANGLLVM = 0
1132-
ifdef LIBCLANGLLVM
1133-
$(call feature_check,cxx)
1134-
ifneq ($(feature-cxx), 1)
1135-
msg := $(warning No g++ found, disable clang and llvm support. Please install g++)
1136-
else
1137-
$(call feature_check,llvm)
1138-
$(call feature_check,llvm-version)
1139-
ifneq ($(feature-llvm), 1)
1140-
msg := $(warning No suitable libLLVM found, disabling builtin clang and LLVM support. Please install llvm-dev(el) (>= 3.9.0))
1141-
else
1142-
$(call feature_check,clang)
1143-
ifneq ($(feature-clang), 1)
1144-
msg := $(warning No suitable libclang found, disabling builtin clang and LLVM support. Please install libclang-dev(el) (>= 3.9.0))
1145-
else
1146-
CFLAGS += -DHAVE_LIBCLANGLLVM_SUPPORT
1147-
CXXFLAGS += -DHAVE_LIBCLANGLLVM_SUPPORT -I$(shell $(LLVM_CONFIG) --includedir)
1148-
$(call detected,CONFIG_CXX)
1149-
$(call detected,CONFIG_CLANGLLVM)
1150-
USE_CXX = 1
1151-
USE_LLVM = 1
1152-
USE_CLANG = 1
1153-
ifneq ($(feature-llvm-version),1)
1154-
msg := $(warning This version of LLVM is not tested. May cause build errors)
1155-
endif
1156-
endif
1157-
endif
1158-
endif
1159-
endif
1160-
11611130
ifndef NO_LIBPFM4
11621131
$(call feature_check,libpfm4)
11631132
ifeq ($(feature-libpfm4), 1)

tools/perf/Makefile.perf

Lines changed: 0 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -99,10 +99,6 @@ include ../scripts/utilities.mak
9999
# Define NO_JVMTI_CMLR (debug only) if you do not want to process CMLR
100100
# data for java source lines.
101101
#
102-
# Define LIBCLANGLLVM if you DO want builtin clang and llvm support.
103-
# When selected, pass LLVM_CONFIG=/path/to/llvm-config to `make' if
104-
# llvm-config is not in $PATH.
105-
#
106102
# Define CORESIGHT if you DO WANT support for CoreSight trace decoding.
107103
#
108104
# Define NO_AIO if you do not want support of Posix AIO based trace
@@ -425,19 +421,6 @@ endif
425421
EXTLIBS := $(call filter-out,$(EXCLUDE_EXTLIBS),$(EXTLIBS))
426422
LIBS = -Wl,--whole-archive $(PERFLIBS) $(EXTRA_PERFLIBS) -Wl,--no-whole-archive -Wl,--start-group $(EXTLIBS) -Wl,--end-group
427423

428-
ifeq ($(USE_CLANG), 1)
429-
LIBS += -L$(shell $(LLVM_CONFIG) --libdir) -lclang-cpp
430-
endif
431-
432-
ifeq ($(USE_LLVM), 1)
433-
LIBLLVM = $(shell $(LLVM_CONFIG) --libs all) $(shell $(LLVM_CONFIG) --system-libs)
434-
LIBS += -L$(shell $(LLVM_CONFIG) --libdir) $(LIBLLVM)
435-
endif
436-
437-
ifeq ($(USE_CXX), 1)
438-
LIBS += -lstdc++
439-
endif
440-
441424
export INSTALL SHELL_PATH
442425

443426
### Build rules

tools/perf/tests/Build

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,6 @@ perf-y += sdt.o
5151
perf-y += is_printable_array.o
5252
perf-y += bitmap.o
5353
perf-y += perf-hooks.o
54-
perf-y += clang.o
5554
perf-y += unit_number__scnprintf.o
5655
perf-y += mem2node.o
5756
perf-y += maps.o

tools/perf/tests/builtin-test.c

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,6 @@ static struct test_suite *generic_tests[] = {
108108
&suite__is_printable_array,
109109
&suite__bitmap_print,
110110
&suite__perf_hooks,
111-
&suite__clang,
112111
&suite__unit_number__scnprint,
113112
&suite__mem2node,
114113
&suite__time_utils,

tools/perf/tests/clang.c

Lines changed: 0 additions & 32 deletions
This file was deleted.

tools/perf/tests/make

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,6 @@ make_with_babeltrace:= LIBBABELTRACE=1
9595
make_with_coresight := CORESIGHT=1
9696
make_no_sdt := NO_SDT=1
9797
make_no_syscall_tbl := NO_SYSCALL_TABLE=1
98-
make_with_clangllvm := LIBCLANGLLVM=1
9998
make_no_libpfm4 := NO_LIBPFM4=1
10099
make_with_gtk2 := GTK2=1
101100
make_refcnt_check := EXTRA_CFLAGS="-DREFCNT_CHECKING=1"

0 commit comments

Comments
 (0)