Skip to content

Commit a980755

Browse files
captain5050acmel
authored andcommitted
perf build: Make BUILD_BPF_SKEL default, rename to NO_BPF_SKEL
BPF skeleton support is now key to a number of perf features. Rather than making it so that BPF support must be enabled for the build, make this the default and error if the build lacks a clang and libbpf that are sufficient. To avoid the error and build without BPF skeletons the NO_BPF_SKEL=1 flag can be used. Add a build-options flag to 'perf version' to enable detection of the BPF skeleton support and use this in the offcpu shell test. Signed-off-by: Ian Rogers <irogers@google.com> Cc: Adrian Hunter <adrian.hunter@intel.com> Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com> Cc: Andres Freund <andres@anarazel.de> Cc: Ingo Molnar <mingo@redhat.com> Cc: Jiri Olsa <jolsa@kernel.org> Cc: Leo Yan <leo.yan@linaro.org> Cc: Mark Rutland <mark.rutland@arm.com> Cc: Martin Liška <mliska@suse.cz> Cc: Namhyung Kim <namhyung@kernel.org> Cc: Nathan Chancellor <nathan@kernel.org> Cc: Nick Desaulniers <ndesaulniers@google.com> Cc: Pavithra Gurushankar <gpavithrasha@gmail.com> Cc: Peter Zijlstra <peterz@infradead.org> Cc: Quentin Monnet <quentin@isovalent.com> Cc: Roberto Sassu <roberto.sassu@huawei.com> Cc: Stephane Eranian <eranian@google.com> Cc: Tiezhu Yang <yangtiezhu@loongson.cn> Cc: Tom Rix <trix@redhat.com> Cc: Yang Jihong <yangjihong1@huawei.com> Cc: llvm@lists.linux.dev Link: https://lore.kernel.org/r/20230311065753.3012826-2-irogers@google.com Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
1 parent 7a9b223 commit a980755

File tree

6 files changed

+20
-14
lines changed

6 files changed

+20
-14
lines changed

tools/perf/Makefile.config

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -415,6 +415,7 @@ ifdef NO_LIBELF
415415
NO_LIBUNWIND := 1
416416
NO_LIBDW_DWARF_UNWIND := 1
417417
NO_LIBBPF := 1
418+
NO_BPF_SKEL := 1
418419
NO_JVMTI := 1
419420
else
420421
ifeq ($(feature-libelf), 0)
@@ -662,18 +663,22 @@ ifndef NO_LIBBPF
662663
msg := $(warning BPF API too old. Please install recent kernel headers. BPF support in 'perf record' is disabled.)
663664
NO_LIBBPF := 1
664665
endif
666+
else
667+
NO_BPF_SKEL := 1
665668
endif
666669

667-
ifdef BUILD_BPF_SKEL
670+
ifndef NO_BPF_SKEL
668671
$(call feature_check,clang-bpf-co-re)
669672
ifeq ($(feature-clang-bpf-co-re), 0)
670-
dummy := $(error Error: clang too old/not installed. Please install recent clang to build with BUILD_BPF_SKEL)
671-
endif
672-
ifeq ($(filter -DHAVE_LIBBPF_SUPPORT, $(CFLAGS)),)
673-
dummy := $(error Error: BPF skeleton support requires libbpf)
673+
dummy := $(error: ERROR: BPF skeletons unsupported. clang too old/not installed or build with NO_BPF_SKEL=1.)
674+
else
675+
ifeq ($(filter -DHAVE_LIBBPF_SUPPORT, $(CFLAGS)),)
676+
dummy := $(error: ERROR: BPF skeletons unsupported. BPF skeleton support requires libbpf or build with NO_BPF_SKEL=1.)
677+
else
678+
$(call detected,CONFIG_PERF_BPF_SKEL)
679+
CFLAGS += -DHAVE_BPF_SKEL
680+
endif
674681
endif
675-
$(call detected,CONFIG_PERF_BPF_SKEL)
676-
CFLAGS += -DHAVE_BPF_SKEL
677682
endif
678683

679684
dwarf-post-unwind := 1

tools/perf/Makefile.perf

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -126,7 +126,7 @@ include ../scripts/utilities.mak
126126
#
127127
# Define NO_LIBDEBUGINFOD if you do not want support debuginfod
128128
#
129-
# Define BUILD_BPF_SKEL to enable BPF skeletons
129+
# Define NO_BPF_SKEL to disable BPF skeletons
130130
#
131131

132132
# As per kernel Makefile, avoid funny character set dependencies
@@ -1055,7 +1055,7 @@ SKELETONS += $(SKEL_OUT)/kwork_trace.skel.h
10551055
$(SKEL_TMP_OUT) $(LIBAPI_OUTPUT) $(LIBBPF_OUTPUT) $(LIBPERF_OUTPUT) $(LIBSUBCMD_OUTPUT) $(LIBSYMBOL_OUTPUT):
10561056
$(Q)$(MKDIR) -p $@
10571057

1058-
ifdef BUILD_BPF_SKEL
1058+
ifndef NO_BPF_SKEL
10591059
BPFTOOL := $(SKEL_TMP_OUT)/bootstrap/bpftool
10601060
BPF_INCLUDE := -I$(SKEL_TMP_OUT)/.. -I$(LIBBPF_INCLUDE)
10611061

@@ -1088,11 +1088,11 @@ bpf-skel: $(SKELETONS)
10881088

10891089
.PRECIOUS: $(SKEL_TMP_OUT)/%.bpf.o
10901090

1091-
else # BUILD_BPF_SKEL
1091+
else # NO_BPF_SKEL
10921092

10931093
bpf-skel:
10941094

1095-
endif # BUILD_BPF_SKEL
1095+
endif # NO_BPF_SKEL
10961096

10971097
bpf-skel-clean:
10981098
$(call QUIET_CLEAN, bpf-skel) $(RM) -r $(SKEL_TMP_OUT) $(SKELETONS)

tools/perf/builtin-lock.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2371,7 +2371,7 @@ int cmd_lock(int argc, const char **argv)
23712371

23722372
#ifndef HAVE_BPF_SKEL
23732373
set_option_nobuild(contention_options, 'b', "use-bpf",
2374-
"no BUILD_BPF_SKEL=1", false);
2374+
"NO_BPF_SKEL=1", false);
23752375
#endif
23762376
if (argc) {
23772377
argc = parse_options(argc, argv, contention_options,

tools/perf/builtin-record.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3971,7 +3971,7 @@ int cmd_record(int argc, const char **argv)
39713971

39723972
#ifndef HAVE_BPF_SKEL
39733973
# define set_nobuild(s, l, m, c) set_option_nobuild(record_options, s, l, m, c)
3974-
set_nobuild('\0', "off-cpu", "no BUILD_BPF_SKEL=1", true);
3974+
set_nobuild('\0', "off-cpu", "NO_BPF_SKEL=1", true);
39753975
# undef set_nobuild
39763976
#endif
39773977

tools/perf/builtin-version.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,7 @@ static void library_status(void)
8383
STATUS(HAVE_ZSTD_SUPPORT, zstd);
8484
STATUS(HAVE_LIBPFM, libpfm4);
8585
STATUS(HAVE_LIBTRACEEVENT, libtraceevent);
86+
STATUS(HAVE_BPF_SKEL, BPF skeletons);
8687
}
8788

8889
int cmd_version(int argc, const char **argv)

tools/perf/tests/shell/record_offcpu.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ test_offcpu_priv() {
2828
err=2
2929
return
3030
fi
31-
if perf record --off-cpu -o /dev/null --quiet true 2>&1 | grep BUILD_BPF_SKEL
31+
if perf version --build-options 2>&1 | grep HAVE_BPF_SKEL | grep -q OFF
3232
then
3333
echo "off-cpu test [Skipped missing BPF support]"
3434
err=2

0 commit comments

Comments
 (0)