perf/x86/intel: Expose LBR callstack to user space tooling
authorPeter Zijlstra <peterz@infradead.org>
Wed, 5 Nov 2014 09:36:45 +0000 (10:36 +0100)
committerIngo Molnar <mingo@kernel.org>
Wed, 18 Feb 2015 16:16:15 +0000 (17:16 +0100)
With LBR call stack feature enable, there are three callchain options.
Enable the 3rd callchain option (LBR callstack) to user space tooling.

Signed-off-by: Peter Zijlstra (Intel) <peterz@infradead.org>
Cc: Jiri Olsa <jolsa@redhat.com>
Cc: Arnaldo Carvalho de Melo <acme@kernel.org>
Cc: Andy Lutomirski <luto@amacapital.net>
Cc: Kan Liang <kan.liang@intel.com>
Cc: Linus Torvalds <torvalds@linux-foundation.org>
Cc: Paul Mackerras <paulus@samba.org>
Cc: Vince Weaver <vincent.weaver@maine.edu>
Cc: linux-api@vger.kernel.org
Link: http://lkml.kernel.org/r/20141105093759.GQ10501@worktop.programming.kicks-ass.net
Signed-off-by: Ingo Molnar <mingo@kernel.org>
arch/x86/kernel/cpu/perf_event.h
arch/x86/kernel/cpu/perf_event_intel_lbr.c
include/uapi/linux/perf_event.h

index 69c26b396cf43fa5ec47f82b4867a0f8893e8955..a371d27d6795fb37511de68cca891509975dc8b3 100644 (file)
@@ -523,14 +523,6 @@ struct x86_perf_task_context {
        int lbr_stack_state;
 };
 
-enum {
-       PERF_SAMPLE_BRANCH_CALL_STACK_SHIFT = PERF_SAMPLE_BRANCH_MAX_SHIFT,
-       PERF_SAMPLE_BRANCH_SELECT_MAP_SIZE,
-
-       PERF_SAMPLE_BRANCH_CALL_STACK =
-                               1U << PERF_SAMPLE_BRANCH_CALL_STACK_SHIFT,
-};
-
 #define x86_add_quirk(func_)                                           \
 do {                                                                   \
        static struct x86_pmu_quirk __quirk __initdata = {              \
index 084f2eb20c8b17e2785aa3187fa30dbd269197a7..0473874109cb7a4551cbf114d15670af4a023037 100644 (file)
@@ -537,7 +537,7 @@ static int intel_pmu_setup_hw_lbr_filter(struct perf_event *event)
        u64 mask = 0, v;
        int i;
 
-       for (i = 0; i < PERF_SAMPLE_BRANCH_SELECT_MAP_SIZE; i++) {
+       for (i = 0; i < PERF_SAMPLE_BRANCH_MAX_SHIFT; i++) {
                if (!(br_type & (1ULL << i)))
                        continue;
 
@@ -821,7 +821,7 @@ intel_pmu_lbr_filter(struct cpu_hw_events *cpuc)
 /*
  * Map interface branch filters onto LBR filters
  */
-static const int nhm_lbr_sel_map[PERF_SAMPLE_BRANCH_SELECT_MAP_SIZE] = {
+static const int nhm_lbr_sel_map[PERF_SAMPLE_BRANCH_MAX_SHIFT] = {
        [PERF_SAMPLE_BRANCH_ANY_SHIFT]          = LBR_ANY,
        [PERF_SAMPLE_BRANCH_USER_SHIFT]         = LBR_USER,
        [PERF_SAMPLE_BRANCH_KERNEL_SHIFT]       = LBR_KERNEL,
@@ -840,7 +840,7 @@ static const int nhm_lbr_sel_map[PERF_SAMPLE_BRANCH_SELECT_MAP_SIZE] = {
        [PERF_SAMPLE_BRANCH_COND_SHIFT]     = LBR_JCC,
 };
 
-static const int snb_lbr_sel_map[PERF_SAMPLE_BRANCH_SELECT_MAP_SIZE] = {
+static const int snb_lbr_sel_map[PERF_SAMPLE_BRANCH_MAX_SHIFT] = {
        [PERF_SAMPLE_BRANCH_ANY_SHIFT]          = LBR_ANY,
        [PERF_SAMPLE_BRANCH_USER_SHIFT]         = LBR_USER,
        [PERF_SAMPLE_BRANCH_KERNEL_SHIFT]       = LBR_KERNEL,
@@ -852,7 +852,7 @@ static const int snb_lbr_sel_map[PERF_SAMPLE_BRANCH_SELECT_MAP_SIZE] = {
        [PERF_SAMPLE_BRANCH_COND_SHIFT]         = LBR_JCC,
 };
 
-static const int hsw_lbr_sel_map[PERF_SAMPLE_BRANCH_SELECT_MAP_SIZE] = {
+static const int hsw_lbr_sel_map[PERF_SAMPLE_BRANCH_MAX_SHIFT] = {
        [PERF_SAMPLE_BRANCH_ANY_SHIFT]          = LBR_ANY,
        [PERF_SAMPLE_BRANCH_USER_SHIFT]         = LBR_USER,
        [PERF_SAMPLE_BRANCH_KERNEL_SHIFT]       = LBR_KERNEL,
index e46b93279e3d5b4fb48ef4bfed44b7b5ea4199d1..1e3cd07cf76e29269756c7a162369eb3a4fcdf14 100644 (file)
@@ -166,6 +166,8 @@ enum perf_branch_sample_type_shift {
        PERF_SAMPLE_BRANCH_NO_TX_SHIFT          = 9, /* not in transaction */
        PERF_SAMPLE_BRANCH_COND_SHIFT           = 10, /* conditional branches */
 
+       PERF_SAMPLE_BRANCH_CALL_STACK_SHIFT     = 11, /* call/ret stack */
+
        PERF_SAMPLE_BRANCH_MAX_SHIFT            /* non-ABI */
 };
 
@@ -175,18 +177,16 @@ enum perf_branch_sample_type {
        PERF_SAMPLE_BRANCH_HV           = 1U << PERF_SAMPLE_BRANCH_HV_SHIFT,
 
        PERF_SAMPLE_BRANCH_ANY          = 1U << PERF_SAMPLE_BRANCH_ANY_SHIFT,
-       PERF_SAMPLE_BRANCH_ANY_CALL     =
-                               1U << PERF_SAMPLE_BRANCH_ANY_CALL_SHIFT,
-       PERF_SAMPLE_BRANCH_ANY_RETURN   =
-                               1U << PERF_SAMPLE_BRANCH_ANY_RETURN_SHIFT,
-       PERF_SAMPLE_BRANCH_IND_CALL     =
-                               1U << PERF_SAMPLE_BRANCH_IND_CALL_SHIFT,
-       PERF_SAMPLE_BRANCH_ABORT_TX     =
-                               1U << PERF_SAMPLE_BRANCH_ABORT_TX_SHIFT,
+       PERF_SAMPLE_BRANCH_ANY_CALL     = 1U << PERF_SAMPLE_BRANCH_ANY_CALL_SHIFT,
+       PERF_SAMPLE_BRANCH_ANY_RETURN   = 1U << PERF_SAMPLE_BRANCH_ANY_RETURN_SHIFT,
+       PERF_SAMPLE_BRANCH_IND_CALL     = 1U << PERF_SAMPLE_BRANCH_IND_CALL_SHIFT,
+       PERF_SAMPLE_BRANCH_ABORT_TX     = 1U << PERF_SAMPLE_BRANCH_ABORT_TX_SHIFT,
        PERF_SAMPLE_BRANCH_IN_TX        = 1U << PERF_SAMPLE_BRANCH_IN_TX_SHIFT,
        PERF_SAMPLE_BRANCH_NO_TX        = 1U << PERF_SAMPLE_BRANCH_NO_TX_SHIFT,
        PERF_SAMPLE_BRANCH_COND         = 1U << PERF_SAMPLE_BRANCH_COND_SHIFT,
 
+       PERF_SAMPLE_BRANCH_CALL_STACK   = 1U << PERF_SAMPLE_BRANCH_CALL_STACK_SHIFT,
+
        PERF_SAMPLE_BRANCH_MAX          = 1U << PERF_SAMPLE_BRANCH_MAX_SHIFT,
 };