[v4,23/25] perf tests: Support 'Session topology' test for hybrid
diff mbox series

Message ID 20210416140517.18206-24-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
Force to create one event "cpu_core/cycles/" by default,
otherwise in evlist__valid_sample_type, the checking of
'if (evlist->core.nr_entries == 1)' would be failed.

  # ./perf test 41
  41: Session topology                                                : Ok

Signed-off-by: Jin Yao <yao.jin@linux.intel.com>
---
 tools/perf/tests/topology.c | 10 +++++++++-
 1 file changed, 9 insertions(+), 1 deletion(-)

Comments

Jiri Olsa April 21, 2021, 6:29 p.m. UTC | #1
On Fri, Apr 16, 2021 at 10:05:15PM +0800, Jin Yao wrote:
> Force to create one event "cpu_core/cycles/" by default,
> otherwise in evlist__valid_sample_type, the checking of
> 'if (evlist->core.nr_entries == 1)' would be failed.
> 
>   # ./perf test 41
>   41: Session topology                                                : Ok
> 
> Signed-off-by: Jin Yao <yao.jin@linux.intel.com>
> ---
>  tools/perf/tests/topology.c | 10 +++++++++-
>  1 file changed, 9 insertions(+), 1 deletion(-)
> 
> diff --git a/tools/perf/tests/topology.c b/tools/perf/tests/topology.c
> index 050489807a47..30b4acb08d35 100644
> --- a/tools/perf/tests/topology.c
> +++ b/tools/perf/tests/topology.c
> @@ -8,6 +8,7 @@
>  #include "session.h"
>  #include "evlist.h"
>  #include "debug.h"
> +#include "pmu.h"
>  #include <linux/err.h>
>  
>  #define TEMPL "/tmp/perf-test-XXXXXX"
> @@ -40,7 +41,14 @@ static int session_write_header(char *path)
>  	session = perf_session__new(&data, false, NULL);
>  	TEST_ASSERT_VAL("can't get session", !IS_ERR(session));
>  
> -	session->evlist = evlist__new_default();
> +	if (!perf_pmu__has_hybrid()) {
> +		session->evlist = evlist__new_default();
> +	} else {
> +		struct parse_events_error err;
> +
> +		session->evlist = evlist__new();

you should ASSERT session->evlist in here

jirka

> +		parse_events(session->evlist, "cpu_core/cycles/", &err);
> +	}
>  	TEST_ASSERT_VAL("can't get evlist", session->evlist);
>  
>  	perf_header__set_feat(&session->header, HEADER_CPU_TOPOLOGY);
> -- 
> 2.17.1
>
Jin Yao April 22, 2021, 3:15 a.m. UTC | #2
Hi Jiri,

On 4/22/2021 2:29 AM, Jiri Olsa wrote:
> On Fri, Apr 16, 2021 at 10:05:15PM +0800, Jin Yao wrote:
>> Force to create one event "cpu_core/cycles/" by default,
>> otherwise in evlist__valid_sample_type, the checking of
>> 'if (evlist->core.nr_entries == 1)' would be failed.
>>
>>    # ./perf test 41
>>    41: Session topology                                                : Ok
>>
>> Signed-off-by: Jin Yao <yao.jin@linux.intel.com>
>> ---
>>   tools/perf/tests/topology.c | 10 +++++++++-
>>   1 file changed, 9 insertions(+), 1 deletion(-)
>>
>> diff --git a/tools/perf/tests/topology.c b/tools/perf/tests/topology.c
>> index 050489807a47..30b4acb08d35 100644
>> --- a/tools/perf/tests/topology.c
>> +++ b/tools/perf/tests/topology.c
>> @@ -8,6 +8,7 @@
>>   #include "session.h"
>>   #include "evlist.h"
>>   #include "debug.h"
>> +#include "pmu.h"
>>   #include <linux/err.h>
>>   
>>   #define TEMPL "/tmp/perf-test-XXXXXX"
>> @@ -40,7 +41,14 @@ static int session_write_header(char *path)
>>   	session = perf_session__new(&data, false, NULL);
>>   	TEST_ASSERT_VAL("can't get session", !IS_ERR(session));
>>   
>> -	session->evlist = evlist__new_default();
>> +	if (!perf_pmu__has_hybrid()) {
>> +		session->evlist = evlist__new_default();
>> +	} else {
>> +		struct parse_events_error err;
>> +
>> +		session->evlist = evlist__new();
> 
> you should ASSERT session->evlist in here
> 
> jirka
> 

OK, will add "ASSERT session->evlist" in next version.

Thanks
Jin Yao

>> +		parse_events(session->evlist, "cpu_core/cycles/", &err);
>> +	}
>>   	TEST_ASSERT_VAL("can't get evlist", session->evlist);
>>   
>>   	perf_header__set_feat(&session->header, HEADER_CPU_TOPOLOGY);
>> -- 
>> 2.17.1
>>
>

Patch
diff mbox series

diff --git a/tools/perf/tests/topology.c b/tools/perf/tests/topology.c
index 050489807a47..30b4acb08d35 100644
--- a/tools/perf/tests/topology.c
+++ b/tools/perf/tests/topology.c
@@ -8,6 +8,7 @@ 
 #include "session.h"
 #include "evlist.h"
 #include "debug.h"
+#include "pmu.h"
 #include <linux/err.h>
 
 #define TEMPL "/tmp/perf-test-XXXXXX"
@@ -40,7 +41,14 @@  static int session_write_header(char *path)
 	session = perf_session__new(&data, false, NULL);
 	TEST_ASSERT_VAL("can't get session", !IS_ERR(session));
 
-	session->evlist = evlist__new_default();
+	if (!perf_pmu__has_hybrid()) {
+		session->evlist = evlist__new_default();
+	} else {
+		struct parse_events_error err;
+
+		session->evlist = evlist__new();
+		parse_events(session->evlist, "cpu_core/cycles/", &err);
+	}
 	TEST_ASSERT_VAL("can't get evlist", session->evlist);
 
 	perf_header__set_feat(&session->header, HEADER_CPU_TOPOLOGY);