5 #include "../../util/debug.h"
6 #include "../../util/header.h"
11 static int _get_cpuid(char *buf, size_t sz)
13 const char *sysfs = sysfs__mountpoint();
18 if (!sysfs || sz < ID_SIZE)
21 scnprintf(path, PATH_MAX, "%s/devices/platform/riscv-pmu/id",
24 file = fopen(path, "r");
26 pr_debug("fopen failed for file %s\n", path);
29 if (!fgets(buf, ID_SIZE, file)) {
36 /*Check if value is numeric and remove special characters*/
37 id = strtoul(buf, NULL, 16);
40 scnprintf(buf, ID_SIZE, "0x%lx", id);
45 char *get_cpuid_str(struct perf_pmu *pmu __maybe_unused)
53 buf = malloc(ID_SIZE);
58 res = _get_cpuid(buf, ID_SIZE);
60 pr_err("failed to get cpuid string for PMU %s\n", pmu->name);