Add extended regs to sample_reg_mask in the tool side to use with `-I?` option. Perf tools side uses extended mask to display the platform supported register names (with -I? option) to the user and also send this mask to the kernel to capture the extended registers in each sample. Hence decide the mask value based on the processor version. Currently definitions for `mfspr`, `SPRN_PVR` are part of `arch/powerpc/util/header.c`. Move this to a header file so that these definitions can be re-used in other source files as well. Signed-off-by: Anju T Sudhakar <anju@linux.vnet.ibm.com> Reviewed-by: Kajol Jain <kjain@linux.ibm.com> Reviewed-by: Madhavan Srinivasan <maddy@linux.vnet.ibm.com> Reviewed--by: Ravi Bangoria <ravi.bangoria@linux.ibm.com> Tested-by: Ravi Bangoria <ravi.bangoria@linux.ibm.com> Cc: Jiri Olsa <jolsa@kernel.org> Cc: Michael Ellerman <mpe@ellerman.id.au> Cc: Michael Neuling <mikey@neuling.org> <mikey@neuling.org> Cc: Ravi Bangoria <ravi.bangoria@linux.ibm.com> Cc: linuxppc-dev@lists.ozlabs.org [Decide extended mask at run time based on platform] Signed-off-by: Athira Jajeev <atrajeev@linux.vnet.ibm.com> Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
47 lines
884 B
C
47 lines
884 B
C
// SPDX-License-Identifier: GPL-2.0
|
|
#include <sys/types.h>
|
|
#include <errno.h>
|
|
#include <unistd.h>
|
|
#include <stdio.h>
|
|
#include <stdlib.h>
|
|
#include <string.h>
|
|
#include <linux/stringify.h>
|
|
#include "header.h"
|
|
#include "utils_header.h"
|
|
#include "metricgroup.h"
|
|
#include <api/fs/fs.h>
|
|
|
|
int
|
|
get_cpuid(char *buffer, size_t sz)
|
|
{
|
|
unsigned long pvr;
|
|
int nb;
|
|
|
|
pvr = mfspr(SPRN_PVR);
|
|
|
|
nb = scnprintf(buffer, sz, "%lu,%lu$", PVR_VER(pvr), PVR_REV(pvr));
|
|
|
|
/* look for end marker to ensure the entire data fit */
|
|
if (strchr(buffer, '$')) {
|
|
buffer[nb-1] = '\0';
|
|
return 0;
|
|
}
|
|
return ENOBUFS;
|
|
}
|
|
|
|
char *
|
|
get_cpuid_str(struct perf_pmu *pmu __maybe_unused)
|
|
{
|
|
char *bufp;
|
|
|
|
if (asprintf(&bufp, "%.8lx", mfspr(SPRN_PVR)) < 0)
|
|
bufp = NULL;
|
|
|
|
return bufp;
|
|
}
|
|
|
|
int arch_get_runtimeparam(void)
|
|
{
|
|
int count;
|
|
return sysfs__read_int("/devices/hv_24x7/interface/sockets", &count) < 0 ? 1 : count;
|
|
}
|