diff options
author | Stephane Eranian <eranian@google.com> | 2012-02-09 17:20:59 -0500 |
---|---|---|
committer | Ingo Molnar <mingo@elte.hu> | 2012-03-05 08:55:42 -0500 |
commit | 2481c5fa6db0237e4f0168f88913178b2b495b7c (patch) | |
tree | 4d0e8e9616c8e83ca2a72abbc3ac94621adc49be /kernel/events | |
parent | 3e702ff6d1ea12dcf1c798ecb61e7f3a1579df42 (diff) |
perf: Disable PERF_SAMPLE_BRANCH_* when not supported
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>
Diffstat (limited to 'kernel/events')
-rw-r--r-- | kernel/events/core.c | 24 | ||||
-rw-r--r-- | kernel/events/hw_breakpoint.c | 6 |
2 files changed, 30 insertions, 0 deletions
diff --git a/kernel/events/core.c b/kernel/events/core.c index 5820efdf47cd..242bb51c67f2 100644 --- a/kernel/events/core.c +++ b/kernel/events/core.c | |||
@@ -5044,6 +5044,12 @@ static int perf_swevent_init(struct perf_event *event) | |||
5044 | if (event->attr.type != PERF_TYPE_SOFTWARE) | 5044 | if (event->attr.type != PERF_TYPE_SOFTWARE) |
5045 | return -ENOENT; | 5045 | return -ENOENT; |
5046 | 5046 | ||
5047 | /* | ||
5048 | * no branch sampling for software events | ||
5049 | */ | ||
5050 | if (has_branch_stack(event)) | ||
5051 | return -EOPNOTSUPP; | ||
5052 | |||
5047 | switch (event_id) { | 5053 | switch (event_id) { |
5048 | case PERF_COUNT_SW_CPU_CLOCK: | 5054 | case PERF_COUNT_SW_CPU_CLOCK: |
5049 | case PERF_COUNT_SW_TASK_CLOCK: | 5055 | case PERF_COUNT_SW_TASK_CLOCK: |
@@ -5154,6 +5160,12 @@ static int perf_tp_event_init(struct perf_event *event) | |||
5154 | if (event->attr.type != PERF_TYPE_TRACEPOINT) | 5160 | if (event->attr.type != PERF_TYPE_TRACEPOINT) |
5155 | return -ENOENT; | 5161 | return -ENOENT; |
5156 | 5162 | ||
5163 | /* | ||
5164 | * no branch sampling for tracepoint events | ||
5165 | */ | ||
5166 | if (has_branch_stack(event)) | ||
5167 | return -EOPNOTSUPP; | ||
5168 | |||
5157 | err = perf_trace_init(event); | 5169 | err = perf_trace_init(event); |
5158 | if (err) | 5170 | if (err) |
5159 | return err; | 5171 | return err; |
@@ -5379,6 +5391,12 @@ static int cpu_clock_event_init(struct perf_event *event) | |||
5379 | if (event->attr.config != PERF_COUNT_SW_CPU_CLOCK) | 5391 | if (event->attr.config != PERF_COUNT_SW_CPU_CLOCK) |
5380 | return -ENOENT; | 5392 | return -ENOENT; |
5381 | 5393 | ||
5394 | /* | ||
5395 | * no branch sampling for software events | ||
5396 | */ | ||
5397 | if (has_branch_stack(event)) | ||
5398 | return -EOPNOTSUPP; | ||
5399 | |||
5382 | perf_swevent_init_hrtimer(event); | 5400 | perf_swevent_init_hrtimer(event); |
5383 | 5401 | ||
5384 | return 0; | 5402 | return 0; |
@@ -5453,6 +5471,12 @@ static int task_clock_event_init(struct perf_event *event) | |||
5453 | if (event->attr.config != PERF_COUNT_SW_TASK_CLOCK) | 5471 | if (event->attr.config != PERF_COUNT_SW_TASK_CLOCK) |
5454 | return -ENOENT; | 5472 | return -ENOENT; |
5455 | 5473 | ||
5474 | /* | ||
5475 | * no branch sampling for software events | ||
5476 | */ | ||
5477 | if (has_branch_stack(event)) | ||
5478 | return -EOPNOTSUPP; | ||
5479 | |||
5456 | perf_swevent_init_hrtimer(event); | 5480 | perf_swevent_init_hrtimer(event); |
5457 | 5481 | ||
5458 | return 0; | 5482 | return 0; |
diff --git a/kernel/events/hw_breakpoint.c b/kernel/events/hw_breakpoint.c index 3330022a7ac1..bb38c4d3ee12 100644 --- a/kernel/events/hw_breakpoint.c +++ b/kernel/events/hw_breakpoint.c | |||
@@ -581,6 +581,12 @@ static int hw_breakpoint_event_init(struct perf_event *bp) | |||
581 | if (bp->attr.type != PERF_TYPE_BREAKPOINT) | 581 | if (bp->attr.type != PERF_TYPE_BREAKPOINT) |
582 | return -ENOENT; | 582 | return -ENOENT; |
583 | 583 | ||
584 | /* | ||
585 | * no branch sampling for breakpoint events | ||
586 | */ | ||
587 | if (has_branch_stack(bp)) | ||
588 | return -EOPNOTSUPP; | ||
589 | |||
584 | err = register_perf_hw_breakpoint(bp); | 590 | err = register_perf_hw_breakpoint(bp); |
585 | if (err) | 591 | if (err) |
586 | return err; | 592 | return err; |