perfcounters: powerpc: set sample enable bit for marked instruction events
PATCH 2/2 perfcounters: powerpc: set sample enable bit for marked instruction events
Impact: enable access to hardware feature
POWER processors have the ability to "mark" a subset of the instructions and provide more detailed information on what happens to the marked instructions as they flow through the pipeline. This marking is enabled by the "sample enable" bit in MMCRA, and there are synchronization requirements around setting and clearing the bit.
This adds logic to the processor-specific back-ends so that they know which events relate to marked instructions and set the sampling enable bit if any event that we want to put on the PMU is a marked instruction event. It also adds logic to the generic powerpc code to do the necessary synchronization if that bit is set.
--- arch/powerpc/kernel/perf_counter.c | 28 +++++++-- arch/powerpc/kernel/power5+-pmu.c | 103 +++++++++++++++++++++++++++++- arch/powerpc/kernel/power5-pmu.c | 96 +++++++++++++++++++++++++++- arch/powerpc/kernel/power6-pmu.c | 126 +++++++++++++++++++++++++++++++++++- arch/powerpc/kernel/ppc970-pmu.c | 72 ++++++++++++++++++++- 5 files changed, 413 insertions(+), 12 deletions(-)
arch/powerpc/kernel/perf_counter.c +23 -5
@@ -307,6 +307,15 @@ u64 hw_perf_save_disable(void) }/* +* Disable instruction sampling if it was enabled +*/ +if (cpuhw->mmcr[2 ] &MMCRA_SAMPLE_ENABLE ) { +mtspr (SPRN_MMCRA , + cpuhw->mmcr[2 ] & ~MMCRA_SAMPLE_ENABLE ); +mb (); + } + +/* * Set the 'freeze counters' bit. * The barrier is to make sure the mtspr has been * executed and the PMU has frozen the counters
@@ -347,12 +356,11 @@ void hw_perf_restore(u64 disable)* (possibly updated for removal of counters). */ if (!cpuhw->n_added) { -mtspr (SPRN_MMCRA , cpuhw->mmcr[2 ]); +mtspr (SPRN_MMCRA , cpuhw->mmcr[2 ] & ~MMCRA_SAMPLE_ENABLE );mtspr (SPRN_MMCR1 , cpuhw->mmcr[1 ]); -mtspr (SPRN_MMCR0 , cpuhw->mmcr[0 ]);if (cpuhw->n_counters ==0 )get_lppaca ()->pmcregs_in_use =0 ; - goto out; + goto out_enable; }/*
@@ -385,7 +393,7 @@ void hw_perf_restore(u64 disable)* Then unfreeze the counters. */ get_lppaca ()->pmcregs_in_use =1 ; -mtspr (SPRN_MMCRA , cpuhw->mmcr[2 ]); +mtspr (SPRN_MMCRA , cpuhw->mmcr[2 ] & ~MMCRA_SAMPLE_ENABLE );mtspr (SPRN_MMCR1 , cpuhw->mmcr[1 ]);mtspr (SPRN_MMCR0 , (cpuhw->mmcr[0 ] & ~(MMCR0_PMC1CE | MMCR0_PMCjCE)) |MMCR0_FC );
@@ -421,10 +429,20 @@ void hw_perf_restore(u64 disable)write_pmc (counter->hw.idx, val);perf_counter_update_userpage (counter); } -mb (); cpuhw->mmcr[0 ] |=MMCR0_PMXE |MMCR0_FCECE ; + + out_enable: +mb ();mtspr (SPRN_MMCR0 , cpuhw->mmcr[0 ]); +/* +* Enable instruction sampling if necessary +*/ +if (cpuhw->mmcr[2 ] &MMCRA_SAMPLE_ENABLE ) { +mb (); +mtspr (SPRN_MMCRA , cpuhw->mmcr[2 ]); + } + out:local_irq_restore (flags); }
arch/powerpc/kernel/power5+-pmu.c +101 -2
129 lines not on this page · raw message
arch/powerpc/kernel/power5-pmu.c +95 -1
118 lines not on this page · raw message
arch/powerpc/kernel/power6-pmu.c +125 -1
150 lines not on this page · raw message
arch/powerpc/kernel/ppc970-pmu.c +69 -3
114 lines not on this page · raw message
Signature · 1 line
1.5.6.3
[tip:perfcounters/core] perf_counter: powerpc: set sample enable bit for marked instruction events
Commit-ID: f708223d49ac39f5af1643985056206c98033f5b Gitweb: http://git.kernel.org/tip/f708223d49ac39f5af1643985056206c98033f5b Author: Paul Mackerras <[email protected]> AuthorDate: Wed, 8 Apr 2009 20:30:18 +1000 Committer: Ingo Molnar <[email protected]> CommitDate: Wed, 8 Apr 2009 12:39:28 +0200
perf_counter: powerpc: set sample enable bit for marked instruction events
Impact: enable access to hardware feature
POWER processors have the ability to "mark" a subset of the instructions and provide more detailed information on what happens to the marked instructions as they flow through the pipeline. This marking is enabled by the "sample enable" bit in MMCRA, and there are synchronization requirements around setting and clearing the bit.
This adds logic to the processor-specific back-ends so that they know which events relate to marked instructions and set the sampling enable bit if any event that we want to put on the PMU is a marked instruction event. It also adds logic to the generic powerpc code to do the necessary synchronization if that bit is set.
LKML-Reference: <[email protected]>
--- arch/powerpc/kernel/perf_counter.c | 28 +++++++-- arch/powerpc/kernel/power5+-pmu.c | 103 +++++++++++++++++++++++++++++- arch/powerpc/kernel/power5-pmu.c | 96 +++++++++++++++++++++++++++- arch/powerpc/kernel/power6-pmu.c | 126 +++++++++++++++++++++++++++++++++++- arch/powerpc/kernel/ppc970-pmu.c | 72 ++++++++++++++++++++- 5 files changed, 413 insertions(+), 12 deletions(-)
arch/powerpc/kernel/perf_counter.c +23 -5
@@ -307,6 +307,15 @@ u64 hw_perf_save_disable(void) }/* +* Disable instruction sampling if it was enabled +*/ +if (cpuhw->mmcr[2 ] &MMCRA_SAMPLE_ENABLE ) { +mtspr (SPRN_MMCRA , + cpuhw->mmcr[2 ] & ~MMCRA_SAMPLE_ENABLE ); +mb (); + } + +/* * Set the 'freeze counters' bit. * The barrier is to make sure the mtspr has been * executed and the PMU has frozen the counters
@@ -347,12 +356,11 @@ void hw_perf_restore(u64 disable)* (possibly updated for removal of counters). */ if (!cpuhw->n_added) { -mtspr (SPRN_MMCRA , cpuhw->mmcr[2 ]); +mtspr (SPRN_MMCRA , cpuhw->mmcr[2 ] & ~MMCRA_SAMPLE_ENABLE );mtspr (SPRN_MMCR1 , cpuhw->mmcr[1 ]); -mtspr (SPRN_MMCR0 , cpuhw->mmcr[0 ]);if (cpuhw->n_counters ==0 )get_lppaca ()->pmcregs_in_use =0 ; - goto out; + goto out_enable; }/*
@@ -385,7 +393,7 @@ void hw_perf_restore(u64 disable)* Then unfreeze the counters. */ get_lppaca ()->pmcregs_in_use =1 ; -mtspr (SPRN_MMCRA , cpuhw->mmcr[2 ]); +mtspr (SPRN_MMCRA , cpuhw->mmcr[2 ] & ~MMCRA_SAMPLE_ENABLE );mtspr (SPRN_MMCR1 , cpuhw->mmcr[1 ]);mtspr (SPRN_MMCR0 , (cpuhw->mmcr[0 ] & ~(MMCR0_PMC1CE | MMCR0_PMCjCE)) |MMCR0_FC );
@@ -421,10 +429,20 @@ void hw_perf_restore(u64 disable)write_pmc (counter->hw.idx, val);perf_counter_update_userpage (counter); } -mb (); cpuhw->mmcr[0 ] |=MMCR0_PMXE |MMCR0_FCECE ; + + out_enable: +mb ();mtspr (SPRN_MMCR0 , cpuhw->mmcr[0 ]); +/* +* Enable instruction sampling if necessary +*/ +if (cpuhw->mmcr[2 ] &MMCRA_SAMPLE_ENABLE ) { +mb (); +mtspr (SPRN_MMCRA , cpuhw->mmcr[2 ]); + } + out:local_irq_restore (flags); }
arch/powerpc/kernel/power5+-pmu.c +101 -2
129 lines not on this page · raw message
arch/powerpc/kernel/power5-pmu.c +95 -1
118 lines not on this page · raw message
arch/powerpc/kernel/power6-pmu.c +125 -1
150 lines not on this page · raw message
arch/powerpc/kernel/ppc970-pmu.c +69 -3
114 lines not on this page · raw message