perf tests: Fix Convert perf time to TSC test for hybrid
Adrian Hunter
reviewercover perf tests: Fix Convert perf time to TSC test for hybrid
Hi
Here are a couple more minor non-urgent fixes.
Adrian Hunter (2):
perf tests: Stop Convert perf time to TSC test opening events twice perf tests: Fix Convert perf time to TSC test for hybrid
tools/perf/tests/perf-time-to-tsc.c | 27 ++++++++++----------------- 1 file changed, 10 insertions(+), 17 deletions(-)
Regards
Adrian
Adrian Hunter
reviewerPATCH 1/2 perf tests: Stop Convert perf time to TSC test opening events twice
Do not call evlist__open() twice.
--- tools/perf/tests/perf-time-to-tsc.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-)
tools/perf/tests/perf-time-to-tsc.c +6 -3
@@ -123,11 +123,14 @@ static int test__perf_time_to_tsc(struct test_suite *test __maybe_unused, int su evsel->core.attr.enable_on_exec =0 ; } -if (evlist__open (evlist) == -ENOENT ) { - err =TEST_SKIP ; + ret =evlist__open (evlist); +if (ret <0 ) { +if (ret == -ENOENT ) + err =TEST_SKIP ; +else +pr_debug ("evlist__open() failed\n" ); goto out_err; } -CHECK__ (evlist__open (evlist));CHECK__ (evlist__mmap (evlist,UINT_MAX ));
Signature · 1 line
2.25.1
Re: [PATCH 1/2] perf tests: Stop Convert perf time to TSC test opening events twice
Quoted 13 lines · Adrian Hunter
Do not call
evlist__open()twice.Fixes 5bb017d4b97a ("perf test: Fix error message for test case 71 on s390, where it is not supported")Signed-off-by Adrian Hunter <[email protected]>> ---tools/perf/tests/perf-time-to-tsc.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-)tools/perf/tests/perf-time-to-tsc.c +0
-0@@ -123,11 +123,14 @@ static int test__perf_time_to_tsc(struct test_suite *test __maybe_unused, int su evsel->core.attr.enable_on_exec =0 ;
tools/perf/tests/perf-time-to-tsc.c static int test__perf_time_to_tsc(struct test_suite *test __maybe_unused, int su · line 131
Quoted 10 lines
tools/perf/tests/perf-time-to-tsc.c +6
-2} -if (evlist__open (evlist) == -ENOENT ) { - err =TEST_SKIP ; + ret =evlist__open (evlist); +if (ret <0 ) { +if (ret == -ENOENT ) + err =TEST_SKIP ; +else +pr_debug ("evlist__open() failed\n" );
The error message for the evlist__open is slightly different with the old one, "evlist__open(evlist) failed!". Not sure if anyone care about it.
Thanks,
Kan
Quoted 6 lines
tools/perf/tests/perf-time-to-tsc.c +0
-1goto out_err; } -CHECK__ (evlist__open (evlist));CHECK__ (evlist__mmap (evlist,UINT_MAX ));
Adrian Hunter
reviewerPATCH 2/2 perf tests: Fix Convert perf time to TSC test for hybrid
In reply to Adrian HunterThe test does not always correctly determine the number of events for hybrids, nor allow for more than 1 evsel when parsing.
Fix by iterating the events actually created and getting the correct evsel for the events processed.
--- tools/perf/tests/perf-time-to-tsc.c | 18 ++++-------------- 1 file changed, 4 insertions(+), 14 deletions(-)
tools/perf/tests/perf-time-to-tsc.c +4 -14
@@ -20,8 +20,6 @@#include "tsc.h" #include "mmap.h" #include "tests.h" -#include "pmu.h" -#include "pmu-hybrid.h" /* * Except x86_64/i386 and Arm64, other archs don't support TSC in perf. Just
@@ -106,18 +104,8 @@ static int test__perf_time_to_tsc(struct test_suite *test __maybe_unused, int suevlist__config (evlist, &opts,NULL ); - evsel =evlist__first (evlist); - - evsel->core.attr.comm =1 ; - evsel->core.attr.disabled =1 ; - evsel->core.attr.enable_on_exec =0 ; - -/* -* For hybrid "cycles:u", it creates two events. -* Init the second evsel here. -*/ -if (perf_pmu__has_hybrid () &&perf_pmu__hybrid_mounted ("cpu_atom" )) { - evsel =evsel__next (evsel); +/* For hybrid "cycles:u", it creates two events */ +evlist__for_each_entry (evlist, evsel) { evsel->core.attr.comm =1 ; evsel->core.attr.disabled =1 ; evsel->core.attr.enable_on_exec =0 ;
@@ -170,10 +158,12 @@ static int test__perf_time_to_tsc(struct test_suite *test __maybe_unused, int su goto next_event;if (strcmp (event->comm.comm, comm1) ==0 ) { +CHECK_NOT_NULL__ (evsel =evlist__event2evsel (evlist, event));CHECK__ (evsel__parse_sample (evsel, event, &sample)); comm1_time = sample.time; }if (strcmp (event->comm.comm, comm2) ==0 ) { +CHECK_NOT_NULL__ (evsel =evlist__event2evsel (evlist, event));CHECK__ (evsel__parse_sample (evsel, event, &sample)); comm2_time = sample.time; }
Signature · 1 line
2.25.1
Quoted 6 lines · Adrian Hunter
The test does not always correctly determine the number of events for hybrids, nor allow for more than 1 evsel when parsing.
Fix by iterating the events actually created and getting the correct evsel for the events processed.
Yes, we cannot always assume there are two events for hybrid.
Quoted 2 lines
Fixes d9da6f70eb23 ("perf tests: Support 'Convert perf time to TSC' test for hybrid")Signed-off-by Adrian Hunter <[email protected]>
Thanks,
Kan
Quoted 51 lines
--- tools/perf/tests/perf-time-to-tsc.c | 18 ++++-------------- 1 file changed, 4 insertions(+), 14 deletions(-)tools/perf/tests/perf-time-to-tsc.c +4
-14@@ -20,8 +20,6 @@#include "tsc.h" #include "mmap.h" #include "tests.h" -#include "pmu.h" -#include "pmu-hybrid.h" /* * Except x86_64/i386 and Arm64, other archs don't support TSC in perf. Just @@ -106,18 +104,8 @@ static int test__perf_time_to_tsc(struct test_suite *test __maybe_unused, int suevlist__config (evlist, &opts,NULL ); - evsel =evlist__first (evlist); - - evsel->core.attr.comm =1 ; - evsel->core.attr.disabled =1 ; - evsel->core.attr.enable_on_exec =0 ; - -/* -* For hybrid "cycles:u", it creates two events. -* Init the second evsel here. -*/ -if (perf_pmu__has_hybrid () &&perf_pmu__hybrid_mounted ("cpu_atom" )) { - evsel =evsel__next (evsel); +/* For hybrid "cycles:u", it creates two events */ +evlist__for_each_entry (evlist, evsel) { evsel->core.attr.comm =1 ; evsel->core.attr.disabled =1 ; evsel->core.attr.enable_on_exec =0 ;@@ -170,10 +158,12 @@ static int test__perf_time_to_tsc(struct test_suite *test __maybe_unused, int su goto next_event;if (strcmp (event->comm.comm, comm1) ==0 ) { +CHECK_NOT_NULL__ (evsel =evlist__event2evsel (evlist, event));CHECK__ (evsel__parse_sample (evsel, event, &sample)); comm1_time = sample.time; }if (strcmp (event->comm.comm, comm2) ==0 ) { +CHECK_NOT_NULL__ (evsel =evlist__event2evsel (evlist, event));CHECK__ (evsel__parse_sample (evsel, event, &sample)); comm2_time = sample.time; }
Em Wed, Jul 13, 2022 at 09:05:21AM -0400, Liang, Kan escreveu:
Quoted 10 lines · Adrian Hunter
Quoted 6 lines
The test does not always correctly determine the number of events for hybrids, nor allow for more than 1 evsel when parsing.
Fix by iterating the events actually created and getting the correct evsel for the events processed.
Quoted 7 lines
Yes, we cannot always assume there are two events for hybrid.
Quoted 2 lines
Fixes d9da6f70eb23 ("perf tests: Support 'Convert perf time to TSC' test for hybrid")Signed-off-by Adrian Hunter <[email protected]>Reviewed-by Kan Liang <[email protected]>
Thanks, applied.
- Arnaldo
Quoted 53 lines
Thanks,
KanQuoted 51 lines
--- tools/perf/tests/perf-time-to-tsc.c | 18 ++++-------------- 1 file changed, 4 insertions(+), 14 deletions(-)tools/perf/tests/perf-time-to-tsc.c +4
-14@@ -20,8 +20,6 @@#include "tsc.h" #include "mmap.h" #include "tests.h" -#include "pmu.h" -#include "pmu-hybrid.h" /* * Except x86_64/i386 and Arm64, other archs don't support TSC in perf. Just @@ -106,18 +104,8 @@ static int test__perf_time_to_tsc(struct test_suite *test __maybe_unused, int suevlist__config (evlist, &opts,NULL ); - evsel =evlist__first (evlist); - - evsel->core.attr.comm =1 ; - evsel->core.attr.disabled =1 ; - evsel->core.attr.enable_on_exec =0 ; - -/* -* For hybrid "cycles:u", it creates two events. -* Init the second evsel here. -*/ -if (perf_pmu__has_hybrid () &&perf_pmu__hybrid_mounted ("cpu_atom" )) { - evsel =evsel__next (evsel); +/* For hybrid "cycles:u", it creates two events */ +evlist__for_each_entry (evlist, evsel) { evsel->core.attr.comm =1 ; evsel->core.attr.disabled =1 ; evsel->core.attr.enable_on_exec =0 ;@@ -170,10 +158,12 @@ static int test__perf_time_to_tsc(struct test_suite *test __maybe_unused, int su goto next_event;if (strcmp (event->comm.comm, comm1) ==0 ) { +CHECK_NOT_NULL__ (evsel =evlist__event2evsel (evlist, event));CHECK__ (evsel__parse_sample (evsel, event, &sample)); comm1_time = sample.time; }if (strcmp (event->comm.comm, comm2) ==0 ) { +CHECK_NOT_NULL__ (evsel =evlist__event2evsel (evlist, event));CHECK__ (evsel__parse_sample (evsel, event, &sample)); comm2_time = sample.time; }
Signature · 1 line
- Arnaldo