Contributors: 6
| Author |
Tokens |
Token Proportion |
Commits |
Commit Proportion |
| Stéphane Eranian |
117 |
59.09% |
1 |
11.11% |
| Sukadev Bhattiprolu |
38 |
19.19% |
2 |
22.22% |
| Kajol Jain |
31 |
15.66% |
1 |
11.11% |
| Arnaldo Carvalho de Melo |
6 |
3.03% |
3 |
33.33% |
| Ganapatrao Kulkarni |
5 |
2.53% |
1 |
11.11% |
| Greg Kroah-Hartman |
1 |
0.51% |
1 |
11.11% |
| Total |
198 |
|
9 |
|
// 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 "metricgroup.h"
#include <api/fs/fs.h>
#define mfspr(rn) ({unsigned long rval; \
asm volatile("mfspr %0," __stringify(rn) \
: "=r" (rval)); rval; })
#define SPRN_PVR 0x11F /* Processor Version Register */
#define PVR_VER(pvr) (((pvr) >> 16) & 0xFFFF) /* Version field */
#define PVR_REV(pvr) (((pvr) >> 0) & 0xFFFF) /* Revison field */
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;
}