perf/core: Set data->sample_flags in perf_prepare_sample()
authorNamhyung Kim <namhyung@kernel.org>
Wed, 18 Jan 2023 06:05:56 +0000 (22:05 -0800)
committerIngo Molnar <mingo@kernel.org>
Wed, 18 Jan 2023 10:57:20 +0000 (11:57 +0100)
commitbb447c27a4674628ea50341cfa4b31618f2010af
treed119eb43c79cc18fda7eeeec39dbd4697e3ab5e7
parenteb55b455ef9c7123bdfa7e8a7f1ebeaa8034eb83
perf/core: Set data->sample_flags in perf_prepare_sample()

The perf_prepare_sample() function sets the perf_sample_data according
to the attr->sample_type before copying it to the ring buffer.  But BPF
also wants to access the sample data so it needs to prepare the sample
even before the regular path.

That means perf_prepare_sample() can be called more than once.  Set
the data->sample_flags consistently so that it can indicate which fields
are set already and skip them if sets.

Also update the filtered_sample_type to have the dependent flags to
reduce the number of branches.

Suggested-by: Peter Zijlstra <peterz@infradead.org>
Signed-off-by: Namhyung Kim <namhyung@kernel.org>
Signed-off-by: Ingo Molnar <mingo@kernel.org>
Tested-by: Jiri Olsa <jolsa@kernel.org>
Acked-by: Jiri Olsa <jolsa@kernel.org>
Acked-by: Peter Zijlstra <peterz@infradead.org>
Link: https://lore.kernel.org/r/20230118060559.615653-6-namhyung@kernel.org
kernel/events/core.c