diff mbox series

powerpc/perf: Fix disabling BHRB and instruction sampling

Message ID 20231018153423.298373-1-npiggin@gmail.com (mailing list archive)
State Accepted
Commit ea142e590aec55ba40c5affb4d49e68c713c63dc
Headers show
Series powerpc/perf: Fix disabling BHRB and instruction sampling | expand

Checks

Context Check Description
snowpatch_ozlabs/github-powerpc_ppctests success Successfully ran 8 jobs.
snowpatch_ozlabs/github-powerpc_selftests success Successfully ran 8 jobs.
snowpatch_ozlabs/github-powerpc_sparse success Successfully ran 4 jobs.
snowpatch_ozlabs/github-powerpc_clang success Successfully ran 6 jobs.
snowpatch_ozlabs/github-powerpc_kernel_qemu success Successfully ran 23 jobs.

Commit Message

Nicholas Piggin Oct. 18, 2023, 3:34 p.m. UTC
When the PMU is disabled, MMCRA is not updated to disable BHRB and
instruction sampling. This can lead to those features remaining enabled,
which can slow down a real or emulated CPU.

Fixes: 1cade527f6e9 ("powerpc/perf: BHRB control to disable BHRB logic when not used")
Signed-off-by: Nicholas Piggin <npiggin@gmail.com>
---
 arch/powerpc/perf/core-book3s.c | 5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)

Comments

Michael Ellerman Oct. 27, 2023, 9:59 a.m. UTC | #1
On Thu, 19 Oct 2023 01:34:23 +1000, Nicholas Piggin wrote:
> When the PMU is disabled, MMCRA is not updated to disable BHRB and
> instruction sampling. This can lead to those features remaining enabled,
> which can slow down a real or emulated CPU.
> 
> 

Applied to powerpc/next.

[1/1] powerpc/perf: Fix disabling BHRB and instruction sampling
      https://git.kernel.org/powerpc/c/ea142e590aec55ba40c5affb4d49e68c713c63dc

cheers
diff mbox series

Patch

diff --git a/arch/powerpc/perf/core-book3s.c b/arch/powerpc/perf/core-book3s.c
index 8c1f7def596e..10b946e9c6e7 100644
--- a/arch/powerpc/perf/core-book3s.c
+++ b/arch/powerpc/perf/core-book3s.c
@@ -1371,8 +1371,7 @@  static void power_pmu_disable(struct pmu *pmu)
 		/*
 		 * Disable instruction sampling if it was enabled
 		 */
-		if (cpuhw->mmcr.mmcra & MMCRA_SAMPLE_ENABLE)
-			val &= ~MMCRA_SAMPLE_ENABLE;
+		val &= ~MMCRA_SAMPLE_ENABLE;
 
 		/* Disable BHRB via mmcra (BHRBRD) for p10 */
 		if (ppmu->flags & PPMU_ARCH_31)
@@ -1383,7 +1382,7 @@  static void power_pmu_disable(struct pmu *pmu)
 		 * instruction sampling or BHRB.
 		 */
 		if (val != mmcra) {
-			mtspr(SPRN_MMCRA, mmcra);
+			mtspr(SPRN_MMCRA, val);
 			mb();
 			isync();
 		}