]> git.karo-electronics.de Git - linux-beck.git/commitdiff
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 8143cd7cdbfbe62a7f6568f4fc1767f31d499997..0dae252f7a33b10ecb0d4e6a9fe77b8e5556fb14 100644 (file)
@@ -685,6 +685,10 @@ static int alpha_pmu_event_init(struct perf_event *event)
 {
        int err;
 
 {
        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:
        switch (event->attr.type) {
        case PERF_TYPE_RAW:
        case PERF_TYPE_HARDWARE:
index 5bb91bf3d47f24c9c6fb75324535c39e54b2c62e..a23c42abc6947d29bae28b4399d570e288447862 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;
 
        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;
 
        if (armpmu->map_event(event) == -ENOENT)
                return -ENOENT;
 
index e3b897acfbc04b3db1cbd29a37a423ccca4df815..811084f4e4220910d83314c843af969ef5425b72 100644 (file)
@@ -606,6 +606,10 @@ static int mipspmu_event_init(struct perf_event *event)
 {
        int err = 0;
 
 {
        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:
        switch (event->attr.type) {
        case PERF_TYPE_RAW:
        case PERF_TYPE_HARDWARE:
index f04c2301725e843e24d1c0a81b9962bc6d6de2f2..c2e27ede07ec8afb138fbaac31b736ea96b6ddc1 100644 (file)
@@ -1084,6 +1084,10 @@ static int power_pmu_event_init(struct perf_event *event)
        if (!ppmu)
                return -ENOENT;
 
        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;
        switch (event->attr.type) {
        case PERF_TYPE_HARDWARE:
                ev = event->attr.config;
index 10b14e3a7eb8142bd88a81ddd9c3a9cb96941a36..068b8a2759b5208bf0067cee27b9b3a6559263cb 100644 (file)
@@ -310,6 +310,10 @@ static int sh_pmu_event_init(struct perf_event *event)
 {
        int err;
 
 {
        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:
        switch (event->attr.type) {
        case PERF_TYPE_RAW:
        case PERF_TYPE_HW_CACHE:
index 614da624330c5057b9ad4d4b6a77ca1c51e4e123..8e16a4a21582073bd1f2edc21d33efafb8f7e2fa 100644 (file)
@@ -1105,6 +1105,10 @@ static int sparc_pmu_event_init(struct perf_event *event)
        if (atomic_read(&nmi_active) < 0)
                return -ENODEV;
 
        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)
        switch (attr->type) {
        case PERF_TYPE_HARDWARE:
                if (attr->config >= sparc_pmu->max_events)
index 67250a52430bfd9a3d0cf89fa38408d0e8cd793a..dd002faff7a65156fc5dccec44b052331d0d5c81 100644 (file)
@@ -139,6 +139,9 @@ static int amd_pmu_hw_config(struct perf_event *event)
        if (ret)
                return ret;
 
        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
        if (event->attr.exclude_host && event->attr.exclude_guest)
                /*
                 * When HO == GO == 1 the hardware treats that as GO == HO == 0
index 5820efdf47cddaf62123d5eca985c07474faa710..242bb51c67f26759b2a7c62e9b98f64524f4281c 100644 (file)
@@ -5044,6 +5044,12 @@ static int perf_swevent_init(struct perf_event *event)
        if (event->attr.type != PERF_TYPE_SOFTWARE)
                return -ENOENT;
 
        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:
        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;
 
        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;
        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;
 
        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;
        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;
 
        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;
        perf_swevent_init_hrtimer(event);
 
        return 0;
index 3330022a7ac1123f87939daab6a7b4b589accd80..bb38c4d3ee129ab06c1b46dc295ca6864c39c416 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;
 
        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;
        err = register_perf_hw_breakpoint(bp);
        if (err)
                return err;