Skip to content

Commit 091e779

Browse files
committed
tools/perf/powerpc/util: Add support to handle compatible mode PVR for perf json events
JIRA: https://issues.redhat.com/browse/RHEL-77935 upstream ======== commit 54f9aa1 Author: Athira Rajeev <atrajeev@linux.vnet.ibm.com> Date: Thu Oct 10 20:21:07 2024 +0530 description =========== 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> Tested-by: Disha Goel<disgoel@linux.ibm.com> Cc: akanksha@linux.ibm.com Cc: hbathini@linux.ibm.com Cc: kjain@linux.ibm.com Cc: linuxppc-dev@lists.ozlabs.org Link: https://lore.kernel.org/r/20241010145107.51211-2-atrajeev@linux.vnet.ibm.com Signed-off-by: Namhyung Kim <namhyung@kernel.org> Signed-off-by: Michael Petlan <mpetlan@redhat.com>
1 parent 4dda713 commit 091e779

File tree

1 file changed

+31
-1
lines changed

1 file changed

+31
-1
lines changed

tools/perf/arch/powerpc/util/header.c

Lines changed: 31 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,18 @@
1010
#include "utils_header.h"
1111
#include "metricgroup.h"
1212
#include <api/fs/fs.h>
13+
#include <sys/auxv.h>
14+
15+
static bool is_compat_mode(void)
16+
{
17+
u64 base_platform = getauxval(AT_BASE_PLATFORM);
18+
u64 platform = getauxval(AT_PLATFORM);
19+
20+
if (!strcmp((char *)platform, (char *)base_platform))
21+
return false;
22+
23+
return true;
24+
}
1325

1426
int
1527
get_cpuid(char *buffer, size_t sz)
@@ -33,8 +45,26 @@ char *
3345
get_cpuid_str(struct perf_pmu *pmu __maybe_unused)
3446
{
3547
char *bufp;
48+
unsigned long pvr;
49+
50+
/*
51+
* IBM Power System supports compatible mode. That is
52+
* Nth generation platform can support previous generation
53+
* OS in a mode called compatibile mode. For ex. LPAR can be
54+
* booted in a Power9 mode when the system is a Power10.
55+
*
56+
* In the compatible mode, care must be taken when generating
57+
* PVR value. When read, PVR will be of the AT_BASE_PLATFORM
58+
* To support generic events, return 0x00ffffff as pvr when
59+
* booted in compat mode. Based on this pvr value, json will
60+
* pick events from pmu-events/arch/powerpc/compat
61+
*/
62+
if (!is_compat_mode())
63+
pvr = mfspr(SPRN_PVR);
64+
else
65+
pvr = 0x00ffffff;
3666

37-
if (asprintf(&bufp, "0x%.8lx", mfspr(SPRN_PVR)) < 0)
67+
if (asprintf(&bufp, "0x%.8lx", pvr) < 0)
3868
bufp = NULL;
3969

4070
return bufp;

0 commit comments

Comments
 (0)