perf: Disable PERF_SAMPLE_BRANCH_* when not supported
authorStephane Eranian <eranian@google.com>
Thu, 9 Feb 2012 22:20:59 +0000 (23:20 +0100)
committerIngo Molnar <mingo@elte.hu>
Mon, 5 Mar 2012 13:55:42 +0000 (14:55 +0100)
PERF_SAMPLE_BRANCH_* is disabled for:

 - SW events (sw counters, tracepoints)
 - HW breakpoints
 - ALL but Intel x86 architecture
 - AMD64 processors

Signed-off-by: Stephane Eranian <eranian@google.com>
Signed-off-by: Peter Zijlstra <a.p.zijlstra@chello.nl>
Link: http://lkml.kernel.org/r/1328826068-11713-10-git-send-email-eranian@google.com
Signed-off-by: Ingo Molnar <mingo@elte.hu>
arch/alpha/kernel/perf_event.c
arch/arm/kernel/perf_event.c
arch/mips/kernel/perf_event_mipsxx.c
arch/powerpc/kernel/perf_event.c
arch/sh/kernel/perf_event.c
arch/sparc/kernel/perf_event.c
arch/x86/kernel/cpu/perf_event_amd.c
kernel/events/core.c
kernel/events/hw_breakpoint.c

index 8143cd7..0dae252 100644 (file)
@@ -685,6 +685,10 @@ static int alpha_pmu_event_init(struct perf_event *event)
 {
        int err;
 
+       /* does not support taken branch sampling */
+       if (has_branch_stack(event))
+               return -EOPNOTSUPP;
+
        switch (event->attr.type) {
        case PERF_TYPE_RAW:
        case PERF_TYPE_HARDWARE:
index 5bb91bf..a23c42a 100644 (file)
@@ -539,6 +539,10 @@ static int armpmu_event_init(struct perf_event *event)
        int err = 0;
        atomic_t *active_events = &armpmu->active_events;
 
+       /* does not support taken branch sampling */
+       if (has_branch_stack(event))
+               return -EOPNOTSUPP;
+
        if (armpmu->map_event(event) == -ENOENT)
                return -ENOENT;
 
index e3b897a..811084f 100644 (file)
@@ -606,6 +606,10 @@ static int mipspmu_event_init(struct perf_event *event)
 {
        int err = 0;
 
+       /* does not support taken branch sampling */
+       if (has_branch_stack(event))
+               return -EOPNOTSUPP;
+
        switch (event->attr.type) {
        case PERF_TYPE_RAW:
        case PERF_TYPE_HARDWARE:
index f04c230..c2e27ed 100644 (file)
@@ -1084,6 +1084,10 @@ static int power_pmu_event_init(struct perf_event *event)
        if (!ppmu)
                return -ENOENT;
 
+       /* does not support taken branch sampling */
+       if (has_branch_stack(event))
+               return -EOPNOTSUPP;
+
        switch (event->attr.type) {
        case PERF_TYPE_HARDWARE:
                ev = event->attr.config;
index 10b14e3..068b8a2 100644 (file)
@@ -310,6 +310,10 @@ static int sh_pmu_event_init(struct perf_event *event)
 {
        int err;
 
+       /* does not support taken branch sampling */
+       if (has_branch_stack(event))
+               return -EOPNOTSUPP;
+
        switch (event->attr.type) {
        case PERF_TYPE_RAW:
        case PERF_TYPE_HW_CACHE:
index 614da62..8e16a4a 100644 (file)
@@ -1105,6 +1105,10 @@ static int sparc_pmu_event_init(struct perf_event *event)
        if (atomic_read(&nmi_active) < 0)
                return -ENODEV;
 
+       /* does not support taken branch sampling */
+       if (has_branch_stack(event))
+               return -EOPNOTSUPP;
+
        switch (attr->type) {
        case PERF_TYPE_HARDWARE:
                if (attr->config >= sparc_pmu->max_events)
index 67250a5..dd002fa 100644 (file)
@@ -139,6 +139,9 @@ static int amd_pmu_hw_config(struct perf_event *event)
        if (ret)
                return ret;
 
+       if (has_branch_stack(event))
+               return -EOPNOTSUPP;
+
        if (event->attr.exclude_host && event->attr.exclude_guest)
                /*
                 * When HO == GO == 1 the hardware treats that as GO == HO == 0
index 5820efd..242bb51 100644 (file)
@@ -5044,6 +5044,12 @@ static int perf_swevent_init(struct perf_event *event)
        if (event->attr.type != PERF_TYPE_SOFTWARE)
                return -ENOENT;
 
+       /*
+        * no branch sampling for software events
+        */
+       if (has_branch_stack(event))
+               return -EOPNOTSUPP;
+
        switch (event_id) {
        case PERF_COUNT_SW_CPU_CLOCK:
        case PERF_COUNT_SW_TASK_CLOCK:
@@ -5154,6 +5160,12 @@ static int perf_tp_event_init(struct perf_event *event)
        if (event->attr.type != PERF_TYPE_TRACEPOINT)
                return -ENOENT;
 
+       /*
+        * no branch sampling for tracepoint events
+        */
+       if (has_branch_stack(event))
+               return -EOPNOTSUPP;
+
        err = perf_trace_init(event);
        if (err)
                return err;
@@ -5379,6 +5391,12 @@ static int cpu_clock_event_init(struct perf_event *event)
        if (event->attr.config != PERF_COUNT_SW_CPU_CLOCK)
                return -ENOENT;
 
+       /*
+        * no branch sampling for software events
+        */
+       if (has_branch_stack(event))
+               return -EOPNOTSUPP;
+
        perf_swevent_init_hrtimer(event);
 
        return 0;
@@ -5453,6 +5471,12 @@ static int task_clock_event_init(struct perf_event *event)
        if (event->attr.config != PERF_COUNT_SW_TASK_CLOCK)
                return -ENOENT;
 
+       /*
+        * no branch sampling for software events
+        */
+       if (has_branch_stack(event))
+               return -EOPNOTSUPP;
+
        perf_swevent_init_hrtimer(event);
 
        return 0;
index 3330022..bb38c4d 100644 (file)
@@ -581,6 +581,12 @@ static int hw_breakpoint_event_init(struct perf_event *bp)
        if (bp->attr.type != PERF_TYPE_BREAKPOINT)
                return -ENOENT;
 
+       /*
+        * no branch sampling for breakpoint events
+        */
+       if (has_branch_stack(bp))
+               return -EOPNOTSUPP;
+
        err = register_perf_hw_breakpoint(bp);
        if (err)
                return err;