Re: [PATCH 2/8] perf bpf filter: Implement event sample filtering

From: Namhyung Kim
Date: Sun Feb 19 2023 - 11:49:06 EST


On Sun, Feb 19, 2023 at 3:14 AM Arnaldo Carvalho de Melo
<acme@xxxxxxxxxx> wrote:
>
> Em Sat, Feb 18, 2023 at 10:13:23PM -0800, Namhyung Kim escreveu:
> > The BPF program will be attached to a perf_event and be triggered when
> > it overflows. It'd iterate the filters map and compare the sample
> > value according to the expression. If any of them fails, the sample
> > would be dropped.
> >
> > Also it needs to have the corresponding sample data for the expression
> > so it compares data->sample_flags with the given value. To access the
> > sample data, it uses the bpf_cast_to_kern_ctx() kfunc which was added
> > in v6.2 kernel.
>
> CLANG /tmp/build/perf/util/bpf_skel/.tmp/sample_filter.bpf.o
> util/bpf_skel/sample_filter.bpf.c:26:19: error: no member named 'sample_flags' in 'struct perf_sample_data'
> if ((kctx->data->sample_flags & entry->flags) == 0)
> ~~~~~~~~~~ ^
> 1 error generated.
> make[2]: *** [Makefile.perf:1078: /tmp/build/perf/util/bpf_skel/.tmp/sample_filter.bpf.o] Error 1
> make[1]: *** [Makefile.perf:236: sub-make] Error 2
> make: *** [Makefile:113: install-bin] Error 2
> make: Leaving directory '/var/home/acme/git/perf/tools/perf'
>
> Performance counter stats for 'make -k BUILD_BPF_SKEL=1 CORESIGHT=1 O=/tmp/build/perf -C tools/perf install-bin':

Hmm.. strange. In the include/linux/perf_event.h, the
perf_sample_data has sample_flags, but vmlinux.h doesn't.

Thanks,
Namhyung