diff mbox series

[3/3] selftests/powerpc: ensure PMC reads are set and ordered on count_pmc

Message ID 20200408223543.21168-4-desnesn@linux.ibm.com (mailing list archive)
State New
Headers show
Series selftests/powerpc: A few fixes on powerpc selftests | expand

Checks

Context Check Description
snowpatch_ozlabs/apply_patch success Successfully applied on branch powerpc/merge (2c0ce4ff35994a7b12cc9879ced52c9e7c2e6667)
snowpatch_ozlabs/build-ppc64le success Build succeeded
snowpatch_ozlabs/build-ppc64be success Build succeeded
snowpatch_ozlabs/build-ppc64e success Build succeeded
snowpatch_ozlabs/build-pmac32 warning Upstream build failed, couldn't test patch
snowpatch_ozlabs/checkpatch success total: 0 errors, 0 warnings, 0 checks, 10 lines checked
snowpatch_ozlabs/needsstable success Patch has no Fixes tags

Commit Message

Desnes A. Nunes do Rosario April 8, 2020, 10:35 p.m. UTC
Function count_pmc() needs a memory barrier to ensure that PMC reads are
fully consistent. The lack of it can occasionally fail pmc56_overflow test,
since depending on the workload on the system, PMC5 & 6 can have past val-
ues from the time the counters are frozen and turned back on. These past
values will be accounted as overflows and make the test fail.

=========
test: pmc56_overflow
...
ebb_state:
...
>>pmc[5] count = 0xfd4cbc8c
>>pmc[6] count = 0xddd8b3b6
HW state:
MMCR0 0x0000000084000000 FC PMAE
MMCR2 0x0000000000000000
EBBHR 0x0000000010003f68
BESCR 0x8000000000000000 GE
...
PMC5  0x0000000000000000
PMC6  0x0000000000000000
SIAR  0x0000000010003398
...
  [3]: register SPRN_PMC2  = 0x0000000080000003
  [4]: register SPRN_PMC5  = 0x0000000000000000
  [5]: register SPRN_PMC6  = 0x0000000000000000
  [6]: register SPRN_PMC2  = 0x0000000080000003
>>[7]: register SPRN_PMC5  = 0x000000008f21266d
>>[8]: register SPRN_PMC6  = 0x000000000da80f8d
  [9]: register SPRN_PMC2  = 0x0000000080000003
>>[10]: register SPRN_PMC5  = 0x000000006e2b961f
>>[11]: register SPRN_PMC6  = 0x00000000d030a429
  [12]: register SPRN_PMC2  = 0x0000000080000003
  [13]: register SPRN_PMC5  = 0x0000000000000000
  [14]: register SPRN_PMC6  = 0x0000000000000000
...
PMC5/6 overflow 2
[FAIL] Test FAILED on line 87
failure: pmc56_overflow
=========

Signed-off-by: Desnes A. Nunes do Rosario <desnesn@linux.ibm.com>
---
 tools/testing/selftests/powerpc/pmu/ebb/ebb.c | 4 ++++
 1 file changed, 4 insertions(+)

Comments

Rashmica Gupta April 23, 2020, 5:54 a.m. UTC | #1
On Wed, 2020-04-08 at 19:35 -0300, Desnes A. Nunes do Rosario wrote:
> Function count_pmc() needs a memory barrier to ensure that PMC reads
> are
> fully consistent. The lack of it can occasionally fail pmc56_overflow
> test,
> since depending on the workload on the system, PMC5 & 6 can have past
> val-
> ues from the time the counters are frozen and turned back on. These
> past
> values will be accounted as overflows and make the test fail.
> 
> =========
> test: pmc56_overflow
> ...
> ebb_state:
> ...
> > > pmc[5] count = 0xfd4cbc8c
> > > pmc[6] count = 0xddd8b3b6
> HW state:
> MMCR0 0x0000000084000000 FC PMAE
> MMCR2 0x0000000000000000
> EBBHR 0x0000000010003f68
> BESCR 0x8000000000000000 GE
> ...
> PMC5  0x0000000000000000
> PMC6  0x0000000000000000
> SIAR  0x0000000010003398
> ...
>   [3]: register SPRN_PMC2  = 0x0000000080000003
>   [4]: register SPRN_PMC5  = 0x0000000000000000
>   [5]: register SPRN_PMC6  = 0x0000000000000000
>   [6]: register SPRN_PMC2  = 0x0000000080000003
> > > [7]: register SPRN_PMC5  = 0x000000008f21266d
> > > [8]: register SPRN_PMC6  = 0x000000000da80f8d
>   [9]: register SPRN_PMC2  = 0x0000000080000003
> > > [10]: register SPRN_PMC5  = 0x000000006e2b961f
> > > [11]: register SPRN_PMC6  = 0x00000000d030a429
>   [12]: register SPRN_PMC2  = 0x0000000080000003
>   [13]: register SPRN_PMC5  = 0x0000000000000000
>   [14]: register SPRN_PMC6  = 0x0000000000000000
> ...
> PMC5/6 overflow 2
> [FAIL] Test FAILED on line 87
> failure: pmc56_overflow
> =========
> 
> Signed-off-by: Desnes A. Nunes do Rosario <desnesn@linux.ibm.com>

Reviewed-by: Rashmica Gupta <rashmica.g@gmail.com>

> ---
>  tools/testing/selftests/powerpc/pmu/ebb/ebb.c | 4 ++++
>  1 file changed, 4 insertions(+)
> 
> diff --git a/tools/testing/selftests/powerpc/pmu/ebb/ebb.c
> b/tools/testing/selftests/powerpc/pmu/ebb/ebb.c
> index bf6f25dfcf7b..6199f3cea0f9 100644
> --- a/tools/testing/selftests/powerpc/pmu/ebb/ebb.c
> +++ b/tools/testing/selftests/powerpc/pmu/ebb/ebb.c
> @@ -258,6 +258,10 @@ int count_pmc(int pmc, uint32_t sample_period)
>  	start_value = pmc_sample_period(sample_period);
>  
>  	val = read_pmc(pmc);
> +
> +	/* Ensure pmc value is consistent between freezes */
> +	mb();
> +
>  	if (val < start_value)
>  		ebb_state.stats.negative++;
>  	else
diff mbox series

Patch

diff --git a/tools/testing/selftests/powerpc/pmu/ebb/ebb.c b/tools/testing/selftests/powerpc/pmu/ebb/ebb.c
index bf6f25dfcf7b..6199f3cea0f9 100644
--- a/tools/testing/selftests/powerpc/pmu/ebb/ebb.c
+++ b/tools/testing/selftests/powerpc/pmu/ebb/ebb.c
@@ -258,6 +258,10 @@  int count_pmc(int pmc, uint32_t sample_period)
 	start_value = pmc_sample_period(sample_period);
 
 	val = read_pmc(pmc);
+
+	/* Ensure pmc value is consistent between freezes */
+	mb();
+
 	if (val < start_value)
 		ebb_state.stats.negative++;
 	else