* [PATCH v2 2/2] perf build: compile BPF skeletons with -mcpu=v3
@ 2026-05-30 19:55 Suchit Karunakaran
2026-05-30 22:39 ` Ian Rogers
0 siblings, 1 reply; 3+ messages in thread
From: Suchit Karunakaran @ 2026-05-30 19:55 UTC (permalink / raw)
To: peterz, mingo, acme, namhyung, mark.rutland, alexander.shishkin,
jolsa, irogers, adrian.hunter, james.clark
Cc: linux-perf-users, linux-kernel, bpf, Suchit Karunakaran
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.
Signed-off-by: Suchit Karunakaran <suchitkarunakaran@gmail.com>
Changes since v1:
- Moved the -mcpu=v3 addition from tools/perf/Makefile.perf to
tools/perf/bpf_skel.mak, following the refactoring of BPF skeleton
build logic into that file.
---
tools/perf/bpf_skel.mak | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/tools/perf/bpf_skel.mak b/tools/perf/bpf_skel.mak
index 7704e7e635d8..f2559de39f96 100644
--- a/tools/perf/bpf_skel.mak
+++ b/tools/perf/bpf_skel.mak
@@ -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)
--
2.54.0
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH v2 2/2] perf build: compile BPF skeletons with -mcpu=v3
2026-05-30 19:55 [PATCH v2 2/2] perf build: compile BPF skeletons with -mcpu=v3 Suchit Karunakaran
@ 2026-05-30 22:39 ` Ian Rogers
2026-06-04 13:34 ` Arnaldo Carvalho de Melo
0 siblings, 1 reply; 3+ messages in thread
From: Ian Rogers @ 2026-05-30 22:39 UTC (permalink / raw)
To: Suchit Karunakaran
Cc: peterz, mingo, acme, namhyung, mark.rutland, alexander.shishkin,
jolsa, adrian.hunter, james.clark, linux-perf-users, linux-kernel,
bpf
On Sat, May 30, 2026 at 12:55 PM Suchit Karunakaran
<suchitkarunakaran@gmail.com> wrote:
>
> 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.
>
> Signed-off-by: Suchit Karunakaran <suchitkarunakaran@gmail.com>
Acked-by: Ian Rogers <irogers@google.com>
Thanks,
Ian
> Changes since v1:
> - Moved the -mcpu=v3 addition from tools/perf/Makefile.perf to
> tools/perf/bpf_skel.mak, following the refactoring of BPF skeleton
> build logic into that file.
> ---
> tools/perf/bpf_skel.mak | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/tools/perf/bpf_skel.mak b/tools/perf/bpf_skel.mak
> index 7704e7e635d8..f2559de39f96 100644
> --- a/tools/perf/bpf_skel.mak
> +++ b/tools/perf/bpf_skel.mak
> @@ -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)
> --
> 2.54.0
>
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH v2 2/2] perf build: compile BPF skeletons with -mcpu=v3
2026-05-30 22:39 ` Ian Rogers
@ 2026-06-04 13:34 ` Arnaldo Carvalho de Melo
0 siblings, 0 replies; 3+ messages in thread
From: Arnaldo Carvalho de Melo @ 2026-06-04 13:34 UTC (permalink / raw)
To: Ian Rogers
Cc: Suchit Karunakaran, peterz, mingo, namhyung, mark.rutland,
alexander.shishkin, jolsa, adrian.hunter, james.clark,
linux-perf-users, linux-kernel, bpf
On Sat, May 30, 2026 at 03:39:32PM -0700, Ian Rogers wrote:
> On Sat, May 30, 2026 at 12:55 PM Suchit Karunakaran
> <suchitkarunakaran@gmail.com> wrote:
> >
> > 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.
> >
> > Signed-off-by: Suchit Karunakaran <suchitkarunakaran@gmail.com>
>
> Acked-by: Ian Rogers <irogers@google.com>
Thanks, applied to perf-tools-next, for v7.2.
- Arnaldo
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2026-06-04 13:35 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-05-30 19:55 [PATCH v2 2/2] perf build: compile BPF skeletons with -mcpu=v3 Suchit Karunakaran
2026-05-30 22:39 ` Ian Rogers
2026-06-04 13:34 ` Arnaldo Carvalho de Melo
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox