Skip to contentSkip to conversation

selftests/powerpc: Purge extra count_pmc() calls of ebb selftests

PATCH Applied Desnes A. Nunes do Rosario 3 participants 4 messages Jun 26, 2020 – Jul 16, 2020

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 selftests/powerpc: Purge extra count_pmc() calls of ebb selftests

An extra count on ebb_state.stats.pmc_count[PMC_INDEX(pmc)] is being per- formed when count_pmc() is used to reset PMCs on a few selftests. 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 value on 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

Quoted 1 line
Quoted 1 line

[30]: register SPRN_PMC1 = 0x000000004000051e

PMC1 count (0x280000546) above upper limit 0x2800003e8 (+0x15e) [FAIL] Test FAILED on line 52
failure: cycles
==========

---
 .../selftests/powerpc/pmu/ebb/back_to_back_ebbs_test.c     | 2 --
 tools/testing/selftests/powerpc/pmu/ebb/cycles_test.c      | 2 --
 .../selftests/powerpc/pmu/ebb/cycles_with_freeze_test.c    | 2 --
 .../selftests/powerpc/pmu/ebb/cycles_with_mmcr2_test.c     | 2 --
 tools/testing/selftests/powerpc/pmu/ebb/ebb.c              | 2 --
 .../selftests/powerpc/pmu/ebb/ebb_on_willing_child_test.c  | 2 --
 .../selftests/powerpc/pmu/ebb/lost_exception_test.c        | 1 -
 .../testing/selftests/powerpc/pmu/ebb/multi_counter_test.c | 7 -------
 .../selftests/powerpc/pmu/ebb/multi_ebb_procs_test.c       | 2 --
 .../testing/selftests/powerpc/pmu/ebb/pmae_handling_test.c | 2 --
 .../selftests/powerpc/pmu/ebb/pmc56_overflow_test.c        | 2 --
 11 files changed, 26 deletions(-)
tools/testing/selftests/powerpc/pmu/ebb/back_to_back_ebbs_test.c +0 -2
index a2d7b0e3dca9..a26ac122c759 100644
@@ -91,8 +91,6 @@ int back_to_back_ebbs(void)
 	ebb_global_disable();
 	ebb_freeze_pmcs();
 
-	count_pmc(1, sample_period);
-
 	dump_ebb_state();
 
 	event_close(&event);
tools/testing/selftests/powerpc/pmu/ebb/cycles_test.c +0 -2
index bc893813483e..bb9f587fa76e 100644
@@ -42,8 +42,6 @@ int cycles(void)
 	ebb_global_disable();
 	ebb_freeze_pmcs();
 
-	count_pmc(1, sample_period);
-
 	dump_ebb_state();
 
 	event_close(&event);
tools/testing/selftests/powerpc/pmu/ebb/cycles_with_freeze_test.c +0 -2
index dcd351d20328..9ae795ce314e 100644
@@ -99,8 +99,6 @@ int cycles_with_freeze(void)
 	ebb_global_disable();
 	ebb_freeze_pmcs();
 
-	count_pmc(1, sample_period);
-
 	dump_ebb_state();
 
 	printf("EBBs while frozen %d\n", ebbs_while_frozen);
tools/testing/selftests/powerpc/pmu/ebb/cycles_with_mmcr2_test.c +0 -2
index 94c99c12c0f2..4b45a2e70f62 100644
@@ -71,8 +71,6 @@ int cycles_with_mmcr2(void)
 	ebb_global_disable();
 	ebb_freeze_pmcs();
 
-	count_pmc(1, sample_period);
-
 	dump_ebb_state();
 
 	event_close(&event);
tools/testing/selftests/powerpc/pmu/ebb/ebb.c +0 -2
index dfbc5c3ad52d..21537d6eb6b7 100644
@@ -396,8 +396,6 @@ int ebb_child(union pipe read_pipe, union pipe write_pipe)
 	ebb_global_disable();
 	ebb_freeze_pmcs();
 
-	count_pmc(1, sample_period);
-
 	dump_ebb_state();
 
 	event_close(&event);
tools/testing/selftests/powerpc/pmu/ebb/ebb_on_willing_child_test.c +0 -2
index ca2f7d729155..b208bf6ad58d 100644
@@ -38,8 +38,6 @@ static int victim_child(union pipe read_pipe, union pipe write_pipe)
 	ebb_global_disable();
 	ebb_freeze_pmcs();
 
-	count_pmc(1, sample_period);
-
 	dump_ebb_state();
 
 	FAIL_IF(ebb_state.stats.ebb_count == 0);
tools/testing/selftests/powerpc/pmu/ebb/lost_exception_test.c +0 -1
index ac3e6e182614..ba2681a12cc7 100644
@@ -75,7 +75,6 @@ static int test_body(void)
 	ebb_freeze_pmcs();
 	ebb_global_disable();
 
-	count_pmc(4, sample_period);
 	mtspr(SPRN_PMC4, 0xdead);
 
 	dump_summary_ebb_state();
tools/testing/selftests/powerpc/pmu/ebb/multi_counter_test.c +0 -7
index b8242e9d97d2..791d37ba327b 100644
@@ -70,13 +70,6 @@ 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);
-
 	dump_ebb_state();
 
 	for (i = 0; i < 6; i++)
tools/testing/selftests/powerpc/pmu/ebb/multi_ebb_procs_test.c +0 -2
index a05c0e18ded6..9b0f70d59702 100644
@@ -61,8 +61,6 @@ static int cycles_child(void)
 	ebb_global_disable();
 	ebb_freeze_pmcs();
 
-	count_pmc(1, sample_period);
-
 	dump_summary_ebb_state();
 
 	event_close(&event);
tools/testing/selftests/powerpc/pmu/ebb/pmae_handling_test.c +0 -2
index 153ebc92234f..2904c741e04e 100644
@@ -82,8 +82,6 @@ static int test_body(void)
 	ebb_global_disable();
 	ebb_freeze_pmcs();
 
-	count_pmc(1, sample_period);
-
 	dump_ebb_state();
 
 	if (mmcr0_mismatch)
tools/testing/selftests/powerpc/pmu/ebb/pmc56_overflow_test.c +0 -2
index eadad75ed7e6..b29f8ba22d1e 100644
@@ -76,8 +76,6 @@ int pmc56_overflow(void)
 	ebb_global_disable();
 	ebb_freeze_pmcs();
 
-	count_pmc(2, sample_period);
-
 	dump_ebb_state();
 
 	printf("PMC5/6 overflow %d\n", pmc56_overflowed);
Signature · 1 line
2.21.3
#1 lore raw
Quoted 24 lines · Desnes A. Nunes do Rosario

An extra count on ebb_state.stats.pmc_count[PMC_INDEX(pmc)] is being per- formed when count_pmc() is used to reset PMCs on a few selftests. 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 value on 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

Quoted 8 lines
Quoted 1 line
Quoted 1 line

[30]: register SPRN_PMC1 = 0x000000004000051e

PMC1 count (0x280000546) above upper limit 0x2800003e8 (+0x15e) [FAIL] Test FAILED on line 52
failure: cycles
==========

---

I too have run into similar failure with cycles_test. I will add that the failure is inconsistent. I have run into this issue 1 out of 25 times. The failure always happen at first instance. Subsequent tries work correctly.

With this patch applied the test completes successfully 25 out of 25 times.

# ./cycles_test 
test: cycles
…..
…..
  [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  = 0x000000004000048f
PMC1 count (0x2800004b7) above upper limit 0x2800003e8 (+0xcf)
[FAIL] Test FAILED on line 52
failure: cycles

With the patch

# ./cycles_test 
test: cycles
…..
…..
  [25]: register SPRN_MMCR0 = 0x0000000080000080
  [26]: register SPRN_PMC1  = 0x0000000080000004
  [27]: counter = 10
  [28]: register SPRN_MMCR0 = 0x0000000080000080
  [29]: register SPRN_PMC1  = 0x0000000080000004
PMC1 count (0x280000028) is between 0x27ffffc18 and 0x2800003e8 delta +0x410/-0x3c0
success: cycles
# 

FWIW Tested-by : Sachin Sant <[email protected]>

Thanks
-Sachin

#2 lore raw
Quoted 29 lines · Sachin Sant
Quoted 29 lines · Desnes A. Nunes do Rosario

An extra count on ebb_state.stats.pmc_count[PMC_INDEX(pmc)] is being per- formed when count_pmc() is used to reset PMCs on a few selftests. 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 value on 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

Quoted 1 line
Quoted 1 line

[30]: register SPRN_PMC1 = 0x000000004000051e

PMC1 count (0x280000546) above upper limit 0x2800003e8 (+0x15e) [FAIL] Test FAILED on line 52
failure: cycles
==========

Quoted 5 lines
Quoted 2 lines

---

I too have run into similar failure with cycles_test. I will add that the failure is inconsistent. I have run into this issue 1 out of 25 times. The failure always happen at first instance. Subsequent tries work correctly.

Indeed; on my tests I was running 100 times to validate. Thanks for the review Sachin

Quoted 36 lines

With this patch applied the test completes successfully 25 out of 25 times.

# ./cycles_test
test: cycles
…..
…..
   [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  = 0x000000004000048f
PMC1 count (0x2800004b7) above upper limit 0x2800003e8 (+0xcf)
[FAIL] Test FAILED on line 52
failure: cycles

With the patch

# ./cycles_test
test: cycles
…..
…..
   [25]: register SPRN_MMCR0 = 0x0000000080000080
   [26]: register SPRN_PMC1  = 0x0000000080000004
   [27]: counter = 10
   [28]: register SPRN_MMCR0 = 0x0000000080000080
   [29]: register SPRN_PMC1  = 0x0000000080000004
PMC1 count (0x280000028) is between 0x27ffffc18 and 0x2800003e8 delta +0x410/-0x3c0
success: cycles
#

FWIW Tested-by : Sachin Sant <[email protected]>

Thanks
-Sachin

Signature · 4 lines
Desnes A. Nunes do Rosario
--------------------------------
Advisory Software Engineer - IBM
Virtual Onsite Engineer - Red Hat
#3 lore raw
In reply to Desnes A. Nunes do Rosario
Quoted 10 lines · Desnes A. Nunes do Rosario

An extra count on ebb_state.stats.pmc_count[PMC_INDEX(pmc)] is being per- formed when count_pmc() is used to reset PMCs on a few selftests. 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 value on 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):

[...]

Applied to powerpc/next.

[1/1] selftests/powerpc: Purge extra count_pmc() calls of ebb selftests

      https://git.kernel.org/powerpc/c/3337bf41e0dd70b4064cdf60acdfcdc2d050066c

cheers