Skip to contentSkip to conversation

perf vendor events: Update datasource event name to fix duplicate events

PATCH Applied Athira Rajeev 4 participants 11 messages Nov 23, 2023 – Dec 5, 2023 perf events

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 perf vendor events: Update datasource event name to fix duplicate events

Running "perf list" on powerpc fails with segfault as below:

./perf list
Segmentation fault (core dumped)

This happens because of duplicate events in the json list. The powerpc Json event list contains some event with same event name, but different event code. They are:
- PM_INST_FROM_L3MISS (Present in datasource and frontend)
- PM_MRK_DATA_FROM_L2MISS (Present in datasource and marked)
- PM_MRK_INST_FROM_L3MISS (Present in datasource and marked)
- PM_MRK_DATA_FROM_L3MISS (Present in datasource and marked)

pmu_events_table__num_events uses the value from table_pmu->num_entries which includes duplicate events as well. This causes issue during "perf list" and results in segmentation fault.

Since both event codes are valid, append _DSRC to the Data Source events (datasource.json), so that they would have a unique name. Also add PM_DATA_FROM_L2MISS_DSRC and PM_DATA_FROM_L3MISS_DSRC events. With the fix, perf list works as expected.

Fixes fc1435807533 ("perf vendor events power10: Update JSON/events")
---
 .../arch/powerpc/power10/datasource.json       | 18 ++++++++++++++----
 1 file changed, 14 insertions(+), 4 deletions(-)
tools/perf/pmu-events/arch/powerpc/power10/datasource.json +14 -4
index 6b0356f2d301..0eeaaf1a95b8 100644
@@ -99,6 +99,11 @@
     "EventName": "PM_INST_FROM_L2MISS",
     "BriefDescription": "The processor's instruction cache was reloaded from a source beyond the local core's L2 due to a demand miss."
   },
+  {
+    "EventCode": "0x0003C0000000C040",
+    "EventName": "PM_DATA_FROM_L2MISS_DSRC",
+    "BriefDescription": "The processor's L1 data cache was reloaded from a source beyond the local core's L2 due to a demand miss."
+  },
   {
     "EventCode": "0x000380000010C040",
     "EventName": "PM_INST_FROM_L2MISS_ALL",
@@ -161,9 +166,14 @@
   },
   {
     "EventCode": "0x000780000000C040",
-    "EventName": "PM_INST_FROM_L3MISS",
+    "EventName": "PM_INST_FROM_L3MISS_DSRC",
     "BriefDescription": "The processor's instruction cache was reloaded from beyond the local core's L3 due to a demand miss."
   },
+  {
+    "EventCode": "0x0007C0000000C040",
+    "EventName": "PM_DATA_FROM_L3MISS_DSRC",
+    "BriefDescription": "The processor's L1 data cache was reloaded from beyond the local core's L3 due to a demand miss."
+  },
   {
     "EventCode": "0x000780000010C040",
     "EventName": "PM_INST_FROM_L3MISS_ALL",
@@ -981,7 +991,7 @@
   },
   {
     "EventCode": "0x0003C0000000C142",
-    "EventName": "PM_MRK_DATA_FROM_L2MISS",
+    "EventName": "PM_MRK_DATA_FROM_L2MISS_DSRC",
     "BriefDescription": "The processor's L1 data cache was reloaded from a source beyond the local core's L2 due to a demand miss for a marked instruction."
   },
   {
@@ -1046,12 +1056,12 @@
   },
   {
     "EventCode": "0x000780000000C142",
-    "EventName": "PM_MRK_INST_FROM_L3MISS",
+    "EventName": "PM_MRK_INST_FROM_L3MISS_DSRC",
     "BriefDescription": "The processor's instruction cache was reloaded from beyond the local core's L3 due to a demand miss for a marked instruction."
   },
   {
     "EventCode": "0x0007C0000000C142",
-    "EventName": "PM_MRK_DATA_FROM_L3MISS",
+    "EventName": "PM_MRK_DATA_FROM_L3MISS_DSRC",
     "BriefDescription": "The processor's L1 data cache was reloaded from beyond the local core's L3 due to a demand miss for a marked instruction."
   },
   {
Signature · 1 line
2.39.3
Tested-by on v1 1/1
#1 lore raw
Quoted 19 lines · Athira Rajeev

Running "perf list" on powerpc fails with segfault as below:

./perf list
Segmentation fault (core dumped)

This happens because of duplicate events in the json list. The powerpc Json event list contains some event with same event name, but different event code. They are:
- PM_INST_FROM_L3MISS (Present in datasource and frontend)
- PM_MRK_DATA_FROM_L2MISS (Present in datasource and marked)
- PM_MRK_INST_FROM_L3MISS (Present in datasource and marked)
- PM_MRK_DATA_FROM_L3MISS (Present in datasource and marked)

pmu_events_table__num_events uses the value from table_pmu->num_entries which includes duplicate events as well. This causes issue during "perf list" and results in segmentation fault.

Quoted 8 lines

Since both event codes are valid, append _DSRC to the Data Source events (datasource.json), so that they would have a unique name. Also add PM_DATA_FROM_L2MISS_DSRC and PM_DATA_FROM_L3MISS_DSRC events. With the fix, perf list works as expected.

Fixes fc1435807533 ("perf vendor events power10: Update JSON/events")

I have tested the patch on Power10 machine. Perf list works correctly without any segfault now.

	# ./perf list

List of pre-defined events (to be used in -e or -M):

branch-instructions OR branches [Hardware event]
branch-misses [Hardware event]

Quoted 60 lines
---
  .../arch/powerpc/power10/datasource.json       | 18 ++++++++++++++----
  1 file changed, 14 insertions(+), 4 deletions(-)
tools/perf/pmu-events/arch/powerpc/power10/datasource.json +14 -4
index 6b0356f2d301..0eeaaf1a95b8 100644
@@ -99,6 +99,11 @@
      "EventName": "PM_INST_FROM_L2MISS",
      "BriefDescription": "The processor's instruction cache was reloaded from a source beyond the local core's L2 due to a demand miss."
    },
+  {
+    "EventCode": "0x0003C0000000C040",
+    "EventName": "PM_DATA_FROM_L2MISS_DSRC",
+    "BriefDescription": "The processor's L1 data cache was reloaded from a source beyond the local core's L2 due to a demand miss."
+  },
    {
      "EventCode": "0x000380000010C040",
      "EventName": "PM_INST_FROM_L2MISS_ALL",
@@ -161,9 +166,14 @@
    },
    {
      "EventCode": "0x000780000000C040",
-    "EventName": "PM_INST_FROM_L3MISS",
+    "EventName": "PM_INST_FROM_L3MISS_DSRC",
      "BriefDescription": "The processor's instruction cache was reloaded from beyond the local core's L3 due to a demand miss."
    },
+  {
+    "EventCode": "0x0007C0000000C040",
+    "EventName": "PM_DATA_FROM_L3MISS_DSRC",
+    "BriefDescription": "The processor's L1 data cache was reloaded from beyond the local core's L3 due to a demand miss."
+  },
    {
      "EventCode": "0x000780000010C040",
      "EventName": "PM_INST_FROM_L3MISS_ALL",
@@ -981,7 +991,7 @@
    },
    {
      "EventCode": "0x0003C0000000C142",
-    "EventName": "PM_MRK_DATA_FROM_L2MISS",
+    "EventName": "PM_MRK_DATA_FROM_L2MISS_DSRC",
      "BriefDescription": "The processor's L1 data cache was reloaded from a source beyond the local core's L2 due to a demand miss for a marked instruction."
    },
    {
@@ -1046,12 +1056,12 @@
    },
    {
      "EventCode": "0x000780000000C142",
-    "EventName": "PM_MRK_INST_FROM_L3MISS",
+    "EventName": "PM_MRK_INST_FROM_L3MISS_DSRC",
      "BriefDescription": "The processor's instruction cache was reloaded from beyond the local core's L3 due to a demand miss for a marked instruction."
    },
    {
      "EventCode": "0x0007C0000000C142",
-    "EventName": "PM_MRK_DATA_FROM_L3MISS",
+    "EventName": "PM_MRK_DATA_FROM_L3MISS_DSRC",
      "BriefDescription": "The processor's L1 data cache was reloaded from beyond the local core's L3 due to a demand miss for a marked instruction."
    },
    {
#2 lore raw
Quoted 36 lines · Disha Goel
Quoted 19 lines · Athira Rajeev

Running "perf list" on powerpc fails with segfault as below:

./perf list
Segmentation fault (core dumped)

This happens because of duplicate events in the json list. The powerpc Json event list contains some event with same event name, but different event code. They are:
- PM_INST_FROM_L3MISS (Present in datasource and frontend)
- PM_MRK_DATA_FROM_L2MISS (Present in datasource and marked)
- PM_MRK_INST_FROM_L3MISS (Present in datasource and marked)
- PM_MRK_DATA_FROM_L3MISS (Present in datasource and marked)

pmu_events_table__num_events uses the value from table_pmu->num_entries which includes duplicate events as well. This causes issue during "perf list" and results in segmentation fault.

Quoted 8 lines

Since both event codes are valid, append _DSRC to the Data Source events (datasource.json), so that they would have a unique name. Also add PM_DATA_FROM_L2MISS_DSRC and PM_DATA_FROM_L3MISS_DSRC events. With the fix, perf list works as expected.

Fixes fc1435807533 ("perf vendor events power10: Update JSON/events")

I have tested the patch on Power10 machine. Perf list works correctly without any segfault now.

Quoted 9 lines
# ./perf list

List of pre-defined events (to be used in -e or -M):

branch-instructions OR branches [Hardware event]
branch-misses [Hardware event]

Thanks Disha for testing

Athira

Quoted 60 lines
Quoted 60 lines
---
 .../arch/powerpc/power10/datasource.json       | 18 ++++++++++++++----
 1 file changed, 14 insertions(+), 4 deletions(-)
tools/perf/pmu-events/arch/powerpc/power10/datasource.json +14 -4
index 6b0356f2d301..0eeaaf1a95b8 100644
@@ -99,6 +99,11 @@
     "EventName": "PM_INST_FROM_L2MISS",
     "BriefDescription": "The processor's instruction cache was reloaded from a source beyond the local core's L2 due to a demand miss."
   },
+  {
+    "EventCode": "0x0003C0000000C040",
+    "EventName": "PM_DATA_FROM_L2MISS_DSRC",
+    "BriefDescription": "The processor's L1 data cache was reloaded from a source beyond the local core's L2 due to a demand miss."
+  },
   {
     "EventCode": "0x000380000010C040",
     "EventName": "PM_INST_FROM_L2MISS_ALL",
@@ -161,9 +166,14 @@
   },
   {
     "EventCode": "0x000780000000C040",
-    "EventName": "PM_INST_FROM_L3MISS",
+    "EventName": "PM_INST_FROM_L3MISS_DSRC",
     "BriefDescription": "The processor's instruction cache was reloaded from beyond the local core's L3 due to a demand miss."
   },
+  {
+    "EventCode": "0x0007C0000000C040",
+    "EventName": "PM_DATA_FROM_L3MISS_DSRC",
+    "BriefDescription": "The processor's L1 data cache was reloaded from beyond the local core's L3 due to a demand miss."
+  },
   {
     "EventCode": "0x000780000010C040",
     "EventName": "PM_INST_FROM_L3MISS_ALL",
@@ -981,7 +991,7 @@
   },
   {
     "EventCode": "0x0003C0000000C142",
-    "EventName": "PM_MRK_DATA_FROM_L2MISS",
+    "EventName": "PM_MRK_DATA_FROM_L2MISS_DSRC",
     "BriefDescription": "The processor's L1 data cache was reloaded from a source beyond the local core's L2 due to a demand miss for a marked instruction."
   },
   {
@@ -1046,12 +1056,12 @@
   },
   {
     "EventCode": "0x000780000000C142",
-    "EventName": "PM_MRK_INST_FROM_L3MISS",
+    "EventName": "PM_MRK_INST_FROM_L3MISS_DSRC",
     "BriefDescription": "The processor's instruction cache was reloaded from beyond the local core's L3 due to a demand miss for a marked instruction."
   },
   {
     "EventCode": "0x0007C0000000C142",
-    "EventName": "PM_MRK_DATA_FROM_L3MISS",
+    "EventName": "PM_MRK_DATA_FROM_L3MISS_DSRC",
     "BriefDescription": "The processor's L1 data cache was reloaded from beyond the local core's L3 due to a demand miss for a marked instruction."
   },
   {
#3 lore raw
Quoted 47 lines · Athira Rajeev
Quoted 44 lines · Disha Goel
Quoted 19 lines · Athira Rajeev

Running "perf list" on powerpc fails with segfault as below:

./perf list
Segmentation fault (core dumped)

This happens because of duplicate events in the json list. The powerpc Json event list contains some event with same event name, but different event code. They are:
- PM_INST_FROM_L3MISS (Present in datasource and frontend)
- PM_MRK_DATA_FROM_L2MISS (Present in datasource and marked)
- PM_MRK_INST_FROM_L3MISS (Present in datasource and marked)
- PM_MRK_DATA_FROM_L3MISS (Present in datasource and marked)

pmu_events_table__num_events uses the value from table_pmu->num_entries which includes duplicate events as well. This causes issue during "perf list" and results in segmentation fault.

Quoted 8 lines

Since both event codes are valid, append _DSRC to the Data Source events (datasource.json), so that they would have a unique name. Also add PM_DATA_FROM_L2MISS_DSRC and PM_DATA_FROM_L3MISS_DSRC events. With the fix, perf list works as expected.

Fixes fc1435807533 ("perf vendor events power10: Update JSON/events")

I have tested the patch on Power10 machine. Perf list works correctly without any segfault now.

# ./perf list

List of pre-defined events (to be used in -e or -M):

branch-instructions OR branches [Hardware event]
branch-misses [Hardware event]

Quoted 6 lines
Quoted 2 lines

Thanks Disha for testing

Athira

Hi Arnaldo,

Can we get this pulled in if the patch looks good ?

Thanks
Athira

Quoted 60 lines
Quoted 60 lines
Quoted 60 lines

---
.../arch/powerpc/power10/datasource.json | 18 ++++++++++++++----

1 file changed, 14 insertions(+), 4 deletions(-)
tools/perf/pmu-events/arch/powerpc/power10/datasource.json +14 -4
index 6b0356f2d301..0eeaaf1a95b8 100644
@@ -99,6 +99,11 @@
    "EventName": "PM_INST_FROM_L2MISS",
    "BriefDescription": "The processor's instruction cache was reloaded from a source beyond the local core's L2 due to a demand miss."
  },
+  {
+    "EventCode": "0x0003C0000000C040",
+    "EventName": "PM_DATA_FROM_L2MISS_DSRC",
+    "BriefDescription": "The processor's L1 data cache was reloaded from a source beyond the local core's L2 due to a demand miss."
+  },
  {
    "EventCode": "0x000380000010C040",
    "EventName": "PM_INST_FROM_L2MISS_ALL",
@@ -161,9 +166,14 @@
  },
  {
    "EventCode": "0x000780000000C040",
-    "EventName": "PM_INST_FROM_L3MISS",
+    "EventName": "PM_INST_FROM_L3MISS_DSRC",
    "BriefDescription": "The processor's instruction cache was reloaded from beyond the local core's L3 due to a demand miss."
  },
+  {
+    "EventCode": "0x0007C0000000C040",
+    "EventName": "PM_DATA_FROM_L3MISS_DSRC",
+    "BriefDescription": "The processor's L1 data cache was reloaded from beyond the local core's L3 due to a demand miss."
+  },
  {
    "EventCode": "0x000780000010C040",
    "EventName": "PM_INST_FROM_L3MISS_ALL",
@@ -981,7 +991,7 @@
  },
  {
    "EventCode": "0x0003C0000000C142",
-    "EventName": "PM_MRK_DATA_FROM_L2MISS",
+    "EventName": "PM_MRK_DATA_FROM_L2MISS_DSRC",
    "BriefDescription": "The processor's L1 data cache was reloaded from a source beyond the local core's L2 due to a demand miss for a marked instruction."
  },
  {
@@ -1046,12 +1056,12 @@
  },
  {
    "EventCode": "0x000780000000C142",
-    "EventName": "PM_MRK_INST_FROM_L3MISS",
+    "EventName": "PM_MRK_INST_FROM_L3MISS_DSRC",
    "BriefDescription": "The processor's instruction cache was reloaded from beyond the local core's L3 due to a demand miss for a marked instruction."
  },
  {
    "EventCode": "0x0007C0000000C142",
-    "EventName": "PM_MRK_DATA_FROM_L3MISS",
+    "EventName": "PM_MRK_DATA_FROM_L3MISS_DSRC",
    "BriefDescription": "The processor's L1 data cache was reloaded from beyond the local core's L3 due to a demand miss for a marked instruction."
  },
  {
maintainer Applied
#4 lore raw

Em Sun, Dec 03, 2023 at 09:27:25PM +0530, Athira Rajeev escreveu:

Quoted 14 lines
Quoted 13 lines · Athira Rajeev
Quoted 12 lines · Disha Goel
Quoted 2 lines
Fixes fc1435807533 ("perf vendor events power10: Update JSON/events")

I have tested the patch on Power10 machine. Perf list works correctly without any segfault now.

# ./perf list

List of pre-defined events (to be used in -e or -M):

branch-instructions OR branches [Hardware event]
branch-misses [Hardware event]

Quoted 7 lines
Quoted 3 lines
Quoted 1 line

Thanks Disha for testing

Hi Arnaldo,

Can we get this pulled in if the patch looks good ?

Thanks, applied to perf-tools-next.

- Arnaldo

reviewer
#5 lore raw
In reply to Athira Rajeev
Quoted 20 lines · Athira Rajeev

Running "perf list" on powerpc fails with segfault as below:

./perf list
Segmentation fault (core dumped)

This happens because of duplicate events in the json list. The powerpc Json event list contains some event with same event name, but different event code. They are:
- PM_INST_FROM_L3MISS (Present in datasource and frontend)
- PM_MRK_DATA_FROM_L2MISS (Present in datasource and marked)
- PM_MRK_INST_FROM_L3MISS (Present in datasource and marked)
- PM_MRK_DATA_FROM_L3MISS (Present in datasource and marked)

pmu_events_table__num_events uses the value from table_pmu->num_entries which includes duplicate events as well. This causes issue during "perf list" and results in segmentation fault.

Quoted 8 lines

Since both event codes are valid, append _DSRC to the Data Source events (datasource.json), so that they would have a unique name. Also add PM_DATA_FROM_L2MISS_DSRC and PM_DATA_FROM_L3MISS_DSRC events. With the fix, perf list works as expected.

Fixes fc1435807533 ("perf vendor events power10: Update JSON/events")

Given duplicate events creates broken pmu-events.c we should capture that as an exception in jevents.py. That way a JEVENTS_ARCH=all build will fail if any vendor/architecture would break in this way. We should also add JEVENTS_ARCH=all to tools/perf/tests/make. Athira, do you want to look at doing this?

Thanks,
Ian

Quoted 63 lines
---
 .../arch/powerpc/power10/datasource.json       | 18 ++++++++++++++----
 1 file changed, 14 insertions(+), 4 deletions(-)
tools/perf/pmu-events/arch/powerpc/power10/datasource.json +14 -5
index 6b0356f2d301..0eeaaf1a95b8 100644
@@ -99,6 +99,11 @@
     "EventName": "PM_INST_FROM_L2MISS",
     "BriefDescription": "The processor's instruction cache was reloaded from a source beyond the local core's L2 due to a demand miss."
   },
+  {
+    "EventCode": "0x0003C0000000C040",
+    "EventName": "PM_DATA_FROM_L2MISS_DSRC",
+    "BriefDescription": "The processor's L1 data cache was reloaded from a source beyond the local core's L2 due to a demand miss."
+  },
   {
     "EventCode": "0x000380000010C040",
     "EventName": "PM_INST_FROM_L2MISS_ALL",
@@ -161,9 +166,14 @@
   },
   {
     "EventCode": "0x000780000000C040",
-    "EventName": "PM_INST_FROM_L3MISS",
+    "EventName": "PM_INST_FROM_L3MISS_DSRC",
     "BriefDescription": "The processor's instruction cache was reloaded from beyond the local core's L3 due to a demand miss."
   },
+  {
+    "EventCode": "0x0007C0000000C040",
+    "EventName": "PM_DATA_FROM_L3MISS_DSRC",
+    "BriefDescription": "The processor's L1 data cache was reloaded from beyond the local core's L3 due to a demand miss."
+  },
   {
     "EventCode": "0x000780000010C040",
     "EventName": "PM_INST_FROM_L3MISS_ALL",
@@ -981,7 +991,7 @@
   },
   {
     "EventCode": "0x0003C0000000C142",
-    "EventName": "PM_MRK_DATA_FROM_L2MISS",
+    "EventName": "PM_MRK_DATA_FROM_L2MISS_DSRC",
     "BriefDescription": "The processor's L1 data cache was reloaded from a source beyond the local core's L2 due to a demand miss for a marked instruction."
   },
   {
@@ -1046,12 +1056,12 @@
   },
   {
     "EventCode": "0x000780000000C142",
-    "EventName": "PM_MRK_INST_FROM_L3MISS",
+    "EventName": "PM_MRK_INST_FROM_L3MISS_DSRC",
     "BriefDescription": "The processor's instruction cache was reloaded from beyond the local core's L3 due to a demand miss for a marked instruction."
   },
   {
     "EventCode": "0x0007C0000000C142",
-    "EventName": "PM_MRK_DATA_FROM_L3MISS",
+    "EventName": "PM_MRK_DATA_FROM_L3MISS_DSRC",
     "BriefDescription": "The processor's L1 data cache was reloaded from beyond the local core's L3 due to a demand miss for a marked instruction."
   },
   {
--

2.39.3

#6 lore raw

Em Mon, Dec 04, 2023 at 12:12:54PM -0800, Ian Rogers escreveu:

Quoted 28 lines
Quoted 26 lines · Athira Rajeev

Running "perf list" on powerpc fails with segfault as below:

./perf list
Segmentation fault (core dumped)

This happens because of duplicate events in the json list. The powerpc Json event list contains some event with same event name, but different event code. They are:
- PM_INST_FROM_L3MISS (Present in datasource and frontend)
- PM_MRK_DATA_FROM_L2MISS (Present in datasource and marked)
- PM_MRK_INST_FROM_L3MISS (Present in datasource and marked)
- PM_MRK_DATA_FROM_L3MISS (Present in datasource and marked)

pmu_events_table__num_events uses the value from table_pmu->num_entries which includes duplicate events as well. This causes issue during "perf list" and results in segmentation fault.

Since both event codes are valid, append _DSRC to the Data Source events (datasource.json), so that they would have a unique name. Also add PM_DATA_FROM_L2MISS_DSRC and PM_DATA_FROM_L3MISS_DSRC events. With the fix, perf list works as expected.

Quoted 8 lines
Quoted 2 lines
Fixes fc1435807533 ("perf vendor events power10: Update JSON/events")

Given duplicate events creates broken pmu-events.c we should capture that as an exception in jevents.py. That way a JEVENTS_ARCH=all build will fail if any vendor/architecture would break in this way. We should also add JEVENTS_ARCH=all to tools/perf/tests/make. Athira, do you want to look at doing this?

Should I go ahead and remove this patch till this is sorted out?

- Arnaldo

#7 lore raw

Em Mon, Dec 04, 2023 at 05:20:46PM -0300, Arnaldo Carvalho de Melo escreveu:

Quoted 32 lines

Em Mon, Dec 04, 2023 at 12:12:54PM -0800, Ian Rogers escreveu:

Quoted 31 lines
Quoted 28 lines · Athira Rajeev

Running "perf list" on powerpc fails with segfault as below:

./perf list
Segmentation fault (core dumped)

This happens because of duplicate events in the json list. The powerpc Json event list contains some event with same event name, but different event code. They are:
- PM_INST_FROM_L3MISS (Present in datasource and frontend)
- PM_MRK_DATA_FROM_L2MISS (Present in datasource and marked)
- PM_MRK_INST_FROM_L3MISS (Present in datasource and marked)
- PM_MRK_DATA_FROM_L3MISS (Present in datasource and marked)

pmu_events_table__num_events uses the value from table_pmu->num_entries which includes duplicate events as well. This causes issue during "perf list" and results in segmentation fault.

Since both event codes are valid, append _DSRC to the Data Source events (datasource.json), so that they would have a unique name. Also add PM_DATA_FROM_L2MISS_DSRC and PM_DATA_FROM_L3MISS_DSRC events. With the fix, perf list works as expected.

Fixes fc1435807533 ("perf vendor events power10: Update JSON/events")
Quoted 7 lines
Quoted 5 lines

Given duplicate events creates broken pmu-events.c we should capture that as an exception in jevents.py. That way a JEVENTS_ARCH=all build will fail if any vendor/architecture would break in this way. We should also add JEVENTS_ARCH=all to tools/perf/tests/make. Athira, do you want to look at doing this?

Should I go ahead and remove this patch till this is sorted out?

I'll keep it, its already in tmp.perf-tools-next, we can go from there and improve this with follow up patches,

- Arnaldo

reviewer
#8 lore raw
Quoted 40 lines · Arnaldo Carvalho de Melo

Em Mon, Dec 04, 2023 at 05:20:46PM -0300, Arnaldo Carvalho de Melo escreveu:

Quoted 38 lines

Em Mon, Dec 04, 2023 at 12:12:54PM -0800, Ian Rogers escreveu:

Quoted 36 lines
Quoted 20 lines · Athira Rajeev

Running "perf list" on powerpc fails with segfault as below:

./perf list
Segmentation fault (core dumped)

This happens because of duplicate events in the json list. The powerpc Json event list contains some event with same event name, but different event code. They are:
- PM_INST_FROM_L3MISS (Present in datasource and frontend)
- PM_MRK_DATA_FROM_L2MISS (Present in datasource and marked)
- PM_MRK_INST_FROM_L3MISS (Present in datasource and marked)
- PM_MRK_DATA_FROM_L3MISS (Present in datasource and marked)

pmu_events_table__num_events uses the value from table_pmu->num_entries which includes duplicate events as well. This causes issue during "perf list" and results in segmentation fault.

Quoted 8 lines

Since both event codes are valid, append _DSRC to the Data Source events (datasource.json), so that they would have a unique name. Also add PM_DATA_FROM_L2MISS_DSRC and PM_DATA_FROM_L3MISS_DSRC events. With the fix, perf list works as expected.

Fixes fc1435807533 ("perf vendor events power10: Update JSON/events")

Given duplicate events creates broken pmu-events.c we should capture that as an exception in jevents.py. That way a JEVENTS_ARCH=all build will fail if any vendor/architecture would break in this way. We should also add JEVENTS_ARCH=all to tools/perf/tests/make. Athira, do you want to look at doing this?

Quoted 4 lines
Quoted 1 line

Should I go ahead and remove this patch till this is sorted out?

I'll keep it, its already in tmp.perf-tools-next, we can go from there and improve this with follow up patches,

Agreed. I could look to do the follow up but likely won't have a chance for a while. If others could help out it would be great. I'd like to have the jevents and json be robust enough that we don't trip over problems like this and the somewhat similar AmpereOne issue.

Thanks,
Ian

Quoted 1 line

- Arnaldo

#9 lore raw
Quoted 46 lines · Ian Rogers
Quoted 40 lines · Arnaldo Carvalho de Melo

Em Mon, Dec 04, 2023 at 05:20:46PM -0300, Arnaldo Carvalho de Melo escreveu:

Quoted 38 lines

Em Mon, Dec 04, 2023 at 12:12:54PM -0800, Ian Rogers escreveu:

Quoted 36 lines
Quoted 20 lines · Athira Rajeev

Running "perf list" on powerpc fails with segfault as below:

./perf list
Segmentation fault (core dumped)

This happens because of duplicate events in the json list. The powerpc Json event list contains some event with same event name, but different event code. They are:
- PM_INST_FROM_L3MISS (Present in datasource and frontend)
- PM_MRK_DATA_FROM_L2MISS (Present in datasource and marked)
- PM_MRK_INST_FROM_L3MISS (Present in datasource and marked)
- PM_MRK_DATA_FROM_L3MISS (Present in datasource and marked)

pmu_events_table__num_events uses the value from table_pmu->num_entries which includes duplicate events as well. This causes issue during "perf list" and results in segmentation fault.

Quoted 8 lines

Since both event codes are valid, append _DSRC to the Data Source events (datasource.json), so that they would have a unique name. Also add PM_DATA_FROM_L2MISS_DSRC and PM_DATA_FROM_L3MISS_DSRC events. With the fix, perf list works as expected.

Fixes fc1435807533 ("perf vendor events power10: Update JSON/events")

Given duplicate events creates broken pmu-events.c we should capture that as an exception in jevents.py. That way a JEVENTS_ARCH=all build will fail if any vendor/architecture would break in this way. We should also add JEVENTS_ARCH=all to tools/perf/tests/make. Athira, do you want to look at doing this?

Quoted 4 lines
Quoted 4 lines
Quoted 1 line

Should I go ahead and remove this patch till this is sorted out?

I'll keep it, its already in tmp.perf-tools-next, we can go from there and improve this with follow up patches,

Thanks Arnaldo for pulling the fix patch.

Quoted 5 lines

Agreed. I could look to do the follow up but likely won't have a chance for a while. If others could help out it would be great. I'd like to have the jevents and json be robust enough that we don't trip over problems like this and the somewhat similar AmpereOne issue.

Yes Ian.

I will look at adding this with follow up patches and including this as part of tools/perf/tests/make

Thanks
Athira

Quoted 5 lines

Thanks,
Ian

Quoted 1 line

- Arnaldo

#10 lore raw
In reply to Ian Rogers
Quoted 35 lines · Ian Rogers
Quoted 20 lines · Athira Rajeev

Running "perf list" on powerpc fails with segfault as below:

./perf list
Segmentation fault (core dumped)

This happens because of duplicate events in the json list. The powerpc Json event list contains some event with same event name, but different event code. They are:
- PM_INST_FROM_L3MISS (Present in datasource and frontend)
- PM_MRK_DATA_FROM_L2MISS (Present in datasource and marked)
- PM_MRK_INST_FROM_L3MISS (Present in datasource and marked)
- PM_MRK_DATA_FROM_L3MISS (Present in datasource and marked)

pmu_events_table__num_events uses the value from table_pmu->num_entries which includes duplicate events as well. This causes issue during "perf list" and results in segmentation fault.

Quoted 8 lines

Since both event codes are valid, append _DSRC to the Data Source events (datasource.json), so that they would have a unique name. Also add PM_DATA_FROM_L2MISS_DSRC and PM_DATA_FROM_L3MISS_DSRC events. With the fix, perf list works as expected.

Fixes fc1435807533 ("perf vendor events power10: Update JSON/events")
Quoted 8 lines

Given duplicate events creates broken pmu-events.c we should capture that as an exception in jevents.py. That way a JEVENTS_ARCH=all build will fail if any vendor/architecture would break in this way. We should also add JEVENTS_ARCH=all to tools/perf/tests/make. Athira, do you want to look at doing this?

Thanks,
Ian

Hi Ian,

That’s a great suggestion. This will definitely help to capture the issues ahead. I am interested and will work on adding this as part of tools/perf/tests/make

Thanks
Athira

Quoted 63 lines
Quoted 63 lines

---
.../arch/powerpc/power10/datasource.json | 18 ++++++++++++++----

1 file changed, 14 insertions(+), 4 deletions(-)
tools/perf/pmu-events/arch/powerpc/power10/datasource.json +14 -5
index 6b0356f2d301..0eeaaf1a95b8 100644
@@ -99,6 +99,11 @@
    "EventName": "PM_INST_FROM_L2MISS",
    "BriefDescription": "The processor's instruction cache was reloaded from a source beyond the local core's L2 due to a demand miss."
  },
+  {
+    "EventCode": "0x0003C0000000C040",
+    "EventName": "PM_DATA_FROM_L2MISS_DSRC",
+    "BriefDescription": "The processor's L1 data cache was reloaded from a source beyond the local core's L2 due to a demand miss."
+  },
  {
    "EventCode": "0x000380000010C040",
    "EventName": "PM_INST_FROM_L2MISS_ALL",
@@ -161,9 +166,14 @@
  },
  {
    "EventCode": "0x000780000000C040",
-    "EventName": "PM_INST_FROM_L3MISS",
+    "EventName": "PM_INST_FROM_L3MISS_DSRC",
    "BriefDescription": "The processor's instruction cache was reloaded from beyond the local core's L3 due to a demand miss."
  },
+  {
+    "EventCode": "0x0007C0000000C040",
+    "EventName": "PM_DATA_FROM_L3MISS_DSRC",
+    "BriefDescription": "The processor's L1 data cache was reloaded from beyond the local core's L3 due to a demand miss."
+  },
  {
    "EventCode": "0x000780000010C040",
    "EventName": "PM_INST_FROM_L3MISS_ALL",
@@ -981,7 +991,7 @@
  },
  {
    "EventCode": "0x0003C0000000C142",
-    "EventName": "PM_MRK_DATA_FROM_L2MISS",
+    "EventName": "PM_MRK_DATA_FROM_L2MISS_DSRC",
    "BriefDescription": "The processor's L1 data cache was reloaded from a source beyond the local core's L2 due to a demand miss for a marked instruction."
  },
  {
@@ -1046,12 +1056,12 @@
  },
  {
    "EventCode": "0x000780000000C142",
-    "EventName": "PM_MRK_INST_FROM_L3MISS",
+    "EventName": "PM_MRK_INST_FROM_L3MISS_DSRC",
    "BriefDescription": "The processor's instruction cache was reloaded from beyond the local core's L3 due to a demand miss for a marked instruction."
  },
  {
    "EventCode": "0x0007C0000000C142",
-    "EventName": "PM_MRK_DATA_FROM_L3MISS",
+    "EventName": "PM_MRK_DATA_FROM_L3MISS_DSRC",
    "BriefDescription": "The processor's L1 data cache was reloaded from beyond the local core's L3 due to a demand miss for a marked instruction."
  },
  {
--

2.39.3