]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
perf build: Compile BPF skeletons with -mcpu=v3
authorSuchit Karunakaran <suchitkarunakaran@gmail.com>
Sat, 30 May 2026 19:55:10 +0000 (01:25 +0530)
committerArnaldo Carvalho de Melo <acme@redhat.com>
Thu, 4 Jun 2026 13:58:32 +0000 (10:58 -0300)
The lock_contention BPF program uses __sync_val_compare_and_swap() to
atomically update the max_time and min_time fields in contention_data.

This builtin lowers to the BPF_CMPXCHG instruction, which is only
available in BPF ISA v3. Without an explicit -mcpu flag, Clang targets
BPF v1/v2 by default on older toolchains (Clang < 18), causing build
errors when v3 instructions are emitted.

Add -mcpu=v3 to CLANG_OPTIONS, which is used exclusively in the BPF
skeleton compilation rule.

Reviewed-by: Namhyung Kim <namhyung@kernel.org>
Signed-off-by: Suchit Karunakaran <suchitkarunakaran@gmail.com>
Acked-by: Ian Rogers <irogers@google.com>
Cc: Adrian Hunter <adrian.hunter@intel.com>
Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
Cc: Ingo Molnar <mingo@redhat.com>
Cc: James Clark <james.clark@linaro.org>
Cc: Jiri Olsa <jolsa@kernel.org>
Cc: Mark Rutland <mark.rutland@arm.com>
Cc: Namhyung Kim <namhyung@kernel.org>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Suchit Karunakaran <suchitkarunakaran@gmail.com>
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
tools/perf/bpf_skel.mak

index 7704e7e635d8e6181f83e4548c1550c9f6faecea..f2559de39f96606fdd5ca0c8de53389d2fc4ff68 100644 (file)
@@ -29,7 +29,7 @@ ifneq ($(CROSS_COMPILE),)
 CLANG_TARGET_ARCH = --target=$(notdir $(CROSS_COMPILE:%-=%))
 endif
 
-CLANG_OPTIONS = -Wall
+CLANG_OPTIONS = -Wall -mcpu=v3
 CLANG_SYS_INCLUDES = $(call get_sys_includes,$(CLANG),$(CLANG_TARGET_ARCH))
 LIBBPF_INCLUDE := $(abspath $(or $(OUTPUT),.))/libbpf/include
 BPF_INCLUDE := -I$(SKEL_TMP_OUT)/.. -I$(SKEL_TOOL_OUT) -I$(LIBBPF_INCLUDE) $(CLANG_SYS_INCLUDES)