diff options
author | Peter Zijlstra <peterz@infradead.org> | 2013-09-16 03:23:02 -0400 |
---|---|---|
committer | Ingo Molnar <mingo@kernel.org> | 2013-09-20 00:53:44 -0400 |
commit | eb8417aa703eff5ff43d0275f19b0a8e591d818d (patch) | |
tree | aa6f24a7a4065dde34e0df8e82df47219d693d7d /arch/x86/kernel/cpu/perf_event_intel_ds.c | |
parent | 7f2ee91f54fb56071f97bde1ef7ba7ba0d58dfe5 (diff) |
perf/x86/intel: Remove division from the intel_pmu_drain_pebs_nhm() hot path
Only do the division in case we have to print the result out in a warning.
Signed-off-by: Peter Zijlstra <peterz@infradead.org>
Link: http://lkml.kernel.org/n/tip-43nl31erfbajwpfj254f6zji@git.kernel.org
Signed-off-by: Ingo Molnar <mingo@kernel.org>
Diffstat (limited to 'arch/x86/kernel/cpu/perf_event_intel_ds.c')
-rw-r--r-- | arch/x86/kernel/cpu/perf_event_intel_ds.c | 10 |
1 files changed, 5 insertions, 5 deletions
diff --git a/arch/x86/kernel/cpu/perf_event_intel_ds.c b/arch/x86/kernel/cpu/perf_event_intel_ds.c index f364c13ddaa6..655d591b57a0 100644 --- a/arch/x86/kernel/cpu/perf_event_intel_ds.c +++ b/arch/x86/kernel/cpu/perf_event_intel_ds.c | |||
@@ -944,7 +944,7 @@ static void intel_pmu_drain_pebs_nhm(struct pt_regs *iregs) | |||
944 | struct perf_event *event = NULL; | 944 | struct perf_event *event = NULL; |
945 | void *at, *top; | 945 | void *at, *top; |
946 | u64 status = 0; | 946 | u64 status = 0; |
947 | int bit, n; | 947 | int bit; |
948 | 948 | ||
949 | if (!x86_pmu.pebs_active) | 949 | if (!x86_pmu.pebs_active) |
950 | return; | 950 | return; |
@@ -954,16 +954,16 @@ static void intel_pmu_drain_pebs_nhm(struct pt_regs *iregs) | |||
954 | 954 | ||
955 | ds->pebs_index = ds->pebs_buffer_base; | 955 | ds->pebs_index = ds->pebs_buffer_base; |
956 | 956 | ||
957 | n = (top - at) / x86_pmu.pebs_record_size; | 957 | if (unlikely(at > top)) |
958 | if (n <= 0) | ||
959 | return; | 958 | return; |
960 | 959 | ||
961 | /* | 960 | /* |
962 | * Should not happen, we program the threshold at 1 and do not | 961 | * Should not happen, we program the threshold at 1 and do not |
963 | * set a reset value. | 962 | * set a reset value. |
964 | */ | 963 | */ |
965 | WARN_ONCE(n > x86_pmu.max_pebs_events, | 964 | WARN_ONCE(top - at > x86_pmu.max_pebs_events * x86_pmu.pebs_record_size, |
966 | "Unexpected number of pebs records %d\n", n); | 965 | "Unexpected number of pebs records %ld\n", |
966 | (top - at) / x86_pmu.pebs_record_size); | ||
967 | 967 | ||
968 | for (; at < top; at += x86_pmu.pebs_record_size) { | 968 | for (; at < top; at += x86_pmu.pebs_record_size) { |
969 | struct pebs_record_nhm *p = at; | 969 | struct pebs_record_nhm *p = at; |