perf/x86: Add PERF_X86_EVENT_NEEDS_BRANCH_STACK flag
authorKan Liang <kan.liang@linux.intel.com>
Wed, 25 Oct 2023 20:16:20 +0000 (13:16 -0700)
committerPeter Zijlstra <peterz@infradead.org>
Fri, 27 Oct 2023 13:05:09 +0000 (15:05 +0200)
commit85846b27072defc7ab3dcee7ff36563a040079dc
tree287c12b68fe5e265b16b874576af953d44c0a57f
parent571d91dcadfa3cef499010b4eddb9b58b0da4d24
perf/x86: Add PERF_X86_EVENT_NEEDS_BRANCH_STACK flag

Currently, branch_sample_type !=0 is used to check whether a branch
stack setup is required. But it doesn't check the sample type,
unnecessary branch stack setup may be done for a counting event. E.g.,
perf record -e "{branch-instructions,branch-misses}:S" -j any
Also, the event only with the new PERF_SAMPLE_BRANCH_COUNTERS branch
sample type may not require a branch stack setup either.

Add a new flag NEEDS_BRANCH_STACK to indicate whether the event requires
a branch stack setup. Replace the needs_branch_stack() by checking the
new flag.

The counting event check is implemented here. The later patch will take
the new PERF_SAMPLE_BRANCH_COUNTERS into account.

Signed-off-by: Kan Liang <kan.liang@linux.intel.com>
Signed-off-by: Peter Zijlstra (Intel) <peterz@infradead.org>
Link: https://lkml.kernel.org/r/20231025201626.3000228-2-kan.liang@linux.intel.com
arch/x86/events/intel/core.c
arch/x86/events/perf_event_flags.h