Re: [PATCH 0/2] perf trace: Fix support for the new BPF feature in clang 12

From: James Clark
Date: Thu Oct 10 2024 - 05:08:44 EST




On 07/10/2024 6:14 am, Howard Chu wrote:
The new augmentation feature in perf trace, along with the protocol
change (from payload to payload->value), breaks the clang 12 build.

perf trace actually builds for any clang version newer than clang 16.
However, as pointed out by Namhyung Kim <namhyung@xxxxxxxxxx> and Ian
Rogers <irogers@xxxxxxxxxx>, clang 16, which was released in 2023, is
still too new for most users. Additionally, as James Clark
<james.clark@xxxxxxxxxx> noted, some commonly used distributions do not
yet support clang 16. Therefore, breaking BPF features between clang 12
and clang 15 is not a good approach.

This patch series rewrites the BPF program in a way that allows it to
pass the BPF verifier, even when the BPF bytecode is generated by older
versions of clang.

However, I have only tested it till clang 14, as older versions are not
supported by my distribution.

Howard Chu (2):
perf build: Change the clang check back to 12.0.1
perf trace: Rewrite BPF code to pass the verifier

tools/perf/Makefile.config | 4 +-
.../bpf_skel/augmented_raw_syscalls.bpf.c | 117 ++++++++++--------
2 files changed, 65 insertions(+), 56 deletions(-)


Tested with clang 15:

$ sudo perf trace -e write --max-events=100 -- echo hello
0.000 ( 0.014 ms): echo/834165 write(fd: 1, buf: hello\10, count: 6)
=

Tested-by: James Clark <james.clark@xxxxxxxxxx>