forked from luck/tmp_suning_uos_patched
f5a489dc81
This patch adds passing of pmu_event as a parameter in function 'arch_get_runtimeparam' which can be used to get details like if the event is percore/perchip. Signed-off-by: Kajol Jain <kjain@linux.ibm.com> Acked-by: Ian Rogers <irogers@google.com> Acked-by: Jiri Olsa <jolsa@redhat.com> Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com> Cc: Andi Kleen <ak@linux.intel.com> Cc: Jin Yao <yao.jin@linux.intel.com> Cc: John Garry <john.garry@huawei.com> Cc: Madhavan Srinivasan <maddy@linux.ibm.com> Cc: Mark Rutland <mark.rutland@arm.com> Cc: Namhyung Kim <namhyung@kernel.org> Cc: Paul Clarke <pc@us.ibm.com> Cc: Peter Zijlstra <peterz@infradead.org> Cc: Ravi Bangoria <ravi.bangoria@linux.ibm.com> Link: http://lore.kernel.org/lkml/20200907064133.75090-5-kjain@linux.ibm.com Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
51 lines
1013 B
C
51 lines
1013 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(struct pmu_event *pe)
|
|
{
|
|
int count;
|
|
char path[PATH_MAX] = "/devices/hv_24x7/interface/";
|
|
|
|
atoi(pe->aggr_mode) == PerChip ? strcat(path, "sockets") : strcat(path, "coresperchip");
|
|
return sysfs__read_int(path, &count) < 0 ? 1 : count;
|
|
}
|