House keeping for the perf PMU dump/reset code
Subsystems (2)
The perf core PMU driver has functions to dump the PMU, and also reset it when something goes wrong. These code paths hadn't quite keep up with newer PMU features.
This patchkit fixes various issues.
Shouldn't make a difference unless something goes wrong with the PMU.
-Andi
PATCH 1/3 perf, x86: Reset more state in PMU reset
From: Andi Kleen <[email protected]>
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
--- arch/x86/kernel/cpu/perf_event_intel.c | 11 +++++++++++ 1 file changed, 11 insertions(+)
arch/x86/kernel/cpu/perf_event_intel.c +11 -0
@@ -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); }
Signature · 1 line
1.9.3
tip-bot for Andi Kleen
merge bot[tip:perf/core] perf/x86/intel: Reset more state in PMU reset
perf/x86/intel: Reset more state in PMU reset
Commit-ID: 8882edf735738c949aba4b65d3ec3453066bab12 Gitweb: http://git.kernel.org/tip/8882edf735738c949aba4b65d3ec3453066bab12 Author: Andi Kleen <[email protected]> AuthorDate: Fri, 27 Feb 2015 09:48:30 -0800 Committer: Ingo Molnar <[email protected]> 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
--- arch/x86/kernel/cpu/perf_event_intel.c | 12 ++++++++++++ 1 file changed, 12 insertions(+)
arch/x86/kernel/cpu/perf_event_intel.c +12 -0
@@ -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); }
PATCH 2/3 perf, x86: Dump DEBUGCTL in pmu dump
In reply to Andi KleenFrom: Andi Kleen <[email protected]>
LBRs and LBR freezing are controlled through DEBUGCTL. So dump the state of DEBUGCTL too when dumping the PMU state.
--- arch/x86/kernel/cpu/perf_event.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-)
arch/x86/kernel/cpu/perf_event.c +5 -1
@@ -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);
Signature · 1 line
1.9.3
tip-bot for Andi Kleen
merge bot[tip:perf/core] perf/x86: Dump DEBUGCTL in PMU dump
perf/x86: Dump DEBUGCTL in PMU dump
Commit-ID: da3e606d885a17525eb18afd423f5c438860b833 Gitweb: http://git.kernel.org/tip/da3e606d885a17525eb18afd423f5c438860b833 Author: Andi Kleen <[email protected]> AuthorDate: Fri, 27 Feb 2015 09:48:31 -0800 Committer: Ingo Molnar <[email protected]> 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.
--- arch/x86/kernel/cpu/perf_event.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-)
arch/x86/kernel/cpu/perf_event.c +5 -1
@@ -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);
PATCH 3/3 perf, x86: Only dump PEBS register when PEBS has been detected
In reply to Andi KleenFrom: Andi Kleen <[email protected]>
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.
--- arch/x86/kernel/cpu/perf_event.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-)
arch/x86/kernel/cpu/perf_event.c +4 -2
@@ -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);
Signature · 1 line
1.9.3
tip-bot for Andi Kleen
merge bot[tip:perf/core] perf/x86: Only dump PEBS register when PEBS has been detected
perf/x86: Only dump PEBS register when PEBS has been detected
Commit-ID: 15fde1101a1aed11958e0d86bc360f01866a74b1 Gitweb: http://git.kernel.org/tip/15fde1101a1aed11958e0d86bc360f01866a74b1 Author: Andi Kleen <[email protected]> AuthorDate: Fri, 27 Feb 2015 09:48:32 -0800 Committer: Ingo Molnar <[email protected]> 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.
--- arch/x86/kernel/cpu/perf_event.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-)
arch/x86/kernel/cpu/perf_event.c +4 -2
@@ -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);