Skip to contentSkip to conversation

perf parse-events: Use strcmp to compare the PMU name

PATCH Applied Jin Yao 5 participants 13 messages Apr 30, 2020 – May 7, 2020 perf events

lore
Share & tools
lore

Jin Yao

author
#0 lore raw

PATCH 1/1 perf parse-events: Use strcmp to compare the PMU name

A big uncore event group is split into multiple small groups which only include the uncore events from the same PMU. This has been supported in the commit 3cdc5c2cb924a ("perf parse-events: Handle uncore event aliases in small groups properly").

If the event's PMU name starts to repeat, it must be a new event. That can be used to distinguish the leader from other members. But now it only compares the pointer of pmu_name (leader->pmu_name == evsel->pmu_name).

If we use "perf stat -M LLC_MISSES.PCIE_WRITE -a" on cascadelakex, the event list is:

evsel->name evsel->pmu_name
---------------------------------------------------------------
unc_iio_data_req_of_cpu.mem_write.part0 uncore_iio_4 (as leader)
unc_iio_data_req_of_cpu.mem_write.part0 uncore_iio_2
unc_iio_data_req_of_cpu.mem_write.part0 uncore_iio_0
unc_iio_data_req_of_cpu.mem_write.part0 uncore_iio_5
unc_iio_data_req_of_cpu.mem_write.part0 uncore_iio_3
unc_iio_data_req_of_cpu.mem_write.part0 uncore_iio_1
unc_iio_data_req_of_cpu.mem_write.part1 uncore_iio_4
......

For the event "unc_iio_data_req_of_cpu.mem_write.part1" with "uncore_iio_4", it should be the event from PMU "uncore_iio_4". It's not a new leader for this PMU.

But if we use "(leader->pmu_name == evsel->pmu_name)", the check would be failed and the event is stored to leaders[] as a new PMU leader.

So this patch uses strcmp to compare the PMU name between events.

Fixes 3cdc5c2cb924a ("perf parse-events: Handle uncore event aliases in small groups properly")
---
 tools/perf/util/parse-events.c | 5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)
tools/perf/util/parse-events.c +2 -3
index 10107747b361..786eddb6a097 100644
@@ -1629,12 +1629,11 @@ parse_events__set_leader_for_uncore_aliase(char *name, struct list_head *list,
 		 * event. That can be used to distinguish the leader from
 		 * other members, even they have the same event name.
 		 */
-		if ((leader != evsel) && (leader->pmu_name == evsel->pmu_name)) {
+		if ((leader != evsel) &&
+		    !strcmp(leader->pmu_name, evsel->pmu_name)) {
 			is_leader = false;
 			continue;
 		}
-		/* The name is always alias name */
-		WARN_ON(strcmp(leader->name, evsel->name));
 
 		/* Store the leader event for each PMU */
 		leaders[nr_pmu++] = (uintptr_t) evsel;
Signature · 1 line
2.17.1
Acked-by on v1 1/1
#1 lore raw
Quoted 28 lines · Jin Yao

A big uncore event group is split into multiple small groups which only include the uncore events from the same PMU. This has been supported in the commit 3cdc5c2cb924a ("perf parse-events: Handle uncore event aliases in small groups properly").

If the event's PMU name starts to repeat, it must be a new event. That can be used to distinguish the leader from other members. But now it only compares the pointer of pmu_name (leader->pmu_name == evsel->pmu_name).

If we use "perf stat -M LLC_MISSES.PCIE_WRITE -a" on cascadelakex, the event list is:

evsel->name evsel->pmu_name
---------------------------------------------------------------
unc_iio_data_req_of_cpu.mem_write.part0 uncore_iio_4 (as leader)
unc_iio_data_req_of_cpu.mem_write.part0 uncore_iio_2
unc_iio_data_req_of_cpu.mem_write.part0 uncore_iio_0
unc_iio_data_req_of_cpu.mem_write.part0 uncore_iio_5
unc_iio_data_req_of_cpu.mem_write.part0 uncore_iio_3
unc_iio_data_req_of_cpu.mem_write.part0 uncore_iio_1
unc_iio_data_req_of_cpu.mem_write.part1 uncore_iio_4
......

For the event "unc_iio_data_req_of_cpu.mem_write.part1" with "uncore_iio_4", it should be the event from PMU "uncore_iio_4". It's not a new leader for this PMU.

Quoted 8 lines

But if we use "(leader->pmu_name == evsel->pmu_name)", the check would be failed and the event is stored to leaders[] as a new PMU leader.

So this patch uses strcmp to compare the PMU name between events.

Fixes 3cdc5c2cb924a ("perf parse-events: Handle uncore event aliases in small groups properly")

looks good, any chance we could have automated test for this uncore leader setup logic? like maybe the way John did the pmu-events tests? like test will trigger only when there's the pmu/events in the system

thanks,
jirka

Quoted 26 lines
---
 tools/perf/util/parse-events.c | 5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)
tools/perf/util/parse-events.c +2 -3
index 10107747b361..786eddb6a097 100644
@@ -1629,12 +1629,11 @@ parse_events__set_leader_for_uncore_aliase(char *name, struct list_head *list,
 		 * event. That can be used to distinguish the leader from
 		 * other members, even they have the same event name.
 		 */
-		if ((leader != evsel) && (leader->pmu_name == evsel->pmu_name)) {
+		if ((leader != evsel) &&
+		    !strcmp(leader->pmu_name, evsel->pmu_name)) {
 			is_leader = false;
 			continue;
 		}
-		/* The name is always alias name */
-		WARN_ON(strcmp(leader->name, evsel->name));
 
 		/* Store the leader event for each PMU */
 		leaders[nr_pmu++] = (uintptr_t) evsel;
Signature · 1 line
2.17.1
#2 lore raw
Quoted 43 lines · Jiri Olsa
Quoted 28 lines · Jin Yao

A big uncore event group is split into multiple small groups which only include the uncore events from the same PMU. This has been supported in the commit 3cdc5c2cb924a ("perf parse-events: Handle uncore event aliases in small groups properly").

If the event's PMU name starts to repeat, it must be a new event. That can be used to distinguish the leader from other members. But now it only compares the pointer of pmu_name (leader->pmu_name == evsel->pmu_name).

If we use "perf stat -M LLC_MISSES.PCIE_WRITE -a" on cascadelakex, the event list is:

evsel->name evsel->pmu_name
---------------------------------------------------------------
unc_iio_data_req_of_cpu.mem_write.part0 uncore_iio_4 (as leader)
unc_iio_data_req_of_cpu.mem_write.part0 uncore_iio_2
unc_iio_data_req_of_cpu.mem_write.part0 uncore_iio_0
unc_iio_data_req_of_cpu.mem_write.part0 uncore_iio_5
unc_iio_data_req_of_cpu.mem_write.part0 uncore_iio_3
unc_iio_data_req_of_cpu.mem_write.part0 uncore_iio_1
unc_iio_data_req_of_cpu.mem_write.part1 uncore_iio_4
......

For the event "unc_iio_data_req_of_cpu.mem_write.part1" with "uncore_iio_4", it should be the event from PMU "uncore_iio_4". It's not a new leader for this PMU.

Quoted 8 lines

But if we use "(leader->pmu_name == evsel->pmu_name)", the check would be failed and the event is stored to leaders[] as a new PMU leader.

So this patch uses strcmp to compare the PMU name between events.

Fixes 3cdc5c2cb924a ("perf parse-events: Handle uncore event aliases in small groups properly")

looks good, any chance we could have automated test for this uncore leader setup logic? like maybe the way John did the pmu-events tests? like test will trigger only when there's the pmu/events in the system

Quoted 4 lines

thanks,
jirka

Hi jirka,

JFYI, this is effectively the same patch as I mentioned to you, which was a fix for the same WARN:

https://lore.kernel.org/linux-arm-kernel/[email protected]/

but I found that it "fixed" d4953f7ef1a2 ("perf parse-events: Fix 3 use after frees found with clang ASANutil/parse-events.c"), based on bisect breakage

cheers

Quoted 31 lines
Quoted 28 lines

---
  tools/perf/util/parse-events.c | 5 ++---
  1 file changed, 2 insertions(+), 3 deletions(-)
tools/perf/util/parse-events.c +2 -3
index 10107747b361..786eddb6a097 100644
@@ -1629,12 +1629,11 @@ parse_events__set_leader_for_uncore_aliase(char *name, struct list_head *list,
  		 * event. That can be used to distinguish the leader from
  		 * other members, even they have the same event name.
  		 */
-		if ((leader != evsel) && (leader->pmu_name == evsel->pmu_name)) {
+		if ((leader != evsel) &&
+		    !strcmp(leader->pmu_name, evsel->pmu_name)) {
  			is_leader = false;
  			continue;
  		}
-		/* The name is always alias name */
-		WARN_ON(strcmp(leader->name, evsel->name));
 
  		/* Store the leader event for each PMU */
  		leaders[nr_pmu++] = (uintptr_t) evsel;
Signature · 1 line
2.17.1

.

#3 lore raw
Quoted 51 lines · John Garry
Quoted 43 lines · Jiri Olsa
Quoted 28 lines · Jin Yao

A big uncore event group is split into multiple small groups which only include the uncore events from the same PMU. This has been supported in the commit 3cdc5c2cb924a ("perf parse-events: Handle uncore event aliases in small groups properly").

If the event's PMU name starts to repeat, it must be a new event. That can be used to distinguish the leader from other members. But now it only compares the pointer of pmu_name (leader->pmu_name == evsel->pmu_name).

If we use "perf stat -M LLC_MISSES.PCIE_WRITE -a" on cascadelakex, the event list is:

evsel->name evsel->pmu_name
---------------------------------------------------------------
unc_iio_data_req_of_cpu.mem_write.part0 uncore_iio_4 (as leader)
unc_iio_data_req_of_cpu.mem_write.part0 uncore_iio_2
unc_iio_data_req_of_cpu.mem_write.part0 uncore_iio_0
unc_iio_data_req_of_cpu.mem_write.part0 uncore_iio_5
unc_iio_data_req_of_cpu.mem_write.part0 uncore_iio_3
unc_iio_data_req_of_cpu.mem_write.part0 uncore_iio_1
unc_iio_data_req_of_cpu.mem_write.part1 uncore_iio_4
......

For the event "unc_iio_data_req_of_cpu.mem_write.part1" with "uncore_iio_4", it should be the event from PMU "uncore_iio_4". It's not a new leader for this PMU.

Quoted 8 lines

But if we use "(leader->pmu_name == evsel->pmu_name)", the check would be failed and the event is stored to leaders[] as a new PMU leader.

So this patch uses strcmp to compare the PMU name between events.

Fixes 3cdc5c2cb924a ("perf parse-events: Handle uncore event aliases in small groups properly")

looks good, any chance we could have automated test for this uncore leader setup logic? like maybe the way John did the pmu-events tests? like test will trigger only when there's the pmu/events in the system

Quoted 4 lines

thanks,
jirka

Hi jirka,

Quoted 8 lines

JFYI, this is effectively the same patch as I mentioned to you, which was a fix for the same WARN:

https://lore.kernel.org/linux-arm-kernel/[email protected]/

but I found that it "fixed" d4953f7ef1a2 ("perf parse-events: Fix 3 use after frees found with clang ASANutil/parse-events.c"), based on bisect breakage

hum right.. sorry I did not recalled that, there's also the warn removal in here, could you guys also plz sync on the fixes clauses?

thanks,
jirka

Quoted 34 lines

cheers

Quoted 30 lines
Quoted 27 lines

---
  tools/perf/util/parse-events.c | 5 ++---
  1 file changed, 2 insertions(+), 3 deletions(-)
tools/perf/util/parse-events.c +2 -3
index 10107747b361..786eddb6a097 100644
@@ -1629,12 +1629,11 @@ parse_events__set_leader_for_uncore_aliase(char *name, struct list_head *list,
  		 * event. That can be used to distinguish the leader from
  		 * other members, even they have the same event name.
  		 */
-		if ((leader != evsel) && (leader->pmu_name == evsel->pmu_name)) {
+		if ((leader != evsel) &&
+		    !strcmp(leader->pmu_name, evsel->pmu_name)) {
  			is_leader = false;
  			continue;
  		}
-		/* The name is always alias name */
-		WARN_ON(strcmp(leader->name, evsel->name));
  		/* Store the leader event for each PMU */
  		leaders[nr_pmu++] = (uintptr_t) evsel;
Signature · 1 line
2.17.1

.

#4 lore raw

On 30/04/2020 12:15, Jiri Olsa wrote:

+

Quoted 57 lines · John Garry
Quoted 56 lines · Jiri Olsa
Quoted 43 lines · Jin Yao
Quoted 28 lines

A big uncore event group is split into multiple small groups which only include the uncore events from the same PMU. This has been supported in the commit 3cdc5c2cb924a ("perf parse-events: Handle uncore event aliases in small groups properly").

If the event's PMU name starts to repeat, it must be a new event. That can be used to distinguish the leader from other members. But now it only compares the pointer of pmu_name (leader->pmu_name == evsel->pmu_name).

If we use "perf stat -M LLC_MISSES.PCIE_WRITE -a" on cascadelakex, the event list is:

evsel->name evsel->pmu_name
---------------------------------------------------------------
unc_iio_data_req_of_cpu.mem_write.part0 uncore_iio_4 (as leader)
unc_iio_data_req_of_cpu.mem_write.part0 uncore_iio_2
unc_iio_data_req_of_cpu.mem_write.part0 uncore_iio_0
unc_iio_data_req_of_cpu.mem_write.part0 uncore_iio_5
unc_iio_data_req_of_cpu.mem_write.part0 uncore_iio_3
unc_iio_data_req_of_cpu.mem_write.part0 uncore_iio_1
unc_iio_data_req_of_cpu.mem_write.part1 uncore_iio_4
......

For the event "unc_iio_data_req_of_cpu.mem_write.part1" with "uncore_iio_4", it should be the event from PMU "uncore_iio_4". It's not a new leader for this PMU.

Quoted 8 lines

But if we use "(leader->pmu_name == evsel->pmu_name)", the check would be failed and the event is stored to leaders[] as a new PMU leader.

So this patch uses strcmp to compare the PMU name between events.

Fixes 3cdc5c2cb924a ("perf parse-events: Handle uncore event aliases in small groups properly")

looks good, any chance we could have automated test for this uncore leader setup logic? like maybe the way John did the pmu-events tests? like test will trigger only when there's the pmu/events in the system

Quoted 4 lines

thanks,
jirka

Hi jirka,

JFYI, this is effectively the same patch as I mentioned to you, which was a fix for the same WARN:

https://lore.kernel.org/linux-arm-kernel/[email protected]/

Quoted 7 lines
Quoted 3 lines

but I found that it "fixed" d4953f7ef1a2 ("perf parse-events: Fix 3 use after frees found with clang ASANutil/parse-events.c"), based on bisect breakage

hum right.. sorry I did not recalled that, there's also the warn removal in here, could you guys also plz sync on the fixes clauses?

I just thought that it fixes d4953f7ef1a2, as I found that the pointer equality fails from that commit. I assume the parse-events code was sound before then (in that regard). That's all I know :)

Thanks!

Quoted 41 lines

thanks,
jirka

Quoted 34 lines

cheers

Quoted 30 lines
Quoted 27 lines

---
   tools/perf/util/parse-events.c | 5 ++---
   1 file changed, 2 insertions(+), 3 deletions(-)
tools/perf/util/parse-events.c +2 -3
index 10107747b361..786eddb6a097 100644
@@ -1629,12 +1629,11 @@ parse_events__set_leader_for_uncore_aliase(char *name, struct list_head *list,
   		 * event. That can be used to distinguish the leader from
   		 * other members, even they have the same event name.
   		 */
-		if ((leader != evsel) && (leader->pmu_name == evsel->pmu_name)) {
+		if ((leader != evsel) &&
+		    !strcmp(leader->pmu_name, evsel->pmu_name)) {
   			is_leader = false;
   			continue;
   		}
-		/* The name is always alias name */
-		WARN_ON(strcmp(leader->name, evsel->name));
   		/* Store the leader event for each PMU */
   		leaders[nr_pmu++] = (uintptr_t) evsel;
Signature · 1 line
2.17.1

.

.

author
#5 lore raw

Hi John, Jiri,

Quoted 66 lines · John Garry

On 30/04/2020 12:15, Jiri Olsa wrote:

+

Quoted 62 lines · John Garry
Quoted 60 lines · Jiri Olsa
Quoted 43 lines · Jin Yao
Quoted 28 lines

A big uncore event group is split into multiple small groups which only include the uncore events from the same PMU. This has been supported in the commit 3cdc5c2cb924a ("perf parse-events: Handle uncore event aliases in small groups properly").

If the event's PMU name starts to repeat, it must be a new event. That can be used to distinguish the leader from other members. But now it only compares the pointer of pmu_name (leader->pmu_name == evsel->pmu_name).

If we use "perf stat -M LLC_MISSES.PCIE_WRITE -a" on cascadelakex, the event list is:

evsel->name                    evsel->pmu_name
---------------------------------------------------------------
unc_iio_data_req_of_cpu.mem_write.part0        uncore_iio_4 (as leader) unc_iio_data_req_of_cpu.mem_write.part0        uncore_iio_2 unc_iio_data_req_of_cpu.mem_write.part0        uncore_iio_0 unc_iio_data_req_of_cpu.mem_write.part0        uncore_iio_5 unc_iio_data_req_of_cpu.mem_write.part0        uncore_iio_3 unc_iio_data_req_of_cpu.mem_write.part0        uncore_iio_1 unc_iio_data_req_of_cpu.mem_write.part1        uncore_iio_4
......

For the event "unc_iio_data_req_of_cpu.mem_write.part1" with "uncore_iio_4", it should be the event from PMU "uncore_iio_4". It's not a new leader for this PMU.

Quoted 8 lines

But if we use "(leader->pmu_name == evsel->pmu_name)", the check would be failed and the event is stored to leaders[] as a new PMU leader.

So this patch uses strcmp to compare the PMU name between events.

Fixes 3cdc5c2cb924a ("perf parse-events: Handle uncore event aliases in small groups properly")

looks good, any chance we could have automated test for this uncore leader setup logic? like maybe the way John did the pmu-events tests? like test will trigger only when there's the pmu/events in the system

Quoted 4 lines

thanks,
jirka

Hi jirka,

JFYI, this is effectively the same patch as I mentioned to you, which was a fix for the same WARN:

https://lore.kernel.org/linux-arm-kernel/[email protected]/

but I found that it "fixed" d4953f7ef1a2 ("perf parse-events: Fix 3 use after frees found with clang ASANutil/parse-events.c"), based on bisect breakage

Quoted 8 lines
Quoted 3 lines

hum right.. sorry I did not recalled that, there's also the warn removal in here, could you guys also plz sync on the fixes clauses?

I just thought that it fixes d4953f7ef1a2, as I found that the pointer equality fails from that commit. I assume the parse-events code was sound before then (in that regard). That's all I know :)

Thanks!

For 3cdc5c2cb924a, I just think it should use strcmp for pmu_name comparison rather than using pointer. But I'm OK to add d4953f7ef1a2 in fixes clauses. :)

Thanks
Jin Yao

Quoted 43 lines
Quoted 42 lines

thanks,
jirka

Quoted 35 lines

cheers

Quoted 31 lines
Quoted 28 lines

---
   tools/perf/util/parse-events.c | 5 ++---

   1 file changed, 2 insertions(+), 3 deletions(-)
tools/perf/util/parse-events.c +2 -3
index 10107747b361..786eddb6a097 100644
@@ -1629,12 +1629,11 @@ parse_events__set_leader_for_uncore_aliase(char 
 *name, struct list_head *list,
             * event. That can be used to distinguish the leader from
             * other members, even they have the same event name.
             */
-        if ((leader != evsel) && (leader->pmu_name == evsel->pmu_name)) {
+        if ((leader != evsel) &&
+            !strcmp(leader->pmu_name, evsel->pmu_name)) {
                is_leader = false;
                continue;
            }
-        /* The name is always alias name */
-        WARN_ON(strcmp(leader->name, evsel->name));
            /* Store the leader event for each PMU */
            leaders[nr_pmu++] = (uintptr_t) evsel;
Signature · 1 line
2.17.1

.

.

author
#8 lore raw
In reply to Jiri Olsa

Hi Jiri,

Quoted 43 lines · Jiri Olsa
Quoted 28 lines · Jin Yao

A big uncore event group is split into multiple small groups which only include the uncore events from the same PMU. This has been supported in the commit 3cdc5c2cb924a ("perf parse-events: Handle uncore event aliases in small groups properly").

If the event's PMU name starts to repeat, it must be a new event. That can be used to distinguish the leader from other members. But now it only compares the pointer of pmu_name (leader->pmu_name == evsel->pmu_name).

If we use "perf stat -M LLC_MISSES.PCIE_WRITE -a" on cascadelakex, the event list is:

evsel->name evsel->pmu_name
---------------------------------------------------------------
unc_iio_data_req_of_cpu.mem_write.part0 uncore_iio_4 (as leader)
unc_iio_data_req_of_cpu.mem_write.part0 uncore_iio_2
unc_iio_data_req_of_cpu.mem_write.part0 uncore_iio_0
unc_iio_data_req_of_cpu.mem_write.part0 uncore_iio_5
unc_iio_data_req_of_cpu.mem_write.part0 uncore_iio_3
unc_iio_data_req_of_cpu.mem_write.part0 uncore_iio_1
unc_iio_data_req_of_cpu.mem_write.part1 uncore_iio_4
......

For the event "unc_iio_data_req_of_cpu.mem_write.part1" with "uncore_iio_4", it should be the event from PMU "uncore_iio_4". It's not a new leader for this PMU.

Quoted 8 lines

But if we use "(leader->pmu_name == evsel->pmu_name)", the check would be failed and the event is stored to leaders[] as a new PMU leader.

So this patch uses strcmp to compare the PMU name between events.

Fixes 3cdc5c2cb924a ("perf parse-events: Handle uncore event aliases in small groups properly")

looks good, any chance we could have automated test for this uncore leader setup logic? like maybe the way John did the pmu-events tests? like test will trigger only when there's the pmu/events in the system

Quoted 6 lines

thanks,
jirka

I'm considering to use LKP to do the sanity tests for all perf events (core/uncore) and perf metrics periodically. It may help us to find the regressions on time.

Thanks
Jin Yao

Quoted 27 lines
Quoted 26 lines
---
  tools/perf/util/parse-events.c | 5 ++---
  1 file changed, 2 insertions(+), 3 deletions(-)
tools/perf/util/parse-events.c +2 -3
index 10107747b361..786eddb6a097 100644
@@ -1629,12 +1629,11 @@ parse_events__set_leader_for_uncore_aliase(char *name, struct list_head *list,
  		 * event. That can be used to distinguish the leader from
  		 * other members, even they have the same event name.
  		 */
-		if ((leader != evsel) && (leader->pmu_name == evsel->pmu_name)) {
+		if ((leader != evsel) &&
+		    !strcmp(leader->pmu_name, evsel->pmu_name)) {
  			is_leader = false;
  			continue;
  		}
-		/* The name is always alias name */
-		WARN_ON(strcmp(leader->name, evsel->name));
 
  		/* Store the leader event for each PMU */
  		leaders[nr_pmu++] = (uintptr_t) evsel;
Signature · 1 line
2.17.1
#9 lore raw
Quoted 48 lines · Yao

Hi Jiri,

Quoted 45 lines · Jiri Olsa
Quoted 28 lines · Jin Yao

A big uncore event group is split into multiple small groups which only include the uncore events from the same PMU. This has been supported in the commit 3cdc5c2cb924a ("perf parse-events: Handle uncore event aliases in small groups properly").

If the event's PMU name starts to repeat, it must be a new event. That can be used to distinguish the leader from other members. But now it only compares the pointer of pmu_name (leader->pmu_name == evsel->pmu_name).

If we use "perf stat -M LLC_MISSES.PCIE_WRITE -a" on cascadelakex, the event list is:

evsel->name evsel->pmu_name
---------------------------------------------------------------
unc_iio_data_req_of_cpu.mem_write.part0 uncore_iio_4 (as leader)
unc_iio_data_req_of_cpu.mem_write.part0 uncore_iio_2
unc_iio_data_req_of_cpu.mem_write.part0 uncore_iio_0
unc_iio_data_req_of_cpu.mem_write.part0 uncore_iio_5
unc_iio_data_req_of_cpu.mem_write.part0 uncore_iio_3
unc_iio_data_req_of_cpu.mem_write.part0 uncore_iio_1
unc_iio_data_req_of_cpu.mem_write.part1 uncore_iio_4
......

For the event "unc_iio_data_req_of_cpu.mem_write.part1" with "uncore_iio_4", it should be the event from PMU "uncore_iio_4". It's not a new leader for this PMU.

Quoted 8 lines

But if we use "(leader->pmu_name == evsel->pmu_name)", the check would be failed and the event is stored to leaders[] as a new PMU leader.

So this patch uses strcmp to compare the PMU name between events.

Fixes 3cdc5c2cb924a ("perf parse-events: Handle uncore event aliases in small groups properly")

looks good, any chance we could have automated test for this uncore leader setup logic? like maybe the way John did the pmu-events tests? like test will trigger only when there's the pmu/events in the system

Quoted 8 lines
Quoted 4 lines

thanks,
jirka

I'm considering to use LKP to do the sanity tests for all perf events (core/uncore) and perf metrics periodically. It may help us to find the regressions on time.

sounds good ;) thanks

jirka

reviewer
#10 lore raw
Quoted 55 lines · Jiri Olsa
Quoted 53 lines · Yao

Hi Jiri,

Quoted 49 lines · Jiri Olsa
Quoted 28 lines · Jin Yao

A big uncore event group is split into multiple small groups which only include the uncore events from the same PMU. This has been supported in the commit 3cdc5c2cb924a ("perf parse-events: Handle uncore event aliases in small groups properly").

If the event's PMU name starts to repeat, it must be a new event. That can be used to distinguish the leader from other members. But now it only compares the pointer of pmu_name (leader->pmu_name == evsel->pmu_name).

If we use "perf stat -M LLC_MISSES.PCIE_WRITE -a" on cascadelakex, the event list is:

evsel->name evsel->pmu_name
---------------------------------------------------------------

unc_iio_data_req_of_cpu.mem_write.part0           uncore_iio_4 (as leader)
unc_iio_data_req_of_cpu.mem_write.part0           uncore_iio_2
unc_iio_data_req_of_cpu.mem_write.part0           uncore_iio_0
unc_iio_data_req_of_cpu.mem_write.part0           uncore_iio_5
unc_iio_data_req_of_cpu.mem_write.part0           uncore_iio_3
unc_iio_data_req_of_cpu.mem_write.part0           uncore_iio_1
unc_iio_data_req_of_cpu.mem_write.part1           uncore_iio_4

......

For the event "unc_iio_data_req_of_cpu.mem_write.part1" with "uncore_iio_4", it should be the event from PMU "uncore_iio_4". It's not a new leader for this PMU.

Quoted 8 lines

But if we use "(leader->pmu_name == evsel->pmu_name)", the check would be failed and the event is stored to leaders[] as a new PMU leader.

So this patch uses strcmp to compare the PMU name between events.

Fixes 3cdc5c2cb924a ("perf parse-events: Handle uncore event aliases in small groups properly")

looks good, any chance we could have automated test for this uncore leader setup logic? like maybe the way John did the pmu-events tests? like test will trigger only when there's the pmu/events in the system

thanks,
jirka

Quoted 7 lines
Quoted 3 lines

I'm considering to use LKP to do the sanity tests for all perf events (core/uncore) and perf metrics periodically. It may help us to find the regressions on time.

sounds good ;) thanks

jirka

I've tested this and would be happy to see this merged. John's bisect found a memory leak fix of mine as the culprit.

Wrt testing, libbpf is using github/travis CI:
https://github.com/libbpf/libbpf
https://travis-ci.org/libbpf/libbpf
Perhaps that kind of set up can automate testing and lower the reviewer burden - but there's upfront cost in setting it up.

Thanks,
Ian

#11 lore raw

Em Wed, May 06, 2020 at 03:45:59PM -0700, Ian Rogers escreveu:

Quoted 64 lines · Jiri Olsa
Quoted 55 lines · Yao
Quoted 53 lines

Hi Jiri,

Quoted 49 lines · Jiri Olsa
Quoted 28 lines · Jin Yao

A big uncore event group is split into multiple small groups which only include the uncore events from the same PMU. This has been supported in the commit 3cdc5c2cb924a ("perf parse-events: Handle uncore event aliases in small groups properly").

If the event's PMU name starts to repeat, it must be a new event. That can be used to distinguish the leader from other members. But now it only compares the pointer of pmu_name (leader->pmu_name == evsel->pmu_name).

If we use "perf stat -M LLC_MISSES.PCIE_WRITE -a" on cascadelakex, the event list is:

evsel->name evsel->pmu_name
---------------------------------------------------------------

unc_iio_data_req_of_cpu.mem_write.part0           uncore_iio_4 (as leader)
unc_iio_data_req_of_cpu.mem_write.part0           uncore_iio_2
unc_iio_data_req_of_cpu.mem_write.part0           uncore_iio_0
unc_iio_data_req_of_cpu.mem_write.part0           uncore_iio_5
unc_iio_data_req_of_cpu.mem_write.part0           uncore_iio_3
unc_iio_data_req_of_cpu.mem_write.part0           uncore_iio_1
unc_iio_data_req_of_cpu.mem_write.part1           uncore_iio_4

......

For the event "unc_iio_data_req_of_cpu.mem_write.part1" with "uncore_iio_4", it should be the event from PMU "uncore_iio_4". It's not a new leader for this PMU.

Quoted 8 lines

But if we use "(leader->pmu_name == evsel->pmu_name)", the check would be failed and the event is stored to leaders[] as a new PMU leader.

So this patch uses strcmp to compare the PMU name between events.

Fixes 3cdc5c2cb924a ("perf parse-events: Handle uncore event aliases in small groups properly")

looks good, any chance we could have automated test for this uncore leader setup logic? like maybe the way John did the pmu-events tests? like test will trigger only when there's the pmu/events in the system

thanks,
jirka

Quoted 7 lines
Quoted 3 lines

I'm considering to use LKP to do the sanity tests for all perf events (core/uncore) and perf metrics periodically. It may help us to find the regressions on time.

sounds good ;) thanks

jirka

Quoted 8 lines

I've tested this and would be happy to see this merged. John's bisect found a memory leak fix of mine as the culprit.

Wrt testing, libbpf is using github/travis CI:
https://github.com/libbpf/libbpf
https://travis-ci.org/libbpf/libbpf
Perhaps that kind of set up can automate testing and lower the reviewer burden - but there's upfront cost in setting it up.

Well, if someone wants to bear this upfront cost, I can provide all the Dockerfiles + scripts I have to build those images, etc, I just don't have the time right now to invest in learning about travis, etc.

That would be awesome.

But if people run:

make -C tools/perf build-test

And:

perf test

Before sending pull requests, that would as well be fantastic :)

- Arnaldo

#12 lore raw
In reply to Jiri Olsa

Em Thu, Apr 30, 2020 at 10:45:29AM +0200, Jiri Olsa escreveu:

Quoted 38 lines · Jin Yao
Quoted 28 lines

A big uncore event group is split into multiple small groups which only include the uncore events from the same PMU. This has been supported in the commit 3cdc5c2cb924a ("perf parse-events: Handle uncore event aliases in small groups properly").

If the event's PMU name starts to repeat, it must be a new event. That can be used to distinguish the leader from other members. But now it only compares the pointer of pmu_name (leader->pmu_name == evsel->pmu_name).

If we use "perf stat -M LLC_MISSES.PCIE_WRITE -a" on cascadelakex, the event list is:

evsel->name evsel->pmu_name
---------------------------------------------------------------
unc_iio_data_req_of_cpu.mem_write.part0 uncore_iio_4 (as leader)
unc_iio_data_req_of_cpu.mem_write.part0 uncore_iio_2
unc_iio_data_req_of_cpu.mem_write.part0 uncore_iio_0
unc_iio_data_req_of_cpu.mem_write.part0 uncore_iio_5
unc_iio_data_req_of_cpu.mem_write.part0 uncore_iio_3
unc_iio_data_req_of_cpu.mem_write.part0 uncore_iio_1
unc_iio_data_req_of_cpu.mem_write.part1 uncore_iio_4
......

For the event "unc_iio_data_req_of_cpu.mem_write.part1" with "uncore_iio_4", it should be the event from PMU "uncore_iio_4". It's not a new leader for this PMU.

Quoted 8 lines

But if we use "(leader->pmu_name == evsel->pmu_name)", the check would be failed and the event is stored to leaders[] as a new PMU leader.

So this patch uses strcmp to compare the PMU name between events.

Fixes 3cdc5c2cb924a ("perf parse-events: Handle uncore event aliases in small groups properly")
Quoted 6 lines

looks good, any chance we could have automated test for this uncore leader setup logic? like maybe the way John did the pmu-events tests? like test will trigger only when there's the pmu/events in the system

Thanks, applied.

- Arnaldo

#6 lore raw
In reply to Jin, Yao

Em Thu, Apr 30, 2020 at 09:38:34PM +0800, Jin, Yao escreveu:

Quoted 78 lines

Hi John, Jiri,

Quoted 75 lines · John Garry

On 30/04/2020 12:15, Jiri Olsa wrote:

+

Quoted 59 lines · John Garry
Quoted 58 lines · Jiri Olsa
Quoted 44 lines · Jin Yao
Quoted 32 lines

A big uncore event group is split into multiple small groups which only include the uncore events from the same PMU. This has been supported in the commit 3cdc5c2cb924a ("perf parse-events: Handle uncore event aliases in small groups properly").

If the event's PMU name starts to repeat, it must be a new event. That can be used to distinguish the leader from other members. But now it only compares the pointer of pmu_name (leader->pmu_name == evsel->pmu_name).

If we use "perf stat -M LLC_MISSES.PCIE_WRITE -a" on cascadelakex, the event list is:

evsel->name                    evsel->pmu_name
---------------------------------------------------------------
unc_iio_data_req_of_cpu.mem_write.part0        uncore_iio_4 (as leader) unc_iio_data_req_of_cpu.mem_write.part0        uncore_iio_2 unc_iio_data_req_of_cpu.mem_write.part0        uncore_iio_0 unc_iio_data_req_of_cpu.mem_write.part0        uncore_iio_5 unc_iio_data_req_of_cpu.mem_write.part0        uncore_iio_3 unc_iio_data_req_of_cpu.mem_write.part0        uncore_iio_1 unc_iio_data_req_of_cpu.mem_write.part1        uncore_iio_4
......

For the event "unc_iio_data_req_of_cpu.mem_write.part1" with "uncore_iio_4", it should be the event from PMU "uncore_iio_4". It's not a new leader for this PMU.

But if we use "(leader->pmu_name == evsel->pmu_name)", the check would be failed and the event is stored to leaders[] as a new PMU leader.

Quoted 5 lines

So this patch uses strcmp to compare the PMU name between events.

Fixes 3cdc5c2cb924a ("perf parse-events: Handle uncore

event aliases in small groups properly")

looks good, any chance we could have automated test for this uncore leader setup logic? like maybe the way John did the pmu-events tests? like test will trigger only when there's the pmu/events in the system

Quoted 4 lines

thanks,
jirka

Hi jirka,

JFYI, this is effectively the same patch as I mentioned to you, which was a fix for the same WARN:

https://lore.kernel.org/linux-arm-kernel/[email protected]/

Quoted 7 lines
Quoted 3 lines

but I found that it "fixed" d4953f7ef1a2 ("perf parse-events: Fix 3 use after frees found with clang ASANutil/parse-events.c"), based on bisect breakage

hum right.. sorry I did not recalled that, there's also the warn removal in here, could you guys also plz sync on the fixes clauses?

I just thought that it fixes d4953f7ef1a2, as I found that the pointer equality fails from that commit. I assume the parse-events code was sound before then (in that regard). That's all I know :)

Quoted 6 lines
Quoted 2 lines

Thanks!

For 3cdc5c2cb924a, I just think it should use strcmp for pmu_name comparison rather than using pointer. But I'm OK to add d4953f7ef1a2 in fixes clauses. :)

So, I'm keeping Ian's patch, as I just applied it, and replaced the fixes clause to:

Fixes d4953f7ef1a2 ("perf parse-events: Fix 3 use after frees found with clang ASAN")

Would this be ok? Or does John's fix has something else in it (I haven't checked).

- Arnaldo

reviewer
#7 lore raw
Quoted 87 lines · Arnaldo Carvalho de Melo

Em Thu, Apr 30, 2020 at 09:38:34PM +0800, Jin, Yao escreveu:

Quoted 78 lines

Hi John, Jiri,

Quoted 75 lines · John Garry

On 30/04/2020 12:15, Jiri Olsa wrote:

+

Quoted 59 lines · John Garry
Quoted 58 lines · Jiri Olsa
Quoted 44 lines · Jin Yao
Quoted 32 lines

A big uncore event group is split into multiple small groups which only include the uncore events from the same PMU. This has been supported in the commit 3cdc5c2cb924a ("perf parse-events: Handle uncore event aliases in small groups properly").

If the event's PMU name starts to repeat, it must be a new event. That can be used to distinguish the leader from other members. But now it only compares the pointer of pmu_name (leader->pmu_name == evsel->pmu_name).

If we use "perf stat -M LLC_MISSES.PCIE_WRITE -a" on cascadelakex, the event list is:

evsel->name evsel->pmu_name
---------------------------------------------------------------

unc_iio_data_req_of_cpu.mem_write.part0        uncore_iio_4 (as leader)
unc_iio_data_req_of_cpu.mem_write.part0        uncore_iio_2
unc_iio_data_req_of_cpu.mem_write.part0        uncore_iio_0
unc_iio_data_req_of_cpu.mem_write.part0        uncore_iio_5
unc_iio_data_req_of_cpu.mem_write.part0        uncore_iio_3
unc_iio_data_req_of_cpu.mem_write.part0        uncore_iio_1
unc_iio_data_req_of_cpu.mem_write.part1        uncore_iio_4

......

For the event "unc_iio_data_req_of_cpu.mem_write.part1" with "uncore_iio_4", it should be the event from PMU "uncore_iio_4". It's not a new leader for this PMU.

But if we use "(leader->pmu_name == evsel->pmu_name)", the check would be failed and the event is stored to leaders[] as a new PMU leader.

Quoted 5 lines

So this patch uses strcmp to compare the PMU name between events.

Fixes 3cdc5c2cb924a ("perf parse-events: Handle uncore

event aliases in small groups properly")

looks good, any chance we could have automated test for this uncore leader setup logic? like maybe the way John did the pmu-events tests? like test will trigger only when there's the pmu/events in the system

Quoted 4 lines

thanks,
jirka

Hi jirka,

JFYI, this is effectively the same patch as I mentioned to you, which was a fix for the same WARN:

https://lore.kernel.org/linux-arm-kernel/[email protected]/

Quoted 7 lines
Quoted 3 lines

but I found that it "fixed" d4953f7ef1a2 ("perf parse-events: Fix 3 use after frees found with clang ASANutil/parse-events.c"), based on bisect breakage

hum right.. sorry I did not recalled that, there's also the warn removal in here, could you guys also plz sync on the fixes clauses?

I just thought that it fixes d4953f7ef1a2, as I found that the pointer equality fails from that commit. I assume the parse-events code was sound before then (in that regard). That's all I know :)

Quoted 6 lines
Quoted 2 lines

Thanks!

For 3cdc5c2cb924a, I just think it should use strcmp for pmu_name comparison rather than using pointer. But I'm OK to add d4953f7ef1a2 in fixes clauses. :)

Quoted 8 lines

So, I'm keeping Ian's patch, as I just applied it, and replaced the fixes clause to:

Fixes d4953f7ef1a2 ("perf parse-events: Fix 3 use after frees found with clang ASAN")

Would this be ok? Or does John's fix has something else in it (I haven't checked).

It is great! This patch is the same as John's except it also removes a warning that can now no longer happen. As such this patch is the better and the Fixes is correct.

Thanks,
Ian

Quoted 1 line

- Arnaldo