diff mbox series

[RESEND,1/3] selftests/powerpc: Use write_pmc instead of count_pmc to reset PMCs on ebb tests

Message ID 20200408223543.21168-2-desnesn@linux.ibm.com
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/checkpatch success total: 0 errors, 0 warnings, 0 checks, 98 lines checked
snowpatch_ozlabs/needsstable success Patch has no Fixes tags

Commit Message

Desnes Augusto Nunes do Rosario April 8, 2020, 10:35 p.m. UTC
By using count_pmc() to reset PMCs instead of write_pmc(), an extra count
is performed on ebb_state.stats.pmc_count[PMC_INDEX(pmc)]. This extra
pmc_count can occasionally invalidate results, such as the ones from
cycles_test shown hereafter. The ebb_check_count() failed with an above
the upper limit error due to the extra ebb_state.stats.pmc_count.

Furthermore, this extra count is also indicated by extra PMC1 trace_log on
the output of the cycle test (as well as on pmc56_overflow_test):

==========
   ...
   [21]: counter = 8
   [22]: register SPRN_MMCR0 = 0x0000000080000080
   [23]: register SPRN_PMC1  = 0x0000000080000004
   [24]: counter = 9
   [25]: register SPRN_MMCR0 = 0x0000000080000080
   [26]: register SPRN_PMC1  = 0x0000000080000004
   [27]: counter = 10
   [28]: register SPRN_MMCR0 = 0x0000000080000080
   [29]: register SPRN_PMC1  = 0x0000000080000004
>> [30]: register SPRN_PMC1  = 0x000000004000051e
PMC1 count (0x280000546) above upper limit 0x2800003e8 (+0x15e)
[FAIL] Test FAILED on line 52
failure: cycles
==========

[desnesn: reflow of original comment]
Signed-off-by: Desnes A. Nunes do Rosario <desnesn@linux.ibm.com>
---
 .../powerpc/pmu/ebb/back_to_back_ebbs_test.c         |  2 +-
 .../testing/selftests/powerpc/pmu/ebb/cycles_test.c  |  2 +-
 .../powerpc/pmu/ebb/cycles_with_freeze_test.c        |  2 +-
 .../powerpc/pmu/ebb/cycles_with_mmcr2_test.c         |  2 +-
 tools/testing/selftests/powerpc/pmu/ebb/ebb.c        |  2 +-
 .../powerpc/pmu/ebb/ebb_on_willing_child_test.c      |  2 +-
 .../selftests/powerpc/pmu/ebb/lost_exception_test.c  |  2 +-
 .../selftests/powerpc/pmu/ebb/multi_counter_test.c   | 12 ++++++------
 .../selftests/powerpc/pmu/ebb/multi_ebb_procs_test.c |  2 +-
 .../selftests/powerpc/pmu/ebb/pmae_handling_test.c   |  2 +-
 .../selftests/powerpc/pmu/ebb/pmc56_overflow_test.c  |  2 +-
 11 files changed, 16 insertions(+), 16 deletions(-)

Comments

Rashmica Gupta April 23, 2020, 5:45 a.m. UTC | #1
On Wed, 2020-04-08 at 19:35 -0300, Desnes A. Nunes do Rosario wrote:
> By using count_pmc() to reset PMCs instead of write_pmc(), an extra
> count
> is performed on ebb_state.stats.pmc_count[PMC_INDEX(pmc)]. This extra
> pmc_count can occasionally invalidate results, such as the ones from
> cycles_test shown hereafter. The ebb_check_count() failed with an
> above
> the upper limit error due to the extra ebb_state.stats.pmc_count.
> 
> Furthermore, this extra count is also indicated by extra PMC1
> trace_log on
> the output of the cycle test (as well as on pmc56_overflow_test):
> 
> ==========
>    ...
>    [21]: counter = 8
>    [22]: register SPRN_MMCR0 = 0x0000000080000080
>    [23]: register SPRN_PMC1  = 0x0000000080000004
>    [24]: counter = 9
>    [25]: register SPRN_MMCR0 = 0x0000000080000080
>    [26]: register SPRN_PMC1  = 0x0000000080000004
>    [27]: counter = 10
>    [28]: register SPRN_MMCR0 = 0x0000000080000080
>    [29]: register SPRN_PMC1  = 0x0000000080000004
> > > [30]: register SPRN_PMC1  = 0x000000004000051e
> PMC1 count (0x280000546) above upper limit 0x2800003e8 (+0x15e)
> [FAIL] Test FAILED on line 52
> failure: cycles
> ==========
> 
> [desnesn: reflow of original comment]
> Signed-off-by: Desnes A. Nunes do Rosario <desnesn@linux.ibm.com>

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

> ---
>  .../powerpc/pmu/ebb/back_to_back_ebbs_test.c         |  2 +-
>  .../testing/selftests/powerpc/pmu/ebb/cycles_test.c  |  2 +-
>  .../powerpc/pmu/ebb/cycles_with_freeze_test.c        |  2 +-
>  .../powerpc/pmu/ebb/cycles_with_mmcr2_test.c         |  2 +-
>  tools/testing/selftests/powerpc/pmu/ebb/ebb.c        |  2 +-
>  .../powerpc/pmu/ebb/ebb_on_willing_child_test.c      |  2 +-
>  .../selftests/powerpc/pmu/ebb/lost_exception_test.c  |  2 +-
>  .../selftests/powerpc/pmu/ebb/multi_counter_test.c   | 12 ++++++--
> ----
>  .../selftests/powerpc/pmu/ebb/multi_ebb_procs_test.c |  2 +-
>  .../selftests/powerpc/pmu/ebb/pmae_handling_test.c   |  2 +-
>  .../selftests/powerpc/pmu/ebb/pmc56_overflow_test.c  |  2 +-
>  11 files changed, 16 insertions(+), 16 deletions(-)
> 
> diff --git
> a/tools/testing/selftests/powerpc/pmu/ebb/back_to_back_ebbs_test.c
> b/tools/testing/selftests/powerpc/pmu/ebb/back_to_back_ebbs_test.c
> index a2d7b0e3dca9..f133ab425f10 100644
> ---
> a/tools/testing/selftests/powerpc/pmu/ebb/back_to_back_ebbs_test.c
> +++
> b/tools/testing/selftests/powerpc/pmu/ebb/back_to_back_ebbs_test.c
> @@ -91,7 +91,7 @@ int back_to_back_ebbs(void)
>  	ebb_global_disable();
>  	ebb_freeze_pmcs();
>  
> -	count_pmc(1, sample_period);
> +	write_pmc(1, pmc_sample_period(sample_period));
>  
>  	dump_ebb_state();
>  
> diff --git a/tools/testing/selftests/powerpc/pmu/ebb/cycles_test.c
> b/tools/testing/selftests/powerpc/pmu/ebb/cycles_test.c
> index bc893813483e..14a399a64729 100644
> --- a/tools/testing/selftests/powerpc/pmu/ebb/cycles_test.c
> +++ b/tools/testing/selftests/powerpc/pmu/ebb/cycles_test.c
> @@ -42,7 +42,7 @@ int cycles(void)
>  	ebb_global_disable();
>  	ebb_freeze_pmcs();
>  
> -	count_pmc(1, sample_period);
> +	write_pmc(1, pmc_sample_period(sample_period));
>  
>  	dump_ebb_state();
>  
> diff --git
> a/tools/testing/selftests/powerpc/pmu/ebb/cycles_with_freeze_test.c
> b/tools/testing/selftests/powerpc/pmu/ebb/cycles_with_freeze_test.c
> index dcd351d20328..0f2089f6f82c 100644
> ---
> a/tools/testing/selftests/powerpc/pmu/ebb/cycles_with_freeze_test.c
> +++
> b/tools/testing/selftests/powerpc/pmu/ebb/cycles_with_freeze_test.c
> @@ -99,7 +99,7 @@ int cycles_with_freeze(void)
>  	ebb_global_disable();
>  	ebb_freeze_pmcs();
>  
> -	count_pmc(1, sample_period);
> +	write_pmc(1, pmc_sample_period(sample_period));
>  
>  	dump_ebb_state();
>  
> diff --git
> a/tools/testing/selftests/powerpc/pmu/ebb/cycles_with_mmcr2_test.c
> b/tools/testing/selftests/powerpc/pmu/ebb/cycles_with_mmcr2_test.c
> index 94c99c12c0f2..a8f3bee04cd8 100644
> ---
> a/tools/testing/selftests/powerpc/pmu/ebb/cycles_with_mmcr2_test.c
> +++
> b/tools/testing/selftests/powerpc/pmu/ebb/cycles_with_mmcr2_test.c
> @@ -71,7 +71,7 @@ int cycles_with_mmcr2(void)
>  	ebb_global_disable();
>  	ebb_freeze_pmcs();
>  
> -	count_pmc(1, sample_period);
> +	write_pmc(1, pmc_sample_period(sample_period));
>  
>  	dump_ebb_state();
>  
> diff --git a/tools/testing/selftests/powerpc/pmu/ebb/ebb.c
> b/tools/testing/selftests/powerpc/pmu/ebb/ebb.c
> index dfbc5c3ad52d..bf6f25dfcf7b 100644
> --- a/tools/testing/selftests/powerpc/pmu/ebb/ebb.c
> +++ b/tools/testing/selftests/powerpc/pmu/ebb/ebb.c
> @@ -396,7 +396,7 @@ int ebb_child(union pipe read_pipe, union pipe
> write_pipe)
>  	ebb_global_disable();
>  	ebb_freeze_pmcs();
>  
> -	count_pmc(1, sample_period);
> +	write_pmc(1, pmc_sample_period(sample_period));
>  
>  	dump_ebb_state();
>  
> diff --git
> a/tools/testing/selftests/powerpc/pmu/ebb/ebb_on_willing_child_test.c
> b/tools/testing/selftests/powerpc/pmu/ebb/ebb_on_willing_child_test.c
> index ca2f7d729155..513812cdcca1 100644
> ---
> a/tools/testing/selftests/powerpc/pmu/ebb/ebb_on_willing_child_test.c
> +++
> b/tools/testing/selftests/powerpc/pmu/ebb/ebb_on_willing_child_test.c
> @@ -38,7 +38,7 @@ static int victim_child(union pipe read_pipe, union
> pipe write_pipe)
>  	ebb_global_disable();
>  	ebb_freeze_pmcs();
>  
> -	count_pmc(1, sample_period);
> +	write_pmc(1, pmc_sample_period(sample_period));
>  
>  	dump_ebb_state();
>  
> diff --git
> a/tools/testing/selftests/powerpc/pmu/ebb/lost_exception_test.c
> b/tools/testing/selftests/powerpc/pmu/ebb/lost_exception_test.c
> index ac3e6e182614..5979606c41dc 100644
> --- a/tools/testing/selftests/powerpc/pmu/ebb/lost_exception_test.c
> +++ b/tools/testing/selftests/powerpc/pmu/ebb/lost_exception_test.c
> @@ -75,7 +75,7 @@ static int test_body(void)
>  	ebb_freeze_pmcs();
>  	ebb_global_disable();
>  
> -	count_pmc(4, sample_period);
> +	write_pmc(4, pmc_sample_period(sample_period));
>  	mtspr(SPRN_PMC4, 0xdead);
>  
>  	dump_summary_ebb_state();
> diff --git
> a/tools/testing/selftests/powerpc/pmu/ebb/multi_counter_test.c
> b/tools/testing/selftests/powerpc/pmu/ebb/multi_counter_test.c
> index b8242e9d97d2..227827b665d5 100644
> --- a/tools/testing/selftests/powerpc/pmu/ebb/multi_counter_test.c
> +++ b/tools/testing/selftests/powerpc/pmu/ebb/multi_counter_test.c
> @@ -70,12 +70,12 @@ int multi_counter(void)
>  	ebb_global_disable();
>  	ebb_freeze_pmcs();
>  
> -	count_pmc(1, sample_period);
> -	count_pmc(2, sample_period);
> -	count_pmc(3, sample_period);
> -	count_pmc(4, sample_period);
> -	count_pmc(5, sample_period);
> -	count_pmc(6, sample_period);
> +	write_pmc(1, pmc_sample_period(sample_period));
> +	write_pmc(2, pmc_sample_period(sample_period));
> +	write_pmc(3, pmc_sample_period(sample_period));
> +	write_pmc(4, pmc_sample_period(sample_period));
> +	write_pmc(5, pmc_sample_period(sample_period));
> +	write_pmc(6, pmc_sample_period(sample_period));
>  
>  	dump_ebb_state();
>  
> diff --git
> a/tools/testing/selftests/powerpc/pmu/ebb/multi_ebb_procs_test.c
> b/tools/testing/selftests/powerpc/pmu/ebb/multi_ebb_procs_test.c
> index a05c0e18ded6..ade70bed0499 100644
> --- a/tools/testing/selftests/powerpc/pmu/ebb/multi_ebb_procs_test.c
> +++ b/tools/testing/selftests/powerpc/pmu/ebb/multi_ebb_procs_test.c
> @@ -61,7 +61,7 @@ static int cycles_child(void)
>  	ebb_global_disable();
>  	ebb_freeze_pmcs();
>  
> -	count_pmc(1, sample_period);
> +	write_pmc(1, pmc_sample_period(sample_period));
>  
>  	dump_summary_ebb_state();
>  
> diff --git
> a/tools/testing/selftests/powerpc/pmu/ebb/pmae_handling_test.c
> b/tools/testing/selftests/powerpc/pmu/ebb/pmae_handling_test.c
> index 153ebc92234f..7b4bf4ed12cb 100644
> --- a/tools/testing/selftests/powerpc/pmu/ebb/pmae_handling_test.c
> +++ b/tools/testing/selftests/powerpc/pmu/ebb/pmae_handling_test.c
> @@ -82,7 +82,7 @@ static int test_body(void)
>  	ebb_global_disable();
>  	ebb_freeze_pmcs();
>  
> -	count_pmc(1, sample_period);
> +	write_pmc(1, pmc_sample_period(sample_period));
>  
>  	dump_ebb_state();
>  
> diff --git
> a/tools/testing/selftests/powerpc/pmu/ebb/pmc56_overflow_test.c
> b/tools/testing/selftests/powerpc/pmu/ebb/pmc56_overflow_test.c
> index eadad75ed7e6..bb55af71404d 100644
> --- a/tools/testing/selftests/powerpc/pmu/ebb/pmc56_overflow_test.c
> +++ b/tools/testing/selftests/powerpc/pmu/ebb/pmc56_overflow_test.c
> @@ -76,7 +76,7 @@ int pmc56_overflow(void)
>  	ebb_global_disable();
>  	ebb_freeze_pmcs();
>  
> -	count_pmc(2, sample_period);
> +	write_pmc(2, pmc_sample_period(sample_period));
>  
>  	dump_ebb_state();
>
diff mbox series

Patch

diff --git a/tools/testing/selftests/powerpc/pmu/ebb/back_to_back_ebbs_test.c b/tools/testing/selftests/powerpc/pmu/ebb/back_to_back_ebbs_test.c
index a2d7b0e3dca9..f133ab425f10 100644
--- a/tools/testing/selftests/powerpc/pmu/ebb/back_to_back_ebbs_test.c
+++ b/tools/testing/selftests/powerpc/pmu/ebb/back_to_back_ebbs_test.c
@@ -91,7 +91,7 @@  int back_to_back_ebbs(void)
 	ebb_global_disable();
 	ebb_freeze_pmcs();
 
-	count_pmc(1, sample_period);
+	write_pmc(1, pmc_sample_period(sample_period));
 
 	dump_ebb_state();
 
diff --git a/tools/testing/selftests/powerpc/pmu/ebb/cycles_test.c b/tools/testing/selftests/powerpc/pmu/ebb/cycles_test.c
index bc893813483e..14a399a64729 100644
--- a/tools/testing/selftests/powerpc/pmu/ebb/cycles_test.c
+++ b/tools/testing/selftests/powerpc/pmu/ebb/cycles_test.c
@@ -42,7 +42,7 @@  int cycles(void)
 	ebb_global_disable();
 	ebb_freeze_pmcs();
 
-	count_pmc(1, sample_period);
+	write_pmc(1, pmc_sample_period(sample_period));
 
 	dump_ebb_state();
 
diff --git a/tools/testing/selftests/powerpc/pmu/ebb/cycles_with_freeze_test.c b/tools/testing/selftests/powerpc/pmu/ebb/cycles_with_freeze_test.c
index dcd351d20328..0f2089f6f82c 100644
--- a/tools/testing/selftests/powerpc/pmu/ebb/cycles_with_freeze_test.c
+++ b/tools/testing/selftests/powerpc/pmu/ebb/cycles_with_freeze_test.c
@@ -99,7 +99,7 @@  int cycles_with_freeze(void)
 	ebb_global_disable();
 	ebb_freeze_pmcs();
 
-	count_pmc(1, sample_period);
+	write_pmc(1, pmc_sample_period(sample_period));
 
 	dump_ebb_state();
 
diff --git a/tools/testing/selftests/powerpc/pmu/ebb/cycles_with_mmcr2_test.c b/tools/testing/selftests/powerpc/pmu/ebb/cycles_with_mmcr2_test.c
index 94c99c12c0f2..a8f3bee04cd8 100644
--- a/tools/testing/selftests/powerpc/pmu/ebb/cycles_with_mmcr2_test.c
+++ b/tools/testing/selftests/powerpc/pmu/ebb/cycles_with_mmcr2_test.c
@@ -71,7 +71,7 @@  int cycles_with_mmcr2(void)
 	ebb_global_disable();
 	ebb_freeze_pmcs();
 
-	count_pmc(1, sample_period);
+	write_pmc(1, pmc_sample_period(sample_period));
 
 	dump_ebb_state();
 
diff --git a/tools/testing/selftests/powerpc/pmu/ebb/ebb.c b/tools/testing/selftests/powerpc/pmu/ebb/ebb.c
index dfbc5c3ad52d..bf6f25dfcf7b 100644
--- a/tools/testing/selftests/powerpc/pmu/ebb/ebb.c
+++ b/tools/testing/selftests/powerpc/pmu/ebb/ebb.c
@@ -396,7 +396,7 @@  int ebb_child(union pipe read_pipe, union pipe write_pipe)
 	ebb_global_disable();
 	ebb_freeze_pmcs();
 
-	count_pmc(1, sample_period);
+	write_pmc(1, pmc_sample_period(sample_period));
 
 	dump_ebb_state();
 
diff --git a/tools/testing/selftests/powerpc/pmu/ebb/ebb_on_willing_child_test.c b/tools/testing/selftests/powerpc/pmu/ebb/ebb_on_willing_child_test.c
index ca2f7d729155..513812cdcca1 100644
--- a/tools/testing/selftests/powerpc/pmu/ebb/ebb_on_willing_child_test.c
+++ b/tools/testing/selftests/powerpc/pmu/ebb/ebb_on_willing_child_test.c
@@ -38,7 +38,7 @@  static int victim_child(union pipe read_pipe, union pipe write_pipe)
 	ebb_global_disable();
 	ebb_freeze_pmcs();
 
-	count_pmc(1, sample_period);
+	write_pmc(1, pmc_sample_period(sample_period));
 
 	dump_ebb_state();
 
diff --git a/tools/testing/selftests/powerpc/pmu/ebb/lost_exception_test.c b/tools/testing/selftests/powerpc/pmu/ebb/lost_exception_test.c
index ac3e6e182614..5979606c41dc 100644
--- a/tools/testing/selftests/powerpc/pmu/ebb/lost_exception_test.c
+++ b/tools/testing/selftests/powerpc/pmu/ebb/lost_exception_test.c
@@ -75,7 +75,7 @@  static int test_body(void)
 	ebb_freeze_pmcs();
 	ebb_global_disable();
 
-	count_pmc(4, sample_period);
+	write_pmc(4, pmc_sample_period(sample_period));
 	mtspr(SPRN_PMC4, 0xdead);
 
 	dump_summary_ebb_state();
diff --git a/tools/testing/selftests/powerpc/pmu/ebb/multi_counter_test.c b/tools/testing/selftests/powerpc/pmu/ebb/multi_counter_test.c
index b8242e9d97d2..227827b665d5 100644
--- a/tools/testing/selftests/powerpc/pmu/ebb/multi_counter_test.c
+++ b/tools/testing/selftests/powerpc/pmu/ebb/multi_counter_test.c
@@ -70,12 +70,12 @@  int multi_counter(void)
 	ebb_global_disable();
 	ebb_freeze_pmcs();
 
-	count_pmc(1, sample_period);
-	count_pmc(2, sample_period);
-	count_pmc(3, sample_period);
-	count_pmc(4, sample_period);
-	count_pmc(5, sample_period);
-	count_pmc(6, sample_period);
+	write_pmc(1, pmc_sample_period(sample_period));
+	write_pmc(2, pmc_sample_period(sample_period));
+	write_pmc(3, pmc_sample_period(sample_period));
+	write_pmc(4, pmc_sample_period(sample_period));
+	write_pmc(5, pmc_sample_period(sample_period));
+	write_pmc(6, pmc_sample_period(sample_period));
 
 	dump_ebb_state();
 
diff --git a/tools/testing/selftests/powerpc/pmu/ebb/multi_ebb_procs_test.c b/tools/testing/selftests/powerpc/pmu/ebb/multi_ebb_procs_test.c
index a05c0e18ded6..ade70bed0499 100644
--- a/tools/testing/selftests/powerpc/pmu/ebb/multi_ebb_procs_test.c
+++ b/tools/testing/selftests/powerpc/pmu/ebb/multi_ebb_procs_test.c
@@ -61,7 +61,7 @@  static int cycles_child(void)
 	ebb_global_disable();
 	ebb_freeze_pmcs();
 
-	count_pmc(1, sample_period);
+	write_pmc(1, pmc_sample_period(sample_period));
 
 	dump_summary_ebb_state();
 
diff --git a/tools/testing/selftests/powerpc/pmu/ebb/pmae_handling_test.c b/tools/testing/selftests/powerpc/pmu/ebb/pmae_handling_test.c
index 153ebc92234f..7b4bf4ed12cb 100644
--- a/tools/testing/selftests/powerpc/pmu/ebb/pmae_handling_test.c
+++ b/tools/testing/selftests/powerpc/pmu/ebb/pmae_handling_test.c
@@ -82,7 +82,7 @@  static int test_body(void)
 	ebb_global_disable();
 	ebb_freeze_pmcs();
 
-	count_pmc(1, sample_period);
+	write_pmc(1, pmc_sample_period(sample_period));
 
 	dump_ebb_state();
 
diff --git a/tools/testing/selftests/powerpc/pmu/ebb/pmc56_overflow_test.c b/tools/testing/selftests/powerpc/pmu/ebb/pmc56_overflow_test.c
index eadad75ed7e6..bb55af71404d 100644
--- a/tools/testing/selftests/powerpc/pmu/ebb/pmc56_overflow_test.c
+++ b/tools/testing/selftests/powerpc/pmu/ebb/pmc56_overflow_test.c
@@ -76,7 +76,7 @@  int pmc56_overflow(void)
 	ebb_global_disable();
 	ebb_freeze_pmcs();
 
-	count_pmc(2, sample_period);
+	write_pmc(2, pmc_sample_period(sample_period));
 
 	dump_ebb_state();