[v4,24/25] perf tests: Support 'Convert perf time to TSC' test for hybrid
diff mbox series

Message ID 20210416140517.18206-25-yao.jin@linux.intel.com
State New
Headers show
Series
  • perf tool: AlderLake hybrid support series 1
Related show

Commit Message

Jin Yao April 16, 2021, 2:05 p.m. UTC
Since for "cycles:u' on hybrid platform, it creates two "cycles".
So the second evsel in evlist also needs initialization.

With this patch,

  # ./perf test 71
  71: Convert perf time to TSC                                        : Ok

Signed-off-by: Jin Yao <yao.jin@linux.intel.com>
---
 tools/perf/tests/perf-time-to-tsc.c | 16 ++++++++++++++++
 1 file changed, 16 insertions(+)

Comments

Jiri Olsa April 21, 2021, 6:29 p.m. UTC | #1
On Fri, Apr 16, 2021 at 10:05:16PM +0800, Jin Yao wrote:
> Since for "cycles:u' on hybrid platform, it creates two "cycles".
> So the second evsel in evlist also needs initialization.
> 
> With this patch,
> 
>   # ./perf test 71
>   71: Convert perf time to TSC                                        : Ok
> 
> Signed-off-by: Jin Yao <yao.jin@linux.intel.com>
> ---
>  tools/perf/tests/perf-time-to-tsc.c | 16 ++++++++++++++++
>  1 file changed, 16 insertions(+)
> 
> diff --git a/tools/perf/tests/perf-time-to-tsc.c b/tools/perf/tests/perf-time-to-tsc.c
> index 680c3cffb128..72f268c6cc5d 100644
> --- a/tools/perf/tests/perf-time-to-tsc.c
> +++ b/tools/perf/tests/perf-time-to-tsc.c
> @@ -20,6 +20,7 @@
>  #include "tsc.h"
>  #include "mmap.h"
>  #include "tests.h"
> +#include "pmu.h"
>  
>  #define CHECK__(x) {				\
>  	while ((x) < 0) {			\
> @@ -66,6 +67,10 @@ int test__perf_time_to_tsc(struct test *test __maybe_unused, int subtest __maybe
>  	u64 test_tsc, comm1_tsc, comm2_tsc;
>  	u64 test_time, comm1_time = 0, comm2_time = 0;
>  	struct mmap *md;
> +	bool hybrid = false;
> +
> +	if (perf_pmu__has_hybrid())
> +		hybrid = true;
>  
>  	threads = thread_map__new(-1, getpid(), UINT_MAX);
>  	CHECK_NOT_NULL__(threads);
> @@ -88,6 +93,17 @@ int test__perf_time_to_tsc(struct test *test __maybe_unused, int subtest __maybe
>  	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 (hybrid) {

same, don't see the reason for 'hybrid' variable

jirka

> +		evsel = evsel__next(evsel);
> +		evsel->core.attr.comm = 1;
> +		evsel->core.attr.disabled = 1;
> +		evsel->core.attr.enable_on_exec = 0;
> +	}
> +
>  	CHECK__(evlist__open(evlist));
>  
>  	CHECK__(evlist__mmap(evlist, UINT_MAX));
> -- 
> 2.17.1
>
Jin Yao April 22, 2021, 3:16 a.m. UTC | #2
Hi Jiri,

On 4/22/2021 2:29 AM, Jiri Olsa wrote:
> On Fri, Apr 16, 2021 at 10:05:16PM +0800, Jin Yao wrote:
>> Since for "cycles:u' on hybrid platform, it creates two "cycles".
>> So the second evsel in evlist also needs initialization.
>>
>> With this patch,
>>
>>    # ./perf test 71
>>    71: Convert perf time to TSC                                        : Ok
>>
>> Signed-off-by: Jin Yao <yao.jin@linux.intel.com>
>> ---
>>   tools/perf/tests/perf-time-to-tsc.c | 16 ++++++++++++++++
>>   1 file changed, 16 insertions(+)
>>
>> diff --git a/tools/perf/tests/perf-time-to-tsc.c b/tools/perf/tests/perf-time-to-tsc.c
>> index 680c3cffb128..72f268c6cc5d 100644
>> --- a/tools/perf/tests/perf-time-to-tsc.c
>> +++ b/tools/perf/tests/perf-time-to-tsc.c
>> @@ -20,6 +20,7 @@
>>   #include "tsc.h"
>>   #include "mmap.h"
>>   #include "tests.h"
>> +#include "pmu.h"
>>   
>>   #define CHECK__(x) {				\
>>   	while ((x) < 0) {			\
>> @@ -66,6 +67,10 @@ int test__perf_time_to_tsc(struct test *test __maybe_unused, int subtest __maybe
>>   	u64 test_tsc, comm1_tsc, comm2_tsc;
>>   	u64 test_time, comm1_time = 0, comm2_time = 0;
>>   	struct mmap *md;
>> +	bool hybrid = false;
>> +
>> +	if (perf_pmu__has_hybrid())
>> +		hybrid = true;
>>   
>>   	threads = thread_map__new(-1, getpid(), UINT_MAX);
>>   	CHECK_NOT_NULL__(threads);
>> @@ -88,6 +93,17 @@ int test__perf_time_to_tsc(struct test *test __maybe_unused, int subtest __maybe
>>   	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 (hybrid) {
> 
> same, don't see the reason for 'hybrid' variable
> 

OK, will use 'if (perf_pmu__has_hybrid())' instead.

Thanks
Jin Yao

> jirka
> 
>> +		evsel = evsel__next(evsel);
>> +		evsel->core.attr.comm = 1;
>> +		evsel->core.attr.disabled = 1;
>> +		evsel->core.attr.enable_on_exec = 0;
>> +	}
>> +
>>   	CHECK__(evlist__open(evlist));
>>   
>>   	CHECK__(evlist__mmap(evlist, UINT_MAX));
>> -- 
>> 2.17.1
>>
>

Patch
diff mbox series

diff --git a/tools/perf/tests/perf-time-to-tsc.c b/tools/perf/tests/perf-time-to-tsc.c
index 680c3cffb128..72f268c6cc5d 100644
--- a/tools/perf/tests/perf-time-to-tsc.c
+++ b/tools/perf/tests/perf-time-to-tsc.c
@@ -20,6 +20,7 @@ 
 #include "tsc.h"
 #include "mmap.h"
 #include "tests.h"
+#include "pmu.h"
 
 #define CHECK__(x) {				\
 	while ((x) < 0) {			\
@@ -66,6 +67,10 @@  int test__perf_time_to_tsc(struct test *test __maybe_unused, int subtest __maybe
 	u64 test_tsc, comm1_tsc, comm2_tsc;
 	u64 test_time, comm1_time = 0, comm2_time = 0;
 	struct mmap *md;
+	bool hybrid = false;
+
+	if (perf_pmu__has_hybrid())
+		hybrid = true;
 
 	threads = thread_map__new(-1, getpid(), UINT_MAX);
 	CHECK_NOT_NULL__(threads);
@@ -88,6 +93,17 @@  int test__perf_time_to_tsc(struct test *test __maybe_unused, int subtest __maybe
 	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 (hybrid) {
+		evsel = evsel__next(evsel);
+		evsel->core.attr.comm = 1;
+		evsel->core.attr.disabled = 1;
+		evsel->core.attr.enable_on_exec = 0;
+	}
+
 	CHECK__(evlist__open(evlist));
 
 	CHECK__(evlist__mmap(evlist, UINT_MAX));