perf bpf-filter: Support multiple events properly
authorNamhyung Kim <namhyung@kernel.org>
Tue, 20 Aug 2024 15:45:02 +0000 (08:45 -0700)
committerArnaldo Carvalho de Melo <acme@redhat.com>
Wed, 28 Aug 2024 21:07:20 +0000 (18:07 -0300)
commit0fe2b18ddc40bf8fbcd96dab651822dbadc1cd85
tree760bf4d420912624864dce7d7bc2a68da93e79a4
parent4f3affe0abf5d5910dc469a1f63257629605d3c3
perf bpf-filter: Support multiple events properly

So far it used tgid as a key to get the filter expressions in the
pinned filters map for regular users but it won't work well if the has
more than one filters at the same time.  Let's add the event id to the
key of the filter hash map so that it can identify the right filter
expression in the BPF program.

As the event can be inherited to child tasks, it should use the primary
id which belongs to the parent (original) event.  Since evsel opens the
event for multiple CPUs and tasks, it needs to maintain a separate hash
map for the event id.

In the user space, it keeps a list for the multiple evsel and release
the entries in the both hash map when it closes the event.

Signed-off-by: Namhyung Kim <namhyung@kernel.org>
Cc: Adrian Hunter <adrian.hunter@intel.com>
Cc: Ian Rogers <irogers@google.com>
Cc: Ingo Molnar <mingo@kernel.org>
Cc: Jiri Olsa <jolsa@kernel.org>
Cc: KP Singh <kpsingh@kernel.org>
Cc: Kan Liang <kan.liang@linux.intel.com>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Song Liu <song@kernel.org>
Link: https://lore.kernel.org/r/20240820154504.128923-1-namhyung@kernel.org
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
tools/perf/util/bpf-filter.c
tools/perf/util/bpf_skel/sample-filter.h
tools/perf/util/bpf_skel/sample_filter.bpf.c
tools/perf/util/bpf_skel/vmlinux/vmlinux.h