* [PATCH 1/3] perf, x86: Reset more state in PMU reset
2015-02-27 17:48 House keeping for the perf PMU dump/reset code Andi Kleen
@ 2015-02-27 17:48 ` Andi Kleen
2015-04-02 18:45 ` [tip:perf/core] perf/x86/intel: " tip-bot for Andi Kleen
2015-02-27 17:48 ` [PATCH 2/3] perf, x86: Dump DEBUGCTL in pmu dump Andi Kleen
2015-02-27 17:48 ` [PATCH 3/3] perf, x86: Only dump PEBS register when PEBS has been detected Andi Kleen
2 siblings, 1 reply; 7+ messages in thread
From: Andi Kleen @ 2015-02-27 17:48 UTC (permalink / raw)
To: peterz; +Cc: linux-kernel, eranian, Andi Kleen
From: Andi Kleen <ak@linux.intel.com>
The PMU reset code didn't quite keep up with newer PMU features.
Improve it a bit to really reset a modern PMU:
- Clear all overflow status
- Clear LBRs and freezing state
- Disable fixed counters too
Signed-off-by: Andi Kleen <ak@linux.intel.com>
---
arch/x86/kernel/cpu/perf_event_intel.c | 11 +++++++++++
1 file changed, 11 insertions(+)
diff --git a/arch/x86/kernel/cpu/perf_event_intel.c b/arch/x86/kernel/cpu/perf_event_intel.c
index 3c024ba..0a48094 100644
--- a/arch/x86/kernel/cpu/perf_event_intel.c
+++ b/arch/x86/kernel/cpu/perf_event_intel.c
@@ -1596,6 +1596,17 @@ static void intel_pmu_reset(void)
if (ds)
ds->bts_index = ds->bts_buffer_base;
+ /* Ack all overflows and disable fixed counters */
+ if (x86_pmu.version >= 2) {
+ intel_pmu_ack_status(intel_pmu_get_status());
+ wrmsrl(MSR_CORE_PERF_GLOBAL_CTRL, 0);
+ }
+
+ /* Reset LBRs and LBR freezing */
+ if (x86_pmu.lbr_nr)
+ update_debugctlmsr(get_debugctlmsr() &
+ ~(DEBUGCTLMSR_FREEZE_LBRS_ON_PMI|DEBUGCTLMSR_LBR));
+
local_irq_restore(flags);
}
--
1.9.3
^ permalink raw reply [flat|nested] 7+ messages in thread* [tip:perf/core] perf/x86/intel: Reset more state in PMU reset
2015-02-27 17:48 ` [PATCH 1/3] perf, x86: Reset more state in PMU reset Andi Kleen
@ 2015-04-02 18:45 ` tip-bot for Andi Kleen
0 siblings, 0 replies; 7+ messages in thread
From: tip-bot for Andi Kleen @ 2015-04-02 18:45 UTC (permalink / raw)
To: linux-tip-commits; +Cc: mingo, ak, linux-kernel, hpa, peterz, tglx
Commit-ID: 8882edf735738c949aba4b65d3ec3453066bab12
Gitweb: http://git.kernel.org/tip/8882edf735738c949aba4b65d3ec3453066bab12
Author: Andi Kleen <ak@linux.intel.com>
AuthorDate: Fri, 27 Feb 2015 09:48:30 -0800
Committer: Ingo Molnar <mingo@kernel.org>
CommitDate: Thu, 2 Apr 2015 17:33:16 +0200
perf/x86/intel: Reset more state in PMU reset
The PMU reset code didn't quite keep up with newer PMU features.
Improve it a bit to really reset a modern PMU:
- Clear all overflow status
- Clear LBRs and freezing state
- Disable fixed counters too
Signed-off-by: Andi Kleen <ak@linux.intel.com>
Signed-off-by: Peter Zijlstra (Intel) <peterz@infradead.org>
Cc: eranian@google.com
Link: http://lkml.kernel.org/r/1425059312-18217-2-git-send-email-andi@firstfloor.org
Signed-off-by: Ingo Molnar <mingo@kernel.org>
---
arch/x86/kernel/cpu/perf_event_intel.c | 12 ++++++++++++
1 file changed, 12 insertions(+)
diff --git a/arch/x86/kernel/cpu/perf_event_intel.c b/arch/x86/kernel/cpu/perf_event_intel.c
index 6ea61a5..5999460 100644
--- a/arch/x86/kernel/cpu/perf_event_intel.c
+++ b/arch/x86/kernel/cpu/perf_event_intel.c
@@ -1538,6 +1538,18 @@ static void intel_pmu_reset(void)
if (ds)
ds->bts_index = ds->bts_buffer_base;
+ /* Ack all overflows and disable fixed counters */
+ if (x86_pmu.version >= 2) {
+ intel_pmu_ack_status(intel_pmu_get_status());
+ wrmsrl(MSR_CORE_PERF_GLOBAL_CTRL, 0);
+ }
+
+ /* Reset LBRs and LBR freezing */
+ if (x86_pmu.lbr_nr) {
+ update_debugctlmsr(get_debugctlmsr() &
+ ~(DEBUGCTLMSR_FREEZE_LBRS_ON_PMI|DEBUGCTLMSR_LBR));
+ }
+
local_irq_restore(flags);
}
^ permalink raw reply [flat|nested] 7+ messages in thread
* [PATCH 2/3] perf, x86: Dump DEBUGCTL in pmu dump
2015-02-27 17:48 House keeping for the perf PMU dump/reset code Andi Kleen
2015-02-27 17:48 ` [PATCH 1/3] perf, x86: Reset more state in PMU reset Andi Kleen
@ 2015-02-27 17:48 ` Andi Kleen
2015-04-02 18:45 ` [tip:perf/core] perf/x86: Dump DEBUGCTL in PMU dump tip-bot for Andi Kleen
2015-02-27 17:48 ` [PATCH 3/3] perf, x86: Only dump PEBS register when PEBS has been detected Andi Kleen
2 siblings, 1 reply; 7+ messages in thread
From: Andi Kleen @ 2015-02-27 17:48 UTC (permalink / raw)
To: peterz; +Cc: linux-kernel, eranian, Andi Kleen
From: Andi Kleen <ak@linux.intel.com>
LBRs and LBR freezing are controlled through DEBUGCTL. So
dump the state of DEBUGCTL too when dumping the PMU state.
Signed-off-by: Andi Kleen <ak@linux.intel.com>
---
arch/x86/kernel/cpu/perf_event.c | 6 +++++-
1 file changed, 5 insertions(+), 1 deletion(-)
diff --git a/arch/x86/kernel/cpu/perf_event.c b/arch/x86/kernel/cpu/perf_event.c
index 01b6f3a..1579a46 100644
--- a/arch/x86/kernel/cpu/perf_event.c
+++ b/arch/x86/kernel/cpu/perf_event.c
@@ -1105,7 +1105,7 @@ static void x86_pmu_start(struct perf_event *event, int flags)
void perf_event_print_debug(void)
{
u64 ctrl, status, overflow, pmc_ctrl, pmc_count, prev_left, fixed;
- u64 pebs;
+ u64 pebs, debugctl;
struct cpu_hw_events *cpuc;
unsigned long flags;
int cpu, idx;
@@ -1131,6 +1131,10 @@ void perf_event_print_debug(void)
pr_info("CPU#%d: overflow: %016llx\n", cpu, overflow);
pr_info("CPU#%d: fixed: %016llx\n", cpu, fixed);
pr_info("CPU#%d: pebs: %016llx\n", cpu, pebs);
+ if (x86_pmu.lbr_nr) {
+ rdmsrl(MSR_IA32_DEBUGCTLMSR, debugctl);
+ pr_info("CPU#%d: debugctl: %016llx\n", cpu, debugctl);
+ }
}
pr_info("CPU#%d: active: %016llx\n", cpu, *(u64 *)cpuc->active_mask);
--
1.9.3
^ permalink raw reply [flat|nested] 7+ messages in thread* [tip:perf/core] perf/x86: Dump DEBUGCTL in PMU dump
2015-02-27 17:48 ` [PATCH 2/3] perf, x86: Dump DEBUGCTL in pmu dump Andi Kleen
@ 2015-04-02 18:45 ` tip-bot for Andi Kleen
0 siblings, 0 replies; 7+ messages in thread
From: tip-bot for Andi Kleen @ 2015-04-02 18:45 UTC (permalink / raw)
To: linux-tip-commits; +Cc: peterz, tglx, hpa, linux-kernel, mingo, ak
Commit-ID: da3e606d885a17525eb18afd423f5c438860b833
Gitweb: http://git.kernel.org/tip/da3e606d885a17525eb18afd423f5c438860b833
Author: Andi Kleen <ak@linux.intel.com>
AuthorDate: Fri, 27 Feb 2015 09:48:31 -0800
Committer: Ingo Molnar <mingo@kernel.org>
CommitDate: Thu, 2 Apr 2015 17:33:17 +0200
perf/x86: Dump DEBUGCTL in PMU dump
LBRs and LBR freezing are controlled through the DEBUGCTL MSR. So
dump the state of DEBUGCTL too when dumping the PMU state.
Signed-off-by: Andi Kleen <ak@linux.intel.com>
Signed-off-by: Peter Zijlstra (Intel) <peterz@infradead.org>
Cc: eranian@google.com
Link: http://lkml.kernel.org/r/1425059312-18217-3-git-send-email-andi@firstfloor.org
Signed-off-by: Ingo Molnar <mingo@kernel.org>
---
arch/x86/kernel/cpu/perf_event.c | 6 +++++-
1 file changed, 5 insertions(+), 1 deletion(-)
diff --git a/arch/x86/kernel/cpu/perf_event.c b/arch/x86/kernel/cpu/perf_event.c
index b8b7a12..9947372 100644
--- a/arch/x86/kernel/cpu/perf_event.c
+++ b/arch/x86/kernel/cpu/perf_event.c
@@ -1171,7 +1171,7 @@ static void x86_pmu_start(struct perf_event *event, int flags)
void perf_event_print_debug(void)
{
u64 ctrl, status, overflow, pmc_ctrl, pmc_count, prev_left, fixed;
- u64 pebs;
+ u64 pebs, debugctl;
struct cpu_hw_events *cpuc;
unsigned long flags;
int cpu, idx;
@@ -1197,6 +1197,10 @@ void perf_event_print_debug(void)
pr_info("CPU#%d: overflow: %016llx\n", cpu, overflow);
pr_info("CPU#%d: fixed: %016llx\n", cpu, fixed);
pr_info("CPU#%d: pebs: %016llx\n", cpu, pebs);
+ if (x86_pmu.lbr_nr) {
+ rdmsrl(MSR_IA32_DEBUGCTLMSR, debugctl);
+ pr_info("CPU#%d: debugctl: %016llx\n", cpu, debugctl);
+ }
}
pr_info("CPU#%d: active: %016llx\n", cpu, *(u64 *)cpuc->active_mask);
^ permalink raw reply [flat|nested] 7+ messages in thread
* [PATCH 3/3] perf, x86: Only dump PEBS register when PEBS has been detected
2015-02-27 17:48 House keeping for the perf PMU dump/reset code Andi Kleen
2015-02-27 17:48 ` [PATCH 1/3] perf, x86: Reset more state in PMU reset Andi Kleen
2015-02-27 17:48 ` [PATCH 2/3] perf, x86: Dump DEBUGCTL in pmu dump Andi Kleen
@ 2015-02-27 17:48 ` Andi Kleen
2015-04-02 18:45 ` [tip:perf/core] perf/x86: " tip-bot for Andi Kleen
2 siblings, 1 reply; 7+ messages in thread
From: Andi Kleen @ 2015-02-27 17:48 UTC (permalink / raw)
To: peterz; +Cc: linux-kernel, eranian, Andi Kleen
From: Andi Kleen <ak@linux.intel.com>
Technically PEBS_ENABLED is only guaranteed to exist when we
detected PEBS. So add a check for this to the PMU dump function.
I don't think it can happen on a real CPU, but could in a VM.
Signed-off-by: Andi Kleen <ak@linux.intel.com>
---
arch/x86/kernel/cpu/perf_event.c | 6 ++++--
1 file changed, 4 insertions(+), 2 deletions(-)
diff --git a/arch/x86/kernel/cpu/perf_event.c b/arch/x86/kernel/cpu/perf_event.c
index 1579a46..bca85ca 100644
--- a/arch/x86/kernel/cpu/perf_event.c
+++ b/arch/x86/kernel/cpu/perf_event.c
@@ -1123,14 +1123,16 @@ void perf_event_print_debug(void)
rdmsrl(MSR_CORE_PERF_GLOBAL_STATUS, status);
rdmsrl(MSR_CORE_PERF_GLOBAL_OVF_CTRL, overflow);
rdmsrl(MSR_ARCH_PERFMON_FIXED_CTR_CTRL, fixed);
- rdmsrl(MSR_IA32_PEBS_ENABLE, pebs);
pr_info("\n");
pr_info("CPU#%d: ctrl: %016llx\n", cpu, ctrl);
pr_info("CPU#%d: status: %016llx\n", cpu, status);
pr_info("CPU#%d: overflow: %016llx\n", cpu, overflow);
pr_info("CPU#%d: fixed: %016llx\n", cpu, fixed);
- pr_info("CPU#%d: pebs: %016llx\n", cpu, pebs);
+ if (x86_pmu.pebs_constraints) {
+ rdmsrl(MSR_IA32_PEBS_ENABLE, pebs);
+ pr_info("CPU#%d: pebs: %016llx\n", cpu, pebs);
+ }
if (x86_pmu.lbr_nr) {
rdmsrl(MSR_IA32_DEBUGCTLMSR, debugctl);
pr_info("CPU#%d: debugctl: %016llx\n", cpu, debugctl);
--
1.9.3
^ permalink raw reply [flat|nested] 7+ messages in thread* [tip:perf/core] perf/x86: Only dump PEBS register when PEBS has been detected
2015-02-27 17:48 ` [PATCH 3/3] perf, x86: Only dump PEBS register when PEBS has been detected Andi Kleen
@ 2015-04-02 18:45 ` tip-bot for Andi Kleen
0 siblings, 0 replies; 7+ messages in thread
From: tip-bot for Andi Kleen @ 2015-04-02 18:45 UTC (permalink / raw)
To: linux-tip-commits; +Cc: peterz, hpa, mingo, ak, tglx, linux-kernel
Commit-ID: 15fde1101a1aed11958e0d86bc360f01866a74b1
Gitweb: http://git.kernel.org/tip/15fde1101a1aed11958e0d86bc360f01866a74b1
Author: Andi Kleen <ak@linux.intel.com>
AuthorDate: Fri, 27 Feb 2015 09:48:32 -0800
Committer: Ingo Molnar <mingo@kernel.org>
CommitDate: Thu, 2 Apr 2015 17:33:17 +0200
perf/x86: Only dump PEBS register when PEBS has been detected
Technically PEBS_ENABLED is only guaranteed to exist when we
detected PEBS. So add a check for this to the PMU dump function.
I don't think it can happen on a real CPU, but could in a VM.
Signed-off-by: Andi Kleen <ak@linux.intel.com>
Signed-off-by: Peter Zijlstra (Intel) <peterz@infradead.org>
Cc: eranian@google.com
Link: http://lkml.kernel.org/r/1425059312-18217-4-git-send-email-andi@firstfloor.org
Signed-off-by: Ingo Molnar <mingo@kernel.org>
---
arch/x86/kernel/cpu/perf_event.c | 6 ++++--
1 file changed, 4 insertions(+), 2 deletions(-)
diff --git a/arch/x86/kernel/cpu/perf_event.c b/arch/x86/kernel/cpu/perf_event.c
index 9947372..689e357 100644
--- a/arch/x86/kernel/cpu/perf_event.c
+++ b/arch/x86/kernel/cpu/perf_event.c
@@ -1189,14 +1189,16 @@ void perf_event_print_debug(void)
rdmsrl(MSR_CORE_PERF_GLOBAL_STATUS, status);
rdmsrl(MSR_CORE_PERF_GLOBAL_OVF_CTRL, overflow);
rdmsrl(MSR_ARCH_PERFMON_FIXED_CTR_CTRL, fixed);
- rdmsrl(MSR_IA32_PEBS_ENABLE, pebs);
pr_info("\n");
pr_info("CPU#%d: ctrl: %016llx\n", cpu, ctrl);
pr_info("CPU#%d: status: %016llx\n", cpu, status);
pr_info("CPU#%d: overflow: %016llx\n", cpu, overflow);
pr_info("CPU#%d: fixed: %016llx\n", cpu, fixed);
- pr_info("CPU#%d: pebs: %016llx\n", cpu, pebs);
+ if (x86_pmu.pebs_constraints) {
+ rdmsrl(MSR_IA32_PEBS_ENABLE, pebs);
+ pr_info("CPU#%d: pebs: %016llx\n", cpu, pebs);
+ }
if (x86_pmu.lbr_nr) {
rdmsrl(MSR_IA32_DEBUGCTLMSR, debugctl);
pr_info("CPU#%d: debugctl: %016llx\n", cpu, debugctl);
^ permalink raw reply [flat|nested] 7+ messages in thread