linux-perf-users.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH V2 1/2] tools/perf/pmu-events/powerpc: Add support for compat events in json
@ 2024-10-10 14:51 Athira Rajeev
  2024-10-10 14:51 ` [PATCH V2 2/2] tools/perf/powerpc/util: Add support to handle compatible mode PVR for perf json events Athira Rajeev
                   ` (3 more replies)
  0 siblings, 4 replies; 8+ messages in thread
From: Athira Rajeev @ 2024-10-10 14:51 UTC (permalink / raw)
  To: acme, jolsa, adrian.hunter, irogers, namhyung, hbathini
  Cc: linux-kernel, linux-perf-users, linuxppc-dev, akanksha, maddy,
	atrajeev, kjain, disgoel

perf list picks the events supported for specific platform
from pmu-events/arch/powerpc/<platform>. Example power10 events
are in pmu-events/arch/powerpc/power10, power9 events are part
of pmu-events/arch/powerpc/power9. The decision of which
platform to pick is determined based on PVR value in powerpc.
The PVR value is matched from pmu-events/arch/powerpc/mapfile.csv

Example:

Format:
        PVR,Version,JSON/file/pathname,Type

0x004[bcd][[:xdigit:]]{4},1,power8,core
0x0066[[:xdigit:]]{4},1,power8,core
0x004e[[:xdigit:]]{4},1,power9,core
0x0080[[:xdigit:]]{4},1,power10,core
0x0082[[:xdigit:]]{4},1,power10,core

The code gets the PVR from system using get_cpuid_str function
in arch/powerpc/util/headers.c ( from SPRN_PVR ) and compares
with value from mapfile.csv

In case of compat mode, say when partition is booted in a power9
mode when the system is a power10, add an entry to pick the
ISA architected events from "pmu-events/arch/powerpc/compat".
Add json file generic-events.json which will contain these
events which is supported in compat mode.

Suggested-by: Madhavan Srinivasan <maddy@linux.ibm.com>
Signed-off-by: Athira Rajeev <atrajeev@linux.vnet.ibm.com>
---

 .../arch/powerpc/compat/generic-events.json   | 117 ++++++++++++++++++
 .../perf/pmu-events/arch/powerpc/mapfile.csv  |   1 +
 2 files changed, 118 insertions(+)
 create mode 100644 tools/perf/pmu-events/arch/powerpc/compat/generic-events.json

diff --git a/tools/perf/pmu-events/arch/powerpc/compat/generic-events.json b/tools/perf/pmu-events/arch/powerpc/compat/generic-events.json
new file mode 100644
index 000000000000..6f5e8efcb098
--- /dev/null
+++ b/tools/perf/pmu-events/arch/powerpc/compat/generic-events.json
@@ -0,0 +1,117 @@
+[
+  {
+    "EventCode": "0x600F4",
+    "EventName": "PM_CYC",
+    "BriefDescription": "Processor cycles."
+  },
+  {
+    "EventCode": "0x100F2",
+    "EventName": "PM_CYC_INST_CMPL",
+    "BriefDescription": "1 or more ppc insts finished"
+  },
+  {
+    "EventCode": "0x100f4",
+    "EventName": "PM_FLOP_CMPL",
+    "BriefDescription": "Floating Point Operations Finished."
+  },
+  {
+    "EventCode": "0x100F6",
+    "EventName": "PM_L1_ITLB_MISS",
+    "BriefDescription": "Number of I-ERAT reloads."
+  },
+  {
+    "EventCode": "0x100F8",
+    "EventName": "PM_NO_INST_AVAIL",
+    "BriefDescription": "Number of cycles the ICT has no itags assigned to this thread."
+  },
+  {
+    "EventCode": "0x100fc",
+    "EventName": "PM_LD_CMPL",
+    "BriefDescription": "Load instruction completed."
+  },
+  {
+    "EventCode": "0x200F0",
+    "EventName": "PM_ST_CMPL",
+    "BriefDescription": "Stores completed from S2Q (2nd-level store queue)."
+  },
+  {
+    "EventCode": "0x200F2",
+    "EventName": "PM_INST_DISP",
+    "BriefDescription": "PowerPC instruction dispatched."
+  },
+  {
+    "EventCode": "0x200F4",
+    "EventName": "PM_RUN_CYC",
+    "BriefDescription": "Processor cycles gated by the run latch."
+  },
+  {
+    "EventCode": "0x200F6",
+    "EventName": "PM_L1_DTLB_RELOAD",
+    "BriefDescription": "DERAT Reloaded due to a DERAT miss."
+  },
+  {
+    "EventCode": "0x200FA",
+    "EventName": "PM_BR_TAKEN_CMPL",
+    "BriefDescription": "Branch Taken instruction completed."
+  },
+  {
+    "EventCode": "0x200FC",
+    "EventName": "PM_L1_ICACHE_MISS",
+    "BriefDescription": "Demand instruction cache miss."
+  },
+  {
+    "EventCode": "0x200FE",
+    "EventName": "PM_L1_RELOAD_FROM_MEM",
+    "BriefDescription": "L1 Dcache reload from memory"
+  },
+  {
+    "EventCode": "0x300F0",
+    "EventName": "PM_ST_MISS_L1",
+    "BriefDescription": "Store Missed L1"
+  },
+  {
+    "EventCode": "0x300FC",
+    "EventName": "PM_DTLB_MISS",
+    "BriefDescription": "Data PTEG reload"
+  },
+  {
+    "EventCode": "0x300FE",
+    "EventName": "PM_DATA_FROM_L3MISS",
+    "BriefDescription": "Demand LD - L3 Miss (not L2 hit and not L3 hit)"
+  },
+  {
+    "EventCode": "0x400F0",
+    "EventName": "PM_LD_MISS_L1",
+    "BriefDescription": "L1 Dcache load miss"
+  },
+  {
+    "EventCode": "0x400F2",
+    "EventName": "PM_CYC_INST_DISP",
+    "BriefDescription": "Cycle when instruction(s) dispatched."
+  },
+  {
+    "EventCode": "0x400F6",
+    "EventName": "PM_BR_MPRED_CMPL",
+    "BriefDescription": "A mispredicted branch completed. Includes direction and target."
+  },
+  {
+    "EventCode": "0x400FA",
+    "EventName": "PM_RUN_INST_CMPL",
+    "BriefDescription": "PowerPC instruction completed while the run latch is set."
+  },
+  {
+    "EventCode": "0x400FC",
+    "EventName": "PM_ITLB_MISS",
+    "BriefDescription": "Instruction TLB reload (after a miss), all page sizes. Includes only demand misses."
+  },
+  {
+    "EventCode": "0x400fe",
+    "EventName": "PM_LD_NOT_CACHED",
+    "BriefDescription": "Load data not cached."
+  },
+  {
+    "EventCode": "0x500fa",
+    "EventName": "PM_INST_CMPL",
+    "BriefDescription": "Instructions."
+  }
+]
diff --git a/tools/perf/pmu-events/arch/powerpc/mapfile.csv b/tools/perf/pmu-events/arch/powerpc/mapfile.csv
index 4d5e9138d4cc..cbd3cb443784 100644
--- a/tools/perf/pmu-events/arch/powerpc/mapfile.csv
+++ b/tools/perf/pmu-events/arch/powerpc/mapfile.csv
@@ -16,3 +16,4 @@
 0x004e[[:xdigit:]]{4},1,power9,core
 0x0080[[:xdigit:]]{4},1,power10,core
 0x0082[[:xdigit:]]{4},1,power10,core
+0x00ffffff,1,compat,core
-- 
2.27.0


^ permalink raw reply related	[flat|nested] 8+ messages in thread

* [PATCH V2 2/2] tools/perf/powerpc/util: Add support to handle compatible mode PVR for perf json events
  2024-10-10 14:51 [PATCH V2 1/2] tools/perf/pmu-events/powerpc: Add support for compat events in json Athira Rajeev
@ 2024-10-10 14:51 ` Athira Rajeev
  2025-03-21 10:34   ` Christophe Leroy
  2024-10-16 17:34 ` [PATCH V2 1/2] tools/perf/pmu-events/powerpc: Add support for compat events in json Namhyung Kim
                   ` (2 subsequent siblings)
  3 siblings, 1 reply; 8+ messages in thread
From: Athira Rajeev @ 2024-10-10 14:51 UTC (permalink / raw)
  To: acme, jolsa, adrian.hunter, irogers, namhyung, hbathini
  Cc: linux-kernel, linux-perf-users, linuxppc-dev, akanksha, maddy,
	atrajeev, kjain, disgoel

perf list picks the events supported for specific platform
from pmu-events/arch/powerpc/<platform>. Example power10 events
are in pmu-events/arch/powerpc/power10, power9 events are part
of pmu-events/arch/powerpc/power9. The decision of which
platform to pick is determined based on PVR value in powerpc.
The PVR value is matched from pmu-events/arch/powerpc/mapfile.csv

Example:

Format:
	PVR,Version,JSON/file/pathname,Type

0x004[bcd][[:xdigit:]]{4},1,power8,core
0x0066[[:xdigit:]]{4},1,power8,core
0x004e[[:xdigit:]]{4},1,power9,core
0x0080[[:xdigit:]]{4},1,power10,core
0x0082[[:xdigit:]]{4},1,power10,core

The code gets the PVR from system using get_cpuid_str function
in arch/powerpc/util/headers.c ( from SPRN_PVR ) and compares
with value from mapfile.csv
In case of compat mode, say when partition is booted in a power9
mode when the system is a power10, this picks incorrectly. Because
PVR will point to power10 where as it should pick events from power9
folder. To support generic events, add new folder
pmu-events/arch/powerpc/compat to contain the ISA architected events
which is supported in compat mode. Also return 0x00ffffff as pvr
when booted in compat mode. Based on this pvr value, json will
pick events from pmu-events/arch/powerpc/compat

Suggested-by: Madhavan Srinivasan <maddy@linux.ibm.com>
Signed-off-by: Athira Rajeev <atrajeev@linux.vnet.ibm.com>
---
changelog:
V1 -> V2:
Corrected commit message and subject line

 tools/perf/arch/powerpc/util/header.c | 32 ++++++++++++++++++++++++++-
 1 file changed, 31 insertions(+), 1 deletion(-)

diff --git a/tools/perf/arch/powerpc/util/header.c b/tools/perf/arch/powerpc/util/header.c
index 6b00efd53638..adc82c479443 100644
--- a/tools/perf/arch/powerpc/util/header.c
+++ b/tools/perf/arch/powerpc/util/header.c
@@ -10,6 +10,18 @@
 #include "utils_header.h"
 #include "metricgroup.h"
 #include <api/fs/fs.h>
+#include <sys/auxv.h>
+
+static bool is_compat_mode(void)
+{
+	u64 base_platform = getauxval(AT_BASE_PLATFORM);
+	u64 platform = getauxval(AT_PLATFORM);
+
+	if (!strcmp((char *)platform, (char *)base_platform))
+		return false;
+
+	return true;
+}
 
 int
 get_cpuid(char *buffer, size_t sz)
@@ -33,8 +45,26 @@ char *
 get_cpuid_str(struct perf_pmu *pmu __maybe_unused)
 {
 	char *bufp;
+	unsigned long pvr;
+
+	/*
+	 * IBM Power System supports compatible mode. That is
+	 * Nth generation platform can support previous generation
+	 * OS in a mode called compatibile mode. For ex. LPAR can be
+	 * booted in a Power9 mode when the system is a Power10.
+	 *
+	 * In the compatible mode, care must be taken when generating
+	 * PVR value. When read, PVR will be of the AT_BASE_PLATFORM
+	 * To support generic events, return 0x00ffffff as pvr when
+	 * booted in compat mode. Based on this pvr value, json will
+	 * pick events from pmu-events/arch/powerpc/compat
+	 */
+	if (!is_compat_mode())
+		pvr = mfspr(SPRN_PVR);
+	else
+		pvr = 0x00ffffff;
 
-	if (asprintf(&bufp, "0x%.8lx", mfspr(SPRN_PVR)) < 0)
+	if (asprintf(&bufp, "0x%.8lx", pvr) < 0)
 		bufp = NULL;
 
 	return bufp;
-- 
2.27.0


^ permalink raw reply related	[flat|nested] 8+ messages in thread

* Re: [PATCH V2 1/2] tools/perf/pmu-events/powerpc: Add support for compat events in json
  2024-10-10 14:51 [PATCH V2 1/2] tools/perf/pmu-events/powerpc: Add support for compat events in json Athira Rajeev
  2024-10-10 14:51 ` [PATCH V2 2/2] tools/perf/powerpc/util: Add support to handle compatible mode PVR for perf json events Athira Rajeev
@ 2024-10-16 17:34 ` Namhyung Kim
  2024-10-16 18:08   ` Athira Rajeev
  2024-10-17 14:11 ` Disha Goel
  2024-10-18 15:20 ` Namhyung Kim
  3 siblings, 1 reply; 8+ messages in thread
From: Namhyung Kim @ 2024-10-16 17:34 UTC (permalink / raw)
  To: Athira Rajeev
  Cc: acme, jolsa, adrian.hunter, irogers, hbathini, linux-kernel,
	linux-perf-users, linuxppc-dev, akanksha, maddy, kjain, disgoel

Hello Athira,

On Thu, Oct 10, 2024 at 08:21:06PM +0530, Athira Rajeev wrote:
> perf list picks the events supported for specific platform
> from pmu-events/arch/powerpc/<platform>. Example power10 events
> are in pmu-events/arch/powerpc/power10, power9 events are part
> of pmu-events/arch/powerpc/power9. The decision of which
> platform to pick is determined based on PVR value in powerpc.
> The PVR value is matched from pmu-events/arch/powerpc/mapfile.csv
> 
> Example:
> 
> Format:
>         PVR,Version,JSON/file/pathname,Type
> 
> 0x004[bcd][[:xdigit:]]{4},1,power8,core
> 0x0066[[:xdigit:]]{4},1,power8,core
> 0x004e[[:xdigit:]]{4},1,power9,core
> 0x0080[[:xdigit:]]{4},1,power10,core
> 0x0082[[:xdigit:]]{4},1,power10,core
> 
> The code gets the PVR from system using get_cpuid_str function
> in arch/powerpc/util/headers.c ( from SPRN_PVR ) and compares
> with value from mapfile.csv
> 
> In case of compat mode, say when partition is booted in a power9
> mode when the system is a power10, add an entry to pick the
> ISA architected events from "pmu-events/arch/powerpc/compat".
> Add json file generic-events.json which will contain these
> events which is supported in compat mode.
> 
> Suggested-by: Madhavan Srinivasan <maddy@linux.ibm.com>
> Signed-off-by: Athira Rajeev <atrajeev@linux.vnet.ibm.com>

Is this the latest version?

Thanks,
Namhyung

> ---
> 
>  .../arch/powerpc/compat/generic-events.json   | 117 ++++++++++++++++++
>  .../perf/pmu-events/arch/powerpc/mapfile.csv  |   1 +
>  2 files changed, 118 insertions(+)
>  create mode 100644 tools/perf/pmu-events/arch/powerpc/compat/generic-events.json
> 
> diff --git a/tools/perf/pmu-events/arch/powerpc/compat/generic-events.json b/tools/perf/pmu-events/arch/powerpc/compat/generic-events.json
> new file mode 100644
> index 000000000000..6f5e8efcb098
> --- /dev/null
> +++ b/tools/perf/pmu-events/arch/powerpc/compat/generic-events.json
> @@ -0,0 +1,117 @@
> +[
> +  {
> +    "EventCode": "0x600F4",
> +    "EventName": "PM_CYC",
> +    "BriefDescription": "Processor cycles."
> +  },
> +  {
> +    "EventCode": "0x100F2",
> +    "EventName": "PM_CYC_INST_CMPL",
> +    "BriefDescription": "1 or more ppc insts finished"
> +  },
> +  {
> +    "EventCode": "0x100f4",
> +    "EventName": "PM_FLOP_CMPL",
> +    "BriefDescription": "Floating Point Operations Finished."
> +  },
> +  {
> +    "EventCode": "0x100F6",
> +    "EventName": "PM_L1_ITLB_MISS",
> +    "BriefDescription": "Number of I-ERAT reloads."
> +  },
> +  {
> +    "EventCode": "0x100F8",
> +    "EventName": "PM_NO_INST_AVAIL",
> +    "BriefDescription": "Number of cycles the ICT has no itags assigned to this thread."
> +  },
> +  {
> +    "EventCode": "0x100fc",
> +    "EventName": "PM_LD_CMPL",
> +    "BriefDescription": "Load instruction completed."
> +  },
> +  {
> +    "EventCode": "0x200F0",
> +    "EventName": "PM_ST_CMPL",
> +    "BriefDescription": "Stores completed from S2Q (2nd-level store queue)."
> +  },
> +  {
> +    "EventCode": "0x200F2",
> +    "EventName": "PM_INST_DISP",
> +    "BriefDescription": "PowerPC instruction dispatched."
> +  },
> +  {
> +    "EventCode": "0x200F4",
> +    "EventName": "PM_RUN_CYC",
> +    "BriefDescription": "Processor cycles gated by the run latch."
> +  },
> +  {
> +    "EventCode": "0x200F6",
> +    "EventName": "PM_L1_DTLB_RELOAD",
> +    "BriefDescription": "DERAT Reloaded due to a DERAT miss."
> +  },
> +  {
> +    "EventCode": "0x200FA",
> +    "EventName": "PM_BR_TAKEN_CMPL",
> +    "BriefDescription": "Branch Taken instruction completed."
> +  },
> +  {
> +    "EventCode": "0x200FC",
> +    "EventName": "PM_L1_ICACHE_MISS",
> +    "BriefDescription": "Demand instruction cache miss."
> +  },
> +  {
> +    "EventCode": "0x200FE",
> +    "EventName": "PM_L1_RELOAD_FROM_MEM",
> +    "BriefDescription": "L1 Dcache reload from memory"
> +  },
> +  {
> +    "EventCode": "0x300F0",
> +    "EventName": "PM_ST_MISS_L1",
> +    "BriefDescription": "Store Missed L1"
> +  },
> +  {
> +    "EventCode": "0x300FC",
> +    "EventName": "PM_DTLB_MISS",
> +    "BriefDescription": "Data PTEG reload"
> +  },
> +  {
> +    "EventCode": "0x300FE",
> +    "EventName": "PM_DATA_FROM_L3MISS",
> +    "BriefDescription": "Demand LD - L3 Miss (not L2 hit and not L3 hit)"
> +  },
> +  {
> +    "EventCode": "0x400F0",
> +    "EventName": "PM_LD_MISS_L1",
> +    "BriefDescription": "L1 Dcache load miss"
> +  },
> +  {
> +    "EventCode": "0x400F2",
> +    "EventName": "PM_CYC_INST_DISP",
> +    "BriefDescription": "Cycle when instruction(s) dispatched."
> +  },
> +  {
> +    "EventCode": "0x400F6",
> +    "EventName": "PM_BR_MPRED_CMPL",
> +    "BriefDescription": "A mispredicted branch completed. Includes direction and target."
> +  },
> +  {
> +    "EventCode": "0x400FA",
> +    "EventName": "PM_RUN_INST_CMPL",
> +    "BriefDescription": "PowerPC instruction completed while the run latch is set."
> +  },
> +  {
> +    "EventCode": "0x400FC",
> +    "EventName": "PM_ITLB_MISS",
> +    "BriefDescription": "Instruction TLB reload (after a miss), all page sizes. Includes only demand misses."
> +  },
> +  {
> +    "EventCode": "0x400fe",
> +    "EventName": "PM_LD_NOT_CACHED",
> +    "BriefDescription": "Load data not cached."
> +  },
> +  {
> +    "EventCode": "0x500fa",
> +    "EventName": "PM_INST_CMPL",
> +    "BriefDescription": "Instructions."
> +  }
> +]
> diff --git a/tools/perf/pmu-events/arch/powerpc/mapfile.csv b/tools/perf/pmu-events/arch/powerpc/mapfile.csv
> index 4d5e9138d4cc..cbd3cb443784 100644
> --- a/tools/perf/pmu-events/arch/powerpc/mapfile.csv
> +++ b/tools/perf/pmu-events/arch/powerpc/mapfile.csv
> @@ -16,3 +16,4 @@
>  0x004e[[:xdigit:]]{4},1,power9,core
>  0x0080[[:xdigit:]]{4},1,power10,core
>  0x0082[[:xdigit:]]{4},1,power10,core
> +0x00ffffff,1,compat,core
> -- 
> 2.27.0
> 

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [PATCH V2 1/2] tools/perf/pmu-events/powerpc: Add support for compat events in json
  2024-10-16 17:34 ` [PATCH V2 1/2] tools/perf/pmu-events/powerpc: Add support for compat events in json Namhyung Kim
@ 2024-10-16 18:08   ` Athira Rajeev
  0 siblings, 0 replies; 8+ messages in thread
From: Athira Rajeev @ 2024-10-16 18:08 UTC (permalink / raw)
  To: Namhyung Kim
  Cc: acme, jolsa, adrian.hunter, irogers, hbathini, linux-kernel,
	linux-perf-users, linuxppc-dev, akanksha, maddy, kjain, disgoel



> On 16 Oct 2024, at 11:04 PM, Namhyung Kim <namhyung@kernel.org> wrote:
> 
> Hello Athira,
> 
> On Thu, Oct 10, 2024 at 08:21:06PM +0530, Athira Rajeev wrote:
>> perf list picks the events supported for specific platform
>> from pmu-events/arch/powerpc/<platform>. Example power10 events
>> are in pmu-events/arch/powerpc/power10, power9 events are part
>> of pmu-events/arch/powerpc/power9. The decision of which
>> platform to pick is determined based on PVR value in powerpc.
>> The PVR value is matched from pmu-events/arch/powerpc/mapfile.csv
>> 
>> Example:
>> 
>> Format:
>>        PVR,Version,JSON/file/pathname,Type
>> 
>> 0x004[bcd][[:xdigit:]]{4},1,power8,core
>> 0x0066[[:xdigit:]]{4},1,power8,core
>> 0x004e[[:xdigit:]]{4},1,power9,core
>> 0x0080[[:xdigit:]]{4},1,power10,core
>> 0x0082[[:xdigit:]]{4},1,power10,core
>> 
>> The code gets the PVR from system using get_cpuid_str function
>> in arch/powerpc/util/headers.c ( from SPRN_PVR ) and compares
>> with value from mapfile.csv
>> 
>> In case of compat mode, say when partition is booted in a power9
>> mode when the system is a power10, add an entry to pick the
>> ISA architected events from "pmu-events/arch/powerpc/compat".
>> Add json file generic-events.json which will contain these
>> events which is supported in compat mode.
>> 
>> Suggested-by: Madhavan Srinivasan <maddy@linux.ibm.com>
>> Signed-off-by: Athira Rajeev <atrajeev@linux.vnet.ibm.com>
> 
> Is this the latest version?
> 
> Thanks,
> Namhyung

Hi Namhyung

Yes, this is the latest version 

Thanks
Athira
> 
>> ---
>> 
>> .../arch/powerpc/compat/generic-events.json   | 117 ++++++++++++++++++
>> .../perf/pmu-events/arch/powerpc/mapfile.csv  |   1 +
>> 2 files changed, 118 insertions(+)
>> create mode 100644 tools/perf/pmu-events/arch/powerpc/compat/generic-events.json
>> 
>> diff --git a/tools/perf/pmu-events/arch/powerpc/compat/generic-events.json b/tools/perf/pmu-events/arch/powerpc/compat/generic-events.json
>> new file mode 100644
>> index 000000000000..6f5e8efcb098
>> --- /dev/null
>> +++ b/tools/perf/pmu-events/arch/powerpc/compat/generic-events.json
>> @@ -0,0 +1,117 @@
>> +[
>> +  {
>> +    "EventCode": "0x600F4",
>> +    "EventName": "PM_CYC",
>> +    "BriefDescription": "Processor cycles."
>> +  },
>> +  {
>> +    "EventCode": "0x100F2",
>> +    "EventName": "PM_CYC_INST_CMPL",
>> +    "BriefDescription": "1 or more ppc insts finished"
>> +  },
>> +  {
>> +    "EventCode": "0x100f4",
>> +    "EventName": "PM_FLOP_CMPL",
>> +    "BriefDescription": "Floating Point Operations Finished."
>> +  },
>> +  {
>> +    "EventCode": "0x100F6",
>> +    "EventName": "PM_L1_ITLB_MISS",
>> +    "BriefDescription": "Number of I-ERAT reloads."
>> +  },
>> +  {
>> +    "EventCode": "0x100F8",
>> +    "EventName": "PM_NO_INST_AVAIL",
>> +    "BriefDescription": "Number of cycles the ICT has no itags assigned to this thread."
>> +  },
>> +  {
>> +    "EventCode": "0x100fc",
>> +    "EventName": "PM_LD_CMPL",
>> +    "BriefDescription": "Load instruction completed."
>> +  },
>> +  {
>> +    "EventCode": "0x200F0",
>> +    "EventName": "PM_ST_CMPL",
>> +    "BriefDescription": "Stores completed from S2Q (2nd-level store queue)."
>> +  },
>> +  {
>> +    "EventCode": "0x200F2",
>> +    "EventName": "PM_INST_DISP",
>> +    "BriefDescription": "PowerPC instruction dispatched."
>> +  },
>> +  {
>> +    "EventCode": "0x200F4",
>> +    "EventName": "PM_RUN_CYC",
>> +    "BriefDescription": "Processor cycles gated by the run latch."
>> +  },
>> +  {
>> +    "EventCode": "0x200F6",
>> +    "EventName": "PM_L1_DTLB_RELOAD",
>> +    "BriefDescription": "DERAT Reloaded due to a DERAT miss."
>> +  },
>> +  {
>> +    "EventCode": "0x200FA",
>> +    "EventName": "PM_BR_TAKEN_CMPL",
>> +    "BriefDescription": "Branch Taken instruction completed."
>> +  },
>> +  {
>> +    "EventCode": "0x200FC",
>> +    "EventName": "PM_L1_ICACHE_MISS",
>> +    "BriefDescription": "Demand instruction cache miss."
>> +  },
>> +  {
>> +    "EventCode": "0x200FE",
>> +    "EventName": "PM_L1_RELOAD_FROM_MEM",
>> +    "BriefDescription": "L1 Dcache reload from memory"
>> +  },
>> +  {
>> +    "EventCode": "0x300F0",
>> +    "EventName": "PM_ST_MISS_L1",
>> +    "BriefDescription": "Store Missed L1"
>> +  },
>> +  {
>> +    "EventCode": "0x300FC",
>> +    "EventName": "PM_DTLB_MISS",
>> +    "BriefDescription": "Data PTEG reload"
>> +  },
>> +  {
>> +    "EventCode": "0x300FE",
>> +    "EventName": "PM_DATA_FROM_L3MISS",
>> +    "BriefDescription": "Demand LD - L3 Miss (not L2 hit and not L3 hit)"
>> +  },
>> +  {
>> +    "EventCode": "0x400F0",
>> +    "EventName": "PM_LD_MISS_L1",
>> +    "BriefDescription": "L1 Dcache load miss"
>> +  },
>> +  {
>> +    "EventCode": "0x400F2",
>> +    "EventName": "PM_CYC_INST_DISP",
>> +    "BriefDescription": "Cycle when instruction(s) dispatched."
>> +  },
>> +  {
>> +    "EventCode": "0x400F6",
>> +    "EventName": "PM_BR_MPRED_CMPL",
>> +    "BriefDescription": "A mispredicted branch completed. Includes direction and target."
>> +  },
>> +  {
>> +    "EventCode": "0x400FA",
>> +    "EventName": "PM_RUN_INST_CMPL",
>> +    "BriefDescription": "PowerPC instruction completed while the run latch is set."
>> +  },
>> +  {
>> +    "EventCode": "0x400FC",
>> +    "EventName": "PM_ITLB_MISS",
>> +    "BriefDescription": "Instruction TLB reload (after a miss), all page sizes. Includes only demand misses."
>> +  },
>> +  {
>> +    "EventCode": "0x400fe",
>> +    "EventName": "PM_LD_NOT_CACHED",
>> +    "BriefDescription": "Load data not cached."
>> +  },
>> +  {
>> +    "EventCode": "0x500fa",
>> +    "EventName": "PM_INST_CMPL",
>> +    "BriefDescription": "Instructions."
>> +  }
>> +]
>> diff --git a/tools/perf/pmu-events/arch/powerpc/mapfile.csv b/tools/perf/pmu-events/arch/powerpc/mapfile.csv
>> index 4d5e9138d4cc..cbd3cb443784 100644
>> --- a/tools/perf/pmu-events/arch/powerpc/mapfile.csv
>> +++ b/tools/perf/pmu-events/arch/powerpc/mapfile.csv
>> @@ -16,3 +16,4 @@
>> 0x004e[[:xdigit:]]{4},1,power9,core
>> 0x0080[[:xdigit:]]{4},1,power10,core
>> 0x0082[[:xdigit:]]{4},1,power10,core
>> +0x00ffffff,1,compat,core
>> -- 
>> 2.27.0



^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [PATCH V2 1/2] tools/perf/pmu-events/powerpc: Add support for compat events in json
  2024-10-10 14:51 [PATCH V2 1/2] tools/perf/pmu-events/powerpc: Add support for compat events in json Athira Rajeev
  2024-10-10 14:51 ` [PATCH V2 2/2] tools/perf/powerpc/util: Add support to handle compatible mode PVR for perf json events Athira Rajeev
  2024-10-16 17:34 ` [PATCH V2 1/2] tools/perf/pmu-events/powerpc: Add support for compat events in json Namhyung Kim
@ 2024-10-17 14:11 ` Disha Goel
  2024-10-18 15:20 ` Namhyung Kim
  3 siblings, 0 replies; 8+ messages in thread
From: Disha Goel @ 2024-10-17 14:11 UTC (permalink / raw)
  To: Athira Rajeev, acme, jolsa, adrian.hunter, irogers, namhyung,
	hbathini
  Cc: linux-kernel, linux-perf-users, linuxppc-dev, akanksha, maddy,
	kjain

On 10/10/24 8:21 pm, Athira Rajeev wrote:

> perf list picks the events supported for specific platform
> from pmu-events/arch/powerpc/<platform>. Example power10 events
> are in pmu-events/arch/powerpc/power10, power9 events are part
> of pmu-events/arch/powerpc/power9. The decision of which
> platform to pick is determined based on PVR value in powerpc.
> The PVR value is matched from pmu-events/arch/powerpc/mapfile.csv
>
> Example:
>
> Format:
>          PVR,Version,JSON/file/pathname,Type
>
> 0x004[bcd][[:xdigit:]]{4},1,power8,core
> 0x0066[[:xdigit:]]{4},1,power8,core
> 0x004e[[:xdigit:]]{4},1,power9,core
> 0x0080[[:xdigit:]]{4},1,power10,core
> 0x0082[[:xdigit:]]{4},1,power10,core
>
> The code gets the PVR from system using get_cpuid_str function
> in arch/powerpc/util/headers.c ( from SPRN_PVR ) and compares
> with value from mapfile.csv
>
> In case of compat mode, say when partition is booted in a power9
> mode when the system is a power10, add an entry to pick the
> ISA architected events from "pmu-events/arch/powerpc/compat".
> Add json file generic-events.json which will contain these
> events which is supported in compat mode.
>
> Suggested-by: Madhavan Srinivasan <maddy@linux.ibm.com>
> Signed-off-by: Athira Rajeev <atrajeev@linux.vnet.ibm.com>

I have tested the patch on PowerPC by booting in different compat modes and
at base also, and it's working as expected.

For the series:
Tested-by: Disha Goel<disgoel@linux.ibm.com>

> ---
>
>   .../arch/powerpc/compat/generic-events.json   | 117 ++++++++++++++++++
>   .../perf/pmu-events/arch/powerpc/mapfile.csv  |   1 +
>   2 files changed, 118 insertions(+)
>   create mode 100644 tools/perf/pmu-events/arch/powerpc/compat/generic-events.json
>
> diff --git a/tools/perf/pmu-events/arch/powerpc/compat/generic-events.json b/tools/perf/pmu-events/arch/powerpc/compat/generic-events.json
> new file mode 100644
> index 000000000000..6f5e8efcb098
> --- /dev/null
> +++ b/tools/perf/pmu-events/arch/powerpc/compat/generic-events.json
> @@ -0,0 +1,117 @@
> +[
> +  {
> +    "EventCode": "0x600F4",
> +    "EventName": "PM_CYC",
> +    "BriefDescription": "Processor cycles."
> +  },
> +  {
> +    "EventCode": "0x100F2",
> +    "EventName": "PM_CYC_INST_CMPL",
> +    "BriefDescription": "1 or more ppc insts finished"
> +  },
> +  {
> +    "EventCode": "0x100f4",
> +    "EventName": "PM_FLOP_CMPL",
> +    "BriefDescription": "Floating Point Operations Finished."
> +  },
> +  {
> +    "EventCode": "0x100F6",
> +    "EventName": "PM_L1_ITLB_MISS",
> +    "BriefDescription": "Number of I-ERAT reloads."
> +  },
> +  {
> +    "EventCode": "0x100F8",
> +    "EventName": "PM_NO_INST_AVAIL",
> +    "BriefDescription": "Number of cycles the ICT has no itags assigned to this thread."
> +  },
> +  {
> +    "EventCode": "0x100fc",
> +    "EventName": "PM_LD_CMPL",
> +    "BriefDescription": "Load instruction completed."
> +  },
> +  {
> +    "EventCode": "0x200F0",
> +    "EventName": "PM_ST_CMPL",
> +    "BriefDescription": "Stores completed from S2Q (2nd-level store queue)."
> +  },
> +  {
> +    "EventCode": "0x200F2",
> +    "EventName": "PM_INST_DISP",
> +    "BriefDescription": "PowerPC instruction dispatched."
> +  },
> +  {
> +    "EventCode": "0x200F4",
> +    "EventName": "PM_RUN_CYC",
> +    "BriefDescription": "Processor cycles gated by the run latch."
> +  },
> +  {
> +    "EventCode": "0x200F6",
> +    "EventName": "PM_L1_DTLB_RELOAD",
> +    "BriefDescription": "DERAT Reloaded due to a DERAT miss."
> +  },
> +  {
> +    "EventCode": "0x200FA",
> +    "EventName": "PM_BR_TAKEN_CMPL",
> +    "BriefDescription": "Branch Taken instruction completed."
> +  },
> +  {
> +    "EventCode": "0x200FC",
> +    "EventName": "PM_L1_ICACHE_MISS",
> +    "BriefDescription": "Demand instruction cache miss."
> +  },
> +  {
> +    "EventCode": "0x200FE",
> +    "EventName": "PM_L1_RELOAD_FROM_MEM",
> +    "BriefDescription": "L1 Dcache reload from memory"
> +  },
> +  {
> +    "EventCode": "0x300F0",
> +    "EventName": "PM_ST_MISS_L1",
> +    "BriefDescription": "Store Missed L1"
> +  },
> +  {
> +    "EventCode": "0x300FC",
> +    "EventName": "PM_DTLB_MISS",
> +    "BriefDescription": "Data PTEG reload"
> +  },
> +  {
> +    "EventCode": "0x300FE",
> +    "EventName": "PM_DATA_FROM_L3MISS",
> +    "BriefDescription": "Demand LD - L3 Miss (not L2 hit and not L3 hit)"
> +  },
> +  {
> +    "EventCode": "0x400F0",
> +    "EventName": "PM_LD_MISS_L1",
> +    "BriefDescription": "L1 Dcache load miss"
> +  },
> +  {
> +    "EventCode": "0x400F2",
> +    "EventName": "PM_CYC_INST_DISP",
> +    "BriefDescription": "Cycle when instruction(s) dispatched."
> +  },
> +  {
> +    "EventCode": "0x400F6",
> +    "EventName": "PM_BR_MPRED_CMPL",
> +    "BriefDescription": "A mispredicted branch completed. Includes direction and target."
> +  },
> +  {
> +    "EventCode": "0x400FA",
> +    "EventName": "PM_RUN_INST_CMPL",
> +    "BriefDescription": "PowerPC instruction completed while the run latch is set."
> +  },
> +  {
> +    "EventCode": "0x400FC",
> +    "EventName": "PM_ITLB_MISS",
> +    "BriefDescription": "Instruction TLB reload (after a miss), all page sizes. Includes only demand misses."
> +  },
> +  {
> +    "EventCode": "0x400fe",
> +    "EventName": "PM_LD_NOT_CACHED",
> +    "BriefDescription": "Load data not cached."
> +  },
> +  {
> +    "EventCode": "0x500fa",
> +    "EventName": "PM_INST_CMPL",
> +    "BriefDescription": "Instructions."
> +  }
> +]
> diff --git a/tools/perf/pmu-events/arch/powerpc/mapfile.csv b/tools/perf/pmu-events/arch/powerpc/mapfile.csv
> index 4d5e9138d4cc..cbd3cb443784 100644
> --- a/tools/perf/pmu-events/arch/powerpc/mapfile.csv
> +++ b/tools/perf/pmu-events/arch/powerpc/mapfile.csv
> @@ -16,3 +16,4 @@
>   0x004e[[:xdigit:]]{4},1,power9,core
>   0x0080[[:xdigit:]]{4},1,power10,core
>   0x0082[[:xdigit:]]{4},1,power10,core
> +0x00ffffff,1,compat,core

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [PATCH V2 1/2] tools/perf/pmu-events/powerpc: Add support for compat events in json
  2024-10-10 14:51 [PATCH V2 1/2] tools/perf/pmu-events/powerpc: Add support for compat events in json Athira Rajeev
                   ` (2 preceding siblings ...)
  2024-10-17 14:11 ` Disha Goel
@ 2024-10-18 15:20 ` Namhyung Kim
  3 siblings, 0 replies; 8+ messages in thread
From: Namhyung Kim @ 2024-10-18 15:20 UTC (permalink / raw)
  To: acme, jolsa, adrian.hunter, irogers, hbathini, Athira Rajeev
  Cc: linux-kernel, linux-perf-users, linuxppc-dev, akanksha, maddy,
	kjain, disgoel

On Thu, 10 Oct 2024 20:21:06 +0530, Athira Rajeev wrote:

> perf list picks the events supported for specific platform
> from pmu-events/arch/powerpc/<platform>. Example power10 events
> are in pmu-events/arch/powerpc/power10, power9 events are part
> of pmu-events/arch/powerpc/power9. The decision of which
> platform to pick is determined based on PVR value in powerpc.
> The PVR value is matched from pmu-events/arch/powerpc/mapfile.csv
> 
> [...]

Applied to perf-tools-next, thanks!

Best regards,
Namhyung


^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [PATCH V2 2/2] tools/perf/powerpc/util: Add support to handle compatible mode PVR for perf json events
  2024-10-10 14:51 ` [PATCH V2 2/2] tools/perf/powerpc/util: Add support to handle compatible mode PVR for perf json events Athira Rajeev
@ 2025-03-21 10:34   ` Christophe Leroy
  2025-03-21 11:42     ` Madhavan Srinivasan
  0 siblings, 1 reply; 8+ messages in thread
From: Christophe Leroy @ 2025-03-21 10:34 UTC (permalink / raw)
  To: Athira Rajeev, namhyung
  Cc: linux-kernel, linux-perf-users, linuxppc-dev, irogers, akanksha,
	maddy, kjain, disgoel, acme, hbathini, adrian.hunter, jolsa

Hi,

Le 10/10/2024 à 16:51, Athira Rajeev a écrit :
> perf list picks the events supported for specific platform
> from pmu-events/arch/powerpc/<platform>. Example power10 events
> are in pmu-events/arch/powerpc/power10, power9 events are part
> of pmu-events/arch/powerpc/power9. The decision of which
> platform to pick is determined based on PVR value in powerpc.
> The PVR value is matched from pmu-events/arch/powerpc/mapfile.csv
> 
> Example:
> 
> Format:
> 	PVR,Version,JSON/file/pathname,Type
> 
> 0x004[bcd][[:xdigit:]]{4},1,power8,core
> 0x0066[[:xdigit:]]{4},1,power8,core
> 0x004e[[:xdigit:]]{4},1,power9,core
> 0x0080[[:xdigit:]]{4},1,power10,core
> 0x0082[[:xdigit:]]{4},1,power10,core
> 
> The code gets the PVR from system using get_cpuid_str function
> in arch/powerpc/util/headers.c ( from SPRN_PVR ) and compares
> with value from mapfile.csv
> In case of compat mode, say when partition is booted in a power9
> mode when the system is a power10, this picks incorrectly. Because
> PVR will point to power10 where as it should pick events from power9
> folder. To support generic events, add new folder
> pmu-events/arch/powerpc/compat to contain the ISA architected events
> which is supported in compat mode. Also return 0x00ffffff as pvr
> when booted in compat mode. Based on this pvr value, json will
> pick events from pmu-events/arch/powerpc/compat
> 
> Suggested-by: Madhavan Srinivasan <maddy@linux.ibm.com>
> Signed-off-by: Athira Rajeev <atrajeev@linux.vnet.ibm.com>

I see this patch was merged into mainline allthough it had CI failures 
and still has.

Could you please fix it ?

arch/powerpc/util/header.c: In function 'is_compat_mode':
Error: arch/powerpc/util/header.c:20:14: error: cast to pointer from 
integer of different size [-Werror=int-to-pointer-cast]
    20 |  if (!strcmp((char *)platform, (char *)base_platform))
       |              ^
Error: arch/powerpc/util/header.c:20:32: error: cast to pointer from 
integer of different size [-Werror=int-to-pointer-cast]
    20 |  if (!strcmp((char *)platform, (char *)base_platform))
       |                                ^
cc1: all warnings being treated as errors
make[6]: *** [/linux/tools/build/Makefile.build:86: 
/output/arch/powerpc/util/header.o] Error 1


The following fix but is maybe not the right one as in reality 
getauxval() seems to return a long not a u64.

diff --git a/tools/perf/arch/powerpc/util/header.c 
b/tools/perf/arch/powerpc/util/header.c
index c7df534dbf8f..1b045d410f31 100644
--- a/tools/perf/arch/powerpc/util/header.c
+++ b/tools/perf/arch/powerpc/util/header.c
@@ -17,7 +17,7 @@ static bool is_compat_mode(void)
  	u64 base_platform = getauxval(AT_BASE_PLATFORM);
  	u64 platform = getauxval(AT_PLATFORM);

-	if (!strcmp((char *)platform, (char *)base_platform))
+	if (!strcmp((char *)(long)platform, (char *)(long)base_platform))
  		return false;

  	return true;


Thanks
Christophe

> ---
> changelog:
> V1 -> V2:
> Corrected commit message and subject line
> 
>   tools/perf/arch/powerpc/util/header.c | 32 ++++++++++++++++++++++++++-
>   1 file changed, 31 insertions(+), 1 deletion(-)
> 
> diff --git a/tools/perf/arch/powerpc/util/header.c b/tools/perf/arch/powerpc/util/header.c
> index 6b00efd53638..adc82c479443 100644
> --- a/tools/perf/arch/powerpc/util/header.c
> +++ b/tools/perf/arch/powerpc/util/header.c
> @@ -10,6 +10,18 @@
>   #include "utils_header.h"
>   #include "metricgroup.h"
>   #include <api/fs/fs.h>
> +#include <sys/auxv.h>
> +
> +static bool is_compat_mode(void)
> +{
> +	u64 base_platform = getauxval(AT_BASE_PLATFORM);
> +	u64 platform = getauxval(AT_PLATFORM);
> +
> +	if (!strcmp((char *)platform, (char *)base_platform))
> +		return false;
> +
> +	return true;
> +}
>   
>   int
>   get_cpuid(char *buffer, size_t sz)
> @@ -33,8 +45,26 @@ char *
>   get_cpuid_str(struct perf_pmu *pmu __maybe_unused)
>   {
>   	char *bufp;
> +	unsigned long pvr;
> +
> +	/*
> +	 * IBM Power System supports compatible mode. That is
> +	 * Nth generation platform can support previous generation
> +	 * OS in a mode called compatibile mode. For ex. LPAR can be
> +	 * booted in a Power9 mode when the system is a Power10.
> +	 *
> +	 * In the compatible mode, care must be taken when generating
> +	 * PVR value. When read, PVR will be of the AT_BASE_PLATFORM
> +	 * To support generic events, return 0x00ffffff as pvr when
> +	 * booted in compat mode. Based on this pvr value, json will
> +	 * pick events from pmu-events/arch/powerpc/compat
> +	 */
> +	if (!is_compat_mode())
> +		pvr = mfspr(SPRN_PVR);
> +	else
> +		pvr = 0x00ffffff;
>   
> -	if (asprintf(&bufp, "0x%.8lx", mfspr(SPRN_PVR)) < 0)
> +	if (asprintf(&bufp, "0x%.8lx", pvr) < 0)
>   		bufp = NULL;
>   
>   	return bufp;


^ permalink raw reply related	[flat|nested] 8+ messages in thread

* Re: [PATCH V2 2/2] tools/perf/powerpc/util: Add support to handle compatible mode PVR for perf json events
  2025-03-21 10:34   ` Christophe Leroy
@ 2025-03-21 11:42     ` Madhavan Srinivasan
  0 siblings, 0 replies; 8+ messages in thread
From: Madhavan Srinivasan @ 2025-03-21 11:42 UTC (permalink / raw)
  To: Christophe Leroy, Athira Rajeev, namhyung
  Cc: linux-kernel, linux-perf-users, linuxppc-dev, irogers, akanksha,
	kjain, disgoel, acme, hbathini, adrian.hunter, jolsa



On 3/21/25 4:04 PM, Christophe Leroy wrote:
> Hi,
> 
> Le 10/10/2024 à 16:51, Athira Rajeev a écrit :
>> perf list picks the events supported for specific platform
>> from pmu-events/arch/powerpc/<platform>. Example power10 events
>> are in pmu-events/arch/powerpc/power10, power9 events are part
>> of pmu-events/arch/powerpc/power9. The decision of which
>> platform to pick is determined based on PVR value in powerpc.
>> The PVR value is matched from pmu-events/arch/powerpc/mapfile.csv
>>
>> Example:
>>
>> Format:
>>     PVR,Version,JSON/file/pathname,Type
>>
>> 0x004[bcd][[:xdigit:]]{4},1,power8,core
>> 0x0066[[:xdigit:]]{4},1,power8,core
>> 0x004e[[:xdigit:]]{4},1,power9,core
>> 0x0080[[:xdigit:]]{4},1,power10,core
>> 0x0082[[:xdigit:]]{4},1,power10,core
>>
>> The code gets the PVR from system using get_cpuid_str function
>> in arch/powerpc/util/headers.c ( from SPRN_PVR ) and compares
>> with value from mapfile.csv
>> In case of compat mode, say when partition is booted in a power9
>> mode when the system is a power10, this picks incorrectly. Because
>> PVR will point to power10 where as it should pick events from power9
>> folder. To support generic events, add new folder
>> pmu-events/arch/powerpc/compat to contain the ISA architected events
>> which is supported in compat mode. Also return 0x00ffffff as pvr
>> when booted in compat mode. Based on this pvr value, json will
>> pick events from pmu-events/arch/powerpc/compat
>>
>> Suggested-by: Madhavan Srinivasan <maddy@linux.ibm.com>
>> Signed-off-by: Athira Rajeev <atrajeev@linux.vnet.ibm.com>
> 
> I see this patch was merged into mainline allthough it had CI failures and still has.
> 
> Could you please fix it ?

We already have a fix patch posted for this issue 

https://patchwork.ozlabs.org/project/linuxppc-dev/patch/20250321100726.699956-1-likhitha@linux.ibm.com/

Maddy


> 
> arch/powerpc/util/header.c: In function 'is_compat_mode':
> Error: arch/powerpc/util/header.c:20:14: error: cast to pointer from integer of different size [-Werror=int-to-pointer-cast]
>    20 |  if (!strcmp((char *)platform, (char *)base_platform))
>       |              ^
> Error: arch/powerpc/util/header.c:20:32: error: cast to pointer from integer of different size [-Werror=int-to-pointer-cast]
>    20 |  if (!strcmp((char *)platform, (char *)base_platform))
>       |                                ^
> cc1: all warnings being treated as errors
> make[6]: *** [/linux/tools/build/Makefile.build:86: /output/arch/powerpc/util/header.o] Error 1
> 
> 
> The following fix but is maybe not the right one as in reality getauxval() seems to return a long not a u64.
> 
> diff --git a/tools/perf/arch/powerpc/util/header.c b/tools/perf/arch/powerpc/util/header.c
> index c7df534dbf8f..1b045d410f31 100644
> --- a/tools/perf/arch/powerpc/util/header.c
> +++ b/tools/perf/arch/powerpc/util/header.c
> @@ -17,7 +17,7 @@ static bool is_compat_mode(void)
>      u64 base_platform = getauxval(AT_BASE_PLATFORM);
>      u64 platform = getauxval(AT_PLATFORM);
> 
> -    if (!strcmp((char *)platform, (char *)base_platform))
> +    if (!strcmp((char *)(long)platform, (char *)(long)base_platform))
>          return false;
> 
>      return true;
> 
> 
> Thanks
> Christophe
> 
>> ---
>> changelog:
>> V1 -> V2:
>> Corrected commit message and subject line
>>
>>   tools/perf/arch/powerpc/util/header.c | 32 ++++++++++++++++++++++++++-
>>   1 file changed, 31 insertions(+), 1 deletion(-)
>>
>> diff --git a/tools/perf/arch/powerpc/util/header.c b/tools/perf/arch/powerpc/util/header.c
>> index 6b00efd53638..adc82c479443 100644
>> --- a/tools/perf/arch/powerpc/util/header.c
>> +++ b/tools/perf/arch/powerpc/util/header.c
>> @@ -10,6 +10,18 @@
>>   #include "utils_header.h"
>>   #include "metricgroup.h"
>>   #include <api/fs/fs.h>
>> +#include <sys/auxv.h>
>> +
>> +static bool is_compat_mode(void)
>> +{
>> +    u64 base_platform = getauxval(AT_BASE_PLATFORM);
>> +    u64 platform = getauxval(AT_PLATFORM);
>> +
>> +    if (!strcmp((char *)platform, (char *)base_platform))
>> +        return false;
>> +
>> +    return true;
>> +}
>>     int
>>   get_cpuid(char *buffer, size_t sz)
>> @@ -33,8 +45,26 @@ char *
>>   get_cpuid_str(struct perf_pmu *pmu __maybe_unused)
>>   {
>>       char *bufp;
>> +    unsigned long pvr;
>> +
>> +    /*
>> +     * IBM Power System supports compatible mode. That is
>> +     * Nth generation platform can support previous generation
>> +     * OS in a mode called compatibile mode. For ex. LPAR can be
>> +     * booted in a Power9 mode when the system is a Power10.
>> +     *
>> +     * In the compatible mode, care must be taken when generating
>> +     * PVR value. When read, PVR will be of the AT_BASE_PLATFORM
>> +     * To support generic events, return 0x00ffffff as pvr when
>> +     * booted in compat mode. Based on this pvr value, json will
>> +     * pick events from pmu-events/arch/powerpc/compat
>> +     */
>> +    if (!is_compat_mode())
>> +        pvr = mfspr(SPRN_PVR);
>> +    else
>> +        pvr = 0x00ffffff;
>>   -    if (asprintf(&bufp, "0x%.8lx", mfspr(SPRN_PVR)) < 0)
>> +    if (asprintf(&bufp, "0x%.8lx", pvr) < 0)
>>           bufp = NULL;
>>         return bufp;
> 


^ permalink raw reply	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2025-03-21 11:42 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-10-10 14:51 [PATCH V2 1/2] tools/perf/pmu-events/powerpc: Add support for compat events in json Athira Rajeev
2024-10-10 14:51 ` [PATCH V2 2/2] tools/perf/powerpc/util: Add support to handle compatible mode PVR for perf json events Athira Rajeev
2025-03-21 10:34   ` Christophe Leroy
2025-03-21 11:42     ` Madhavan Srinivasan
2024-10-16 17:34 ` [PATCH V2 1/2] tools/perf/pmu-events/powerpc: Add support for compat events in json Namhyung Kim
2024-10-16 18:08   ` Athira Rajeev
2024-10-17 14:11 ` Disha Goel
2024-10-18 15:20 ` Namhyung Kim

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).