perf: Add branch_sample_call_stack
authorKan Liang <kan.liang@linux.intel.com>
Wed, 25 Oct 2023 20:16:21 +0000 (13:16 -0700)
committerPeter Zijlstra <peterz@infradead.org>
Fri, 27 Oct 2023 13:05:09 +0000 (15:05 +0200)
Add a helper function to check call stack sample type.

The later patch will invoke the function in several places.

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-3-kan.liang@linux.intel.com
arch/x86/events/core.c
include/linux/perf_event.h

index 40c9af124128d62a43630e7afca35c9c5a083a4f..09050641ce5d3c02ad099d8faabbe5e98fe57570 100644 (file)
@@ -601,7 +601,7 @@ int x86_pmu_hw_config(struct perf_event *event)
                }
        }
 
-       if (event->attr.branch_sample_type & PERF_SAMPLE_BRANCH_CALL_STACK)
+       if (branch_sample_call_stack(event))
                event->attach_state |= PERF_ATTACH_TASK_DATA;
 
        /*
index 7897ef06602723eb8d53b0ecc5de42385cb99da4..ac1a59c1f252260a70a3d2ce9ac8e59c3118a763 100644 (file)
@@ -1144,6 +1144,11 @@ static inline bool branch_sample_counters(const struct perf_event *event)
        return event->attr.branch_sample_type & PERF_SAMPLE_BRANCH_COUNTERS;
 }
 
+static inline bool branch_sample_call_stack(const struct perf_event *event)
+{
+       return event->attr.branch_sample_type & PERF_SAMPLE_BRANCH_CALL_STACK;
+}
+
 struct perf_sample_data {
        /*
         * Fields set by perf_sample_data_init() unconditionally,