selftests/powerpc: A few fixes on powerpc selftests
cover selftests/powerpc: A few fixes on powerpc selftests
This patchseries addresses a few fixes on powerpc selftests (first and second patch are being resent).
The first fix has to do with the extra counts on PMCs resets, which not only are shown on the trace_logs, but can also invalidate the results of a few selftests. On the other hand, the second fix proper addresses the Per- formance Monitor Alert (PMAE) bit on MMCR0 when freezing counters are dis- abled on cycles_with_freeze_test selftest. Lastly, the third fix adds a memory barrier on count_pmc() to ensure read consistency of PMCs. This is necessary since these values are usually accounted on ebb_handlers to val- lidade tests results, such as the overflow values on pmc56_overflow_test.
Desnes A. Nunes do Rosario (2):
selftests/powerpc: Use write_pmc instead of count_pmc to reset PMCs on
ebb tests
selftests/powerpc: ensure PMC reads are set and ordered on count_pmc
Gustavo Romero (1):
selftests/powerpc: enable performance alerts when freezing counters on
cycles_with_freeze_test selftest
.../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 | 4 ++-- .../powerpc/pmu/ebb/cycles_with_mmcr2_test.c | 2 +- tools/testing/selftests/powerpc/pmu/ebb/ebb.c | 6 +++++- .../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, 21 insertions(+), 17 deletions(-)
Signature · 1 line
2.21.1
PATCH RESEND 1/3 selftests/powerpc: Use write_pmc instead of count_pmc to reset PMCs on ebb tests
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
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
==========
--- .../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(-)
tools/testing/selftests/powerpc/pmu/ebb/back_to_back_ebbs_test.c +1 -1
@@ -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 ();
tools/testing/selftests/powerpc/pmu/ebb/cycles_test.c +1 -1
@@ -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 ();
tools/testing/selftests/powerpc/pmu/ebb/cycles_with_freeze_test.c +1 -1
@@ -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 ();
tools/testing/selftests/powerpc/pmu/ebb/cycles_with_mmcr2_test.c +1 -1
@@ -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 ();
tools/testing/selftests/powerpc/pmu/ebb/ebb.c +1 -1
@@ -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 ();
tools/testing/selftests/powerpc/pmu/ebb/ebb_on_willing_child_test.c +1 -1
@@ -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 ();
tools/testing/selftests/powerpc/pmu/ebb/lost_exception_test.c +1 -1
@@ -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 ();
tools/testing/selftests/powerpc/pmu/ebb/multi_counter_test.c +6 -6
@@ -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 ();
tools/testing/selftests/powerpc/pmu/ebb/multi_ebb_procs_test.c +1 -1
@@ -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 ();
tools/testing/selftests/powerpc/pmu/ebb/pmae_handling_test.c +1 -1
@@ -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 ();
tools/testing/selftests/powerpc/pmu/ebb/pmc56_overflow_test.c +1 -1
@@ -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 ();
Signature · 1 line
2.21.1
Re: [PATCH, RESEND, 1/3] selftests/powerpc: Use write_pmc instead of count_pmc to reset PMCs on ebb tests
Quoted 23 lines · Desnes A. Nunes do Rosario
By using
count_pmc()to reset PMCs instead ofwrite_pmc(), an extra count
is performed on ebb_state.stats.pmc_count[PMC_INDEX(pmc)]. This extrapmc_countcan occasionally invalidate results, such as the ones fromcycles_testshown hereafter. Theebb_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_logon
the output of the cycle test (as well as onpmc56_overflow_test):==========
...
[21]: counter = 8
[22]: registerSPRN_MMCR0=0x0000000080000080
[23]: registerSPRN_PMC1=0x0000000080000004
[24]: counter = 9
[25]: registerSPRN_MMCR0=0x0000000080000080
[26]: registerSPRN_PMC1=0x0000000080000004
[27]: counter = 10
[28]: registerSPRN_MMCR0=0x0000000080000080
[29]: registerSPRN_PMC1=0x0000000080000004
Quoted 8 lines
Quoted 1 line
Quoted 1 line
[30]: register
SPRN_PMC1=0x000000004000051ePMC1 count (
0x280000546) above upper limit0x2800003e8(+0x15e) [FAIL] Test FAILED on line 52
failure: cycles
==========[desnesn: reflow of original comment]Signed-off-by Desnes A. Nunes do Rosario <[email protected]>
Reviewed and Tested-by: Rashmica Gupta <[email protected]>
Quoted 198 lines
--- .../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.cb/tools/testing/selftests/powerpc/pmu/ebb/back_to_back_ebbs_test.cindexa2d7b0e3dca9..f133ab425f10100644
---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.ctools/testing/selftests/powerpc/pmu/ebb/back_to_back_ebbs_test.c +1
-1@@ -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 ();tools/testing/selftests/powerpc/pmu/ebb/cycles_test.c +1
-1@@ -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.cb/tools/testing/selftests/powerpc/pmu/ebb/cycles_with_freeze_test.cindexdcd351d20328..0f2089f6f82c100644
---a/tools/testing/selftests/powerpc/pmu/ebb/cycles_with_freeze_test.c
+++b/tools/testing/selftests/powerpc/pmu/ebb/cycles_with_freeze_test.ctools/testing/selftests/powerpc/pmu/ebb/cycles_test.c +1
-1@@ -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.cb/tools/testing/selftests/powerpc/pmu/ebb/cycles_with_mmcr2_test.cindex94c99c12c0f2..a8f3bee04cd8100644
---a/tools/testing/selftests/powerpc/pmu/ebb/cycles_with_mmcr2_test.c
+++b/tools/testing/selftests/powerpc/pmu/ebb/cycles_with_mmcr2_test.ctools/testing/selftests/powerpc/pmu/ebb/cycles_test.c +1
-1@@ -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 ();tools/testing/selftests/powerpc/pmu/ebb/ebb.c +1
-1@@ -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.cb/tools/testing/selftests/powerpc/pmu/ebb/ebb_on_willing_child_test.cindexca2f7d729155..513812cdcca1100644
---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.ctools/testing/selftests/powerpc/pmu/ebb/ebb.c +1
-1@@ -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.cb/tools/testing/selftests/powerpc/pmu/ebb/lost_exception_test.cindexac3e6e182614..5979606c41dc100644tools/testing/selftests/powerpc/pmu/ebb/lost_exception_test.c +1
-1@@ -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.cb/tools/testing/selftests/powerpc/pmu/ebb/multi_counter_test.cindexb8242e9d97d2..227827b665d5100644tools/testing/selftests/powerpc/pmu/ebb/multi_counter_test.c +6
-6@@ -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.cb/tools/testing/selftests/powerpc/pmu/ebb/multi_ebb_procs_test.cindexa05c0e18ded6..ade70bed0499100644tools/testing/selftests/powerpc/pmu/ebb/multi_ebb_procs_test.c +1
-1@@ -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.cb/tools/testing/selftests/powerpc/pmu/ebb/pmae_handling_test.cindex153ebc92234f..7b4bf4ed12cb100644tools/testing/selftests/powerpc/pmu/ebb/pmae_handling_test.c +1
-1@@ -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.cb/tools/testing/selftests/powerpc/pmu/ebb/pmc56_overflow_test.cindexeadad75ed7e6..bb55af71404d100644tools/testing/selftests/powerpc/pmu/ebb/pmc56_overflow_test.c +1
-1@@ -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 ();
PATCH RESEND 2/3 selftests/powerpc: enable performance alerts when freezing counters on cycles_with_freeze_test selftest
In reply to Desnes A. Nunes do RosarioFrom: Gustavo Romero <[email protected]>
When disabling freezing counters by setting MMCR0 FC bit to 0, the MMCR0 PMAE bit must also be enabled if a Performance Monitor Alert (and the cor- responding Performance Monitor Interrupt) is still desired to be received when an enabled condition or event occurs.
This is the case of the cycles_with_freeze_test selftest, since the test disables the MMCR0 PMAE due to the usage of PMU to trigger EBBs. This can make the test loop up to the point of being killed by the test harness timeout (2500 ms), since no other ebb event will happen because the MMCR0 PMAE bit is disabled, and thus, no more increments to ebb_count occur.
--- .../testing/selftests/powerpc/pmu/ebb/cycles_with_freeze_test.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
tools/testing/selftests/powerpc/pmu/ebb/cycles_with_freeze_test.c +1 -1
@@ -81,7 +81,7 @@ int cycles_with_freeze(void) { counters_frozen = false;mb (); -mtspr (SPRN_MMCR0 ,mfspr (SPRN_MMCR0 ) & ~MMCR0_FC ); +mtspr (SPRN_MMCR0 , (mfspr (SPRN_MMCR0 ) & ~MMCR0_FC ) |MMCR0_PMAE );FAIL_IF (core_busy_loop ());
Signature · 1 line
2.21.1
Re: [PATCH, RESEND, 2/3] selftests/powerpc: enable performance alerts when freezing counters on cycles_with_freeze_test selftest
Quoted 21 lines · Desnes A. Nunes do Rosario
From: Gustavo Romero <[email protected]>
When disabling freezing counters by setting MMCR0 FC bit to 0, the MMCR0
PMAE bit must also be enabled if a Performance Monitor Alert (and the cor-
responding Performance Monitor Interrupt) is still desired to be received
when an enabled condition or event occurs.This is the case of the
cycles_with_freeze_testselftest, since the test
disables the MMCR0 PMAE due to the usage of PMU to trigger EBBs. This can
make the test loop up to the point of being killed by the test harness
timeout (2500 ms), since no other ebb event will happen because the MMCR0
PMAE bit is disabled, and thus, no more increments toebb_countoccur.
Quoted 5 lines
Fixes 3752e453f6bafd7 ("selftests/powerpc: Add tests of PMU EBBs")Signed-off-by Gustavo Romero <[email protected]>[desnesn: Only set
MMCR0_PMAEwhen disablingMMCR0_FC, reflow comment]Signed-off-by Desnes A. Nunes do Rosario <[email protected]>
Reviewed and Tested-by: Rashmica Gupta <[email protected]>
Quoted 23 lines
--- .../testing/selftests/powerpc/pmu/ebb/cycles_with_freeze_test.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)diff --git
a/tools/testing/selftests/powerpc/pmu/ebb/cycles_with_freeze_test.cb/tools/testing/selftests/powerpc/pmu/ebb/cycles_with_freeze_test.cindex0f2089f6f82c..d368199144fb100644
---a/tools/testing/selftests/powerpc/pmu/ebb/cycles_with_freeze_test.c
+++b/tools/testing/selftests/powerpc/pmu/ebb/cycles_with_freeze_test.ctools/testing/selftests/powerpc/pmu/ebb/cycles_with_freeze_test.c +1
-1@@ -81,7 +81,7 @@ int cycles_with_freeze(void) { counters_frozen = false;mb (); -mtspr (SPRN_MMCR0 ,mfspr (SPRN_MMCR0 ) & ~MMCR0_FC ); +mtspr (SPRN_MMCR0 , (mfspr (SPRN_MMCR0 ) & ~MMCR0_FC ) |MMCR0_PMAE );FAIL_IF (core_busy_loop ());
PATCH 3/3 selftests/powerpc: ensure PMC reads are set and ordered on count_pmc
In reply to Desnes A. Nunes do RosarioFunction 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:
...
Quoted 2 lines
Quoted 2 lines
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
Quoted 2 lines
Quoted 2 lines
[10]: register
SPRN_PMC5=0x000000006e2b961f[11]: registerSPRN_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
=========
--- tools/testing/selftests/powerpc/pmu/ebb/ebb.c | 4 ++++ 1 file changed, 4 insertions(+)
tools/testing/selftests/powerpc/pmu/ebb/ebb.c +4 -0
@@ -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
Signature · 1 line
2.21.1
Re: [PATCH 3/3] selftests/powerpc: ensure PMC reads are set and ordered on count_pmc
Quoted 39 lines · Desnes A. Nunes do Rosario
Function
count_pmc()needs a memory barrier to ensure that PMC reads are
fully consistent. The lack of it can occasionally failpmc56_overflowtest,
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:
...Quoted 2 lines
Quoted 2 lines
pmc[5] count =
0xfd4cbc8c
pmc[6] count =0xddd8b3b6HW state:
MMCR00x0000000084000000FC PMAE
MMCR20x0000000000000000
EBBHR0x0000000010003f68
BESCR0x8000000000000000GE
...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 = 0x0000000080000003Quoted 2 lines
Quoted 2 lines
[7]: register
SPRN_PMC5=0x000000008f21266d[8]: registerSPRN_PMC6=0x000000000da80f8d[9]: register
SPRN_PMC2=0x0000000080000003Quoted 2 lines
Quoted 2 lines
[10]: register
SPRN_PMC5=0x000000006e2b961f[11]: registerSPRN_PMC6=0x00000000d030a429[12]: register SPRN_PMC2 = 0x0000000080000003 [13]: register SPRN_PMC5 = 0x0000000000000000 [14]: register SPRN_PMC6 = 0x0000000000000000
Quoted 7 lines
...
PMC5/6 overflow 2
[FAIL] Test FAILED on line 87
failure:pmc56_overflow
=========Signed-off-by Desnes A. Nunes do Rosario <[email protected]>
Quoted 20 lines
--- tools/testing/selftests/powerpc/pmu/ebb/ebb.c | 4 ++++ 1 file changed, 4 insertions(+)tools/testing/selftests/powerpc/pmu/ebb/ebb.c +4
-0@@ -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