Skip to contentSkip to conversation

perf parse-events: Specially handle uncore event alias in small groups

PATCH Superseded [email protected] 3 participants 8 messages May 1, 2018 – May 7, 2018 perf events

v5 of 6 Superseded Latest is v6 →

lore
Share & tools
lore
#0 lore raw

PATCH v5 1/1 perf parse-events: Specially handle uncore event alias in small groups

From: Kan Liang <[email protected]>

Perf stat doesn't count the uncore event aliases from the same uncore block in a group, for example:

perf stat -e '{unc_m_cas_count.all,unc_m_clockticks}' -a -I 1000
# time counts unit events

       1.000447342      <not counted>      unc_m_cas_count.all
       1.000447342      <not counted>      unc_m_clockticks
       2.000740654      <not counted>      unc_m_cas_count.all
       2.000740654      <not counted>      unc_m_clockticks

The output is very misleading. It gives a wrong impression that the uncore event doesn't work.

An uncore block could be composed by several PMUs. An uncore event alias is a joint name which means the same event runs on all PMUs of a block. Perf doesn't support mixed events from different PMUs in the same group. It is wrong to put uncore event aliases in a big group.

The right way is to split the big group into multiple small groups which only include the events from the same PMU.
Only uncore event aliases from the same uncore block should be specially handled here. It doesn't make sense to mix the uncore events with other uncore events from different blocks or even core events in a group.

With the patch:
# time counts unit events

     1.001557653            140,833      unc_m_cas_count.all
     1.001557653      1,330,231,332      unc_m_clockticks
     2.002709483             85,007      unc_m_cas_count.all
     2.002709483      1,429,494,563      unc_m_clockticks

---

Changes since V4:
- Add WARN_ON when failing to alloc an array for leaders
- Add comments to explain why it has to go through the whole group

 tools/perf/util/evsel.h        |   1 +
 tools/perf/util/parse-events.c | 130 ++++++++++++++++++++++++++++++++++++++++-
 tools/perf/util/parse-events.h |   7 ++-
 tools/perf/util/parse-events.y |   8 +--
 4 files changed, 137 insertions(+), 9 deletions(-)
tools/perf/util/evsel.h +1 -0
index 92ec009..b13f5f2 100644
@@ -127,6 +127,7 @@ struct perf_evsel {
 	bool			precise_max;
 	bool			ignore_missing_thread;
 	bool			forced_leader;
+	bool			use_uncore_alias;
 	/* parse modifier helper */
 	int			exclude_GH;
 	int			nr_members;
tools/perf/util/parse-events.c +127 -3

177 lines not on this page · raw message

tools/perf/util/parse-events.h +5 -2
index 5015cfd..4473dac 100644
@@ -167,7 +167,9 @@ int parse_events_add_breakpoint(struct list_head *list, int *idx,
 				void *ptr, char *type, u64 len);
 int parse_events_add_pmu(struct parse_events_state *parse_state,
 			 struct list_head *list, char *name,
-			 struct list_head *head_config, bool auto_merge_stats);
+			 struct list_head *head_config,
+			 bool auto_merge_stats,
+			 bool use_alias);
 
 int parse_events_multi_pmu_add(struct parse_events_state *parse_state,
 			       char *str,
@@ -178,7 +180,8 @@ int parse_events_copy_term_list(struct list_head *old,
 
 enum perf_pmu_event_symbol_type
 perf_pmu__parse_check(const char *name);
-void parse_events__set_leader(char *name, struct list_head *list);
+void parse_events__set_leader(char *name, struct list_head *list,
+			      struct parse_events_state *parse_state);
 void parse_events_update_lists(struct list_head *list_event,
 			       struct list_head *list_all);
 void parse_events_evlist_error(struct parse_events_state *parse_state,
tools/perf/util/parse-events.y +4 -4
index d14464c..47f6399 100644
@@ -161,7 +161,7 @@ PE_NAME '{' events '}'
 	struct list_head *list = $3;
 
 	inc_group_count(list, _parse_state);
-	parse_events__set_leader($1, list);
+	parse_events__set_leader($1, list, _parse_state);
 	$$ = list;
 }
 |
@@ -170,7 +170,7 @@ PE_NAME '{' events '}'
 	struct list_head *list = $2;
 
 	inc_group_count(list, _parse_state);
-	parse_events__set_leader(NULL, list);
+	parse_events__set_leader(NULL, list, _parse_state);
 	$$ = list;
 }
 
@@ -232,7 +232,7 @@ PE_NAME '/' event_config '/'
 		YYABORT;
 
 	ALLOC_LIST(list);
-	if (parse_events_add_pmu(_parse_state, list, $1, $3, false)) {
+	if (parse_events_add_pmu(_parse_state, list, $1, $3, false, false)) {
 		struct perf_pmu *pmu = NULL;
 		int ok = 0;
 		char *pattern;
@@ -251,7 +251,7 @@ PE_NAME '/' event_config '/'
 					free(pattern);
 					YYABORT;
 				}
-				if (!parse_events_add_pmu(_parse_state, list, pmu->name, terms, true))
+				if (!parse_events_add_pmu(_parse_state, list, pmu->name, terms, true, false))
 					ok++;
 				parse_events_terms__delete(terms);
 			}
Signature · 1 line
2.7.4
Acked-by on v5 1/1
#1 lore raw
Quoted 33 lines · On Tue, May 01, 2018 at 07:31:36AM -0700, [email protected] wrote:

From: Kan Liang <[email protected]>

Perf stat doesn't count the uncore event aliases from the same uncore block in a group, for example:

perf stat -e '{unc_m_cas_count.all,unc_m_clockticks}' -a -I 1000
# time counts unit events

       1.000447342      <not counted>      unc_m_cas_count.all
       1.000447342      <not counted>      unc_m_clockticks
       2.000740654      <not counted>      unc_m_cas_count.all
       2.000740654      <not counted>      unc_m_clockticks

The output is very misleading. It gives a wrong impression that the uncore event doesn't work.

An uncore block could be composed by several PMUs. An uncore event alias is a joint name which means the same event runs on all PMUs of a block. Perf doesn't support mixed events from different PMUs in the same group. It is wrong to put uncore event aliases in a big group.

The right way is to split the big group into multiple small groups which only include the events from the same PMU.
Only uncore event aliases from the same uncore block should be specially handled here. It doesn't make sense to mix the uncore events with other uncore events from different blocks or even core events in a group.

With the patch:
# time counts unit events

     1.001557653            140,833      unc_m_cas_count.all
     1.001557653      1,330,231,332      unc_m_clockticks
     2.002709483             85,007      unc_m_cas_count.all
     2.002709483      1,429,494,563      unc_m_clockticks
Quoted 7 lines

---

Changes since V4:
- Add WARN_ON when failing to alloc an array for leaders
- Add comments to explain why it has to go through the whole group

thanks,
jirka

author
#2 lore raw
Quoted 38 lines · Jiri Olsa
Quoted 37 lines · On Tue, May 01, 2018 at 07:31:36AM -0700, [email protected] wrote:

From: Kan Liang <[email protected]>

Perf stat doesn't count the uncore event aliases from the same uncore block in a group, for example:

   perf stat -e '{unc_m_cas_count.all,unc_m_clockticks}' -a -I 1000
   #           time             counts unit events
        1.000447342      <not counted>      unc_m_cas_count.all
        1.000447342      <not counted>      unc_m_clockticks
        2.000740654      <not counted>      unc_m_cas_count.all
        2.000740654      <not counted>      unc_m_clockticks

The output is very misleading. It gives a wrong impression that the uncore event doesn't work.

An uncore block could be composed by several PMUs. An uncore event alias is a joint name which means the same event runs on all PMUs of a block. Perf doesn't support mixed events from different PMUs in the same group. It is wrong to put uncore event aliases in a big group.

The right way is to split the big group into multiple small groups which only include the events from the same PMU.
Only uncore event aliases from the same uncore block should be specially handled here. It doesn't make sense to mix the uncore events with other uncore events from different blocks or even core events in a group.

With the patch:

   #           time             counts unit events
      1.001557653            140,833      unc_m_cas_count.all
      1.001557653      1,330,231,332      unc_m_clockticks
      2.002709483             85,007      unc_m_cas_count.all
      2.002709483      1,429,494,563      unc_m_clockticks

---

Quoted 6 lines
Quoted 3 lines

Changes since V4:
- Add WARN_ON when failing to alloc an array for leaders
- Add comments to explain why it has to go through the whole group

Thanks Jirka.

Hi Arnaldo,

Are you OK with the patch?
It looks like Jirka has another patch which will touch the same code.
If it's OK for you, could you please merge the patch? So he can do the changes on top of this patch.

Thanks,
Kan

#3 lore raw

Em Fri, May 04, 2018 at 01:57:33PM -0400, Liang, Kan escreveu:

Quoted 48 lines · Jiri Olsa
Quoted 38 lines · On Tue, May 01, 2018 at 07:31:36AM -0700, [email protected] wrote:
Quoted 37 lines

From: Kan Liang <[email protected]>

Perf stat doesn't count the uncore event aliases from the same uncore block in a group, for example:

   perf stat -e '{unc_m_cas_count.all,unc_m_clockticks}' -a -I 1000
   #           time             counts unit events
        1.000447342      <not counted>      unc_m_cas_count.all
        1.000447342      <not counted>      unc_m_clockticks
        2.000740654      <not counted>      unc_m_cas_count.all
        2.000740654      <not counted>      unc_m_clockticks

The output is very misleading. It gives a wrong impression that the uncore event doesn't work.

An uncore block could be composed by several PMUs. An uncore event alias is a joint name which means the same event runs on all PMUs of a block. Perf doesn't support mixed events from different PMUs in the same group. It is wrong to put uncore event aliases in a big group.

The right way is to split the big group into multiple small groups which only include the events from the same PMU.
Only uncore event aliases from the same uncore block should be specially handled here. It doesn't make sense to mix the uncore events with other uncore events from different blocks or even core events in a group.

With the patch:

   #           time             counts unit events
      1.001557653            140,833      unc_m_cas_count.all
      1.001557653      1,330,231,332      unc_m_clockticks
      2.002709483             85,007      unc_m_cas_count.all
      2.002709483      1,429,494,563      unc_m_clockticks

---

Quoted 6 lines
Quoted 3 lines

Changes since V4:
- Add WARN_ON when failing to alloc an array for leaders
- Add comments to explain why it has to go through the whole group

Quoted 8 lines

Thanks Jirka.

Hi Arnaldo,

Are you OK with the patch?
It looks like Jirka has another patch which will touch the same code. If it's OK for you, could you please merge the patch? So he can do the changes on top of this patch.

Yeah, I'm applying to my perf/core branch and pushing it out now.

- Arnaldo

#4 lore raw

Em Fri, May 04, 2018 at 03:21:16PM -0300, Arnaldo Carvalho de Melo escreveu:

Quoted 4 lines

Em Fri, May 04, 2018 at 01:57:33PM -0400, Liang, Kan escreveu:

Quoted 2 lines · Jiri Olsa
Quoted 1 line
Quoted 8 lines
Quoted 6 lines

Thanks Jirka.

Are you OK with the patch?
It looks like Jirka has another patch which will touch the same code. If it's OK for you, could you please merge the patch? So he can do the changes on top of this patch.

Yeah, I'm applying to my perf/core branch and pushing it out now.

So, this will probably break when merging with perf/urgent due to the revert of a patch that touches the parser files, just a heads out.

- Arnaldo

#5 lore raw

Em Mon, May 07, 2018 at 03:39:30PM -0300, Arnaldo Carvalho de Melo escreveu:

Quoted 10 lines

Em Fri, May 04, 2018 at 03:21:16PM -0300, Arnaldo Carvalho de Melo escreveu:

Quoted 8 lines

Em Fri, May 04, 2018 at 01:57:33PM -0400, Liang, Kan escreveu:

Quoted 7 lines · Jiri Olsa
Quoted 1 line

Are you OK with the patch?
It looks like Jirka has another patch which will touch the same code. If it's OK for you, could you please merge the patch? So he can do the changes on top of this patch.

Quoted 4 lines
Quoted 1 line

Yeah, I'm applying to my perf/core branch and pushing it out now.

So, this will probably break when merging with perf/urgent due to the revert of a patch that touches the parser files, just a heads out.

s/heads out/heads up/
:-)

-Arnaldo

author
#6 lore raw
In reply to Arnaldo Carvalho de Melo
Quoted 12 lines · Arnaldo Carvalho de Melo

Em Fri, May 04, 2018 at 03:21:16PM -0300, Arnaldo Carvalho de Melo escreveu:

Quoted 10 lines

Em Fri, May 04, 2018 at 01:57:33PM -0400, Liang, Kan escreveu:

Quoted 9 lines · Jiri Olsa
Quoted 1 line

Thanks Jirka.

Are you OK with the patch?
It looks like Jirka has another patch which will touch the same code. If it's OK for you, could you please merge the patch? So he can do the changes on top of this patch.

Quoted 5 lines
Quoted 1 line

Yeah, I'm applying to my perf/core branch and pushing it out now.

So, this will probably break when merging with perf/urgent due to the revert of a patch that touches the parser files, just a heads out.

Yes, it probably be a conflict.
Do you want me to send a re-base version of this patch after the revert?

Thanks,
Kan

#7 lore raw

Em Mon, May 07, 2018 at 03:06:18PM -0400, Liang, Kan escreveu:

Quoted 12 lines · Arnaldo Carvalho de Melo
Quoted 11 lines

Em Fri, May 04, 2018 at 03:21:16PM -0300, Arnaldo Carvalho de Melo escreveu:

Quoted 10 lines

Em Fri, May 04, 2018 at 01:57:33PM -0400, Liang, Kan escreveu:

Quoted 9 lines · Jiri Olsa
Quoted 1 line

Thanks Jirka.

Are you OK with the patch?
It looks like Jirka has another patch which will touch the same code. If it's OK for you, could you please merge the patch? So he can do the changes on top of this patch.

Quoted 7 lines
Quoted 4 lines
Quoted 1 line

Yeah, I'm applying to my perf/core branch and pushing it out now.

So, this will probably break when merging with perf/urgent due to the revert of a patch that touches the parser files, just a heads out.

Yes, it probably be a conflict.
Do you want me to send a re-base version of this patch after the revert?

That would be nice, please do so.

- Arnaldo