perf bpf filter: Implement event sample filtering
authorNamhyung Kim <namhyung@kernel.org>
Tue, 14 Mar 2023 23:42:29 +0000 (16:42 -0700)
committerArnaldo Carvalho de Melo <acme@redhat.com>
Wed, 15 Mar 2023 13:34:33 +0000 (10:34 -0300)
commit56ec9457a4a20c5e07ad94bfb6e23077d54cb28e
treecafe1144949eb53e95bfbbfc4e2ce9fb87e04c1f
parent990a71e904f6ec2d7d84eecb37e5127b75721985
perf bpf filter: Implement event sample filtering

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.

Signed-off-by: Namhyung Kim <namhyung@kernel.org>
Acked-by: Jiri Olsa <jolsa@kernel.org>
Cc: Adrian Hunter <adrian.hunter@intel.com>
Cc: Andi Kleen <ak@linux.intel.com>
Cc: Hao Luo <haoluo@google.com>
Cc: Ian Rogers <irogers@google.com>
Cc: Ingo Molnar <mingo@kernel.org>
Cc: James Clark <james.clark@arm.com>
Cc: Kan Liang <kan.liang@linux.intel.com>
Cc: Leo Yan <leo.yan@linaro.org>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Ravi Bangoria <ravi.bangoria@amd.com>
Cc: Song Liu <song@kernel.org>
Cc: Stephane Eranian <eranian@google.com>
Cc: bpf@vger.kernel.org
Link: https://lore.kernel.org/r/20230314234237.3008956-2-namhyung@kernel.org
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
tools/perf/Makefile.perf
tools/perf/util/bpf-filter.c
tools/perf/util/bpf-filter.h
tools/perf/util/bpf_skel/sample-filter.h [new file with mode: 0644]
tools/perf/util/bpf_skel/sample_filter.bpf.c [new file with mode: 0644]
tools/perf/util/evsel.h