mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
synced 2026-05-29 13:35:31 -04:00
Commitf8ad6018ce("perf pmu: Remove duplication around EVENT_SOURCE_DEVICE_PATH") uses sysfs__read_ull() to read a full sysfs path, which will never succeeds as it already comes with the sysfs mount point in it, which sysfs__read_ull() will add again. Fix it by reading the file using filename__read_ull(), that will not add the sysfs mount point. Fixes:f8ad6018ce("perf pmu: Remove duplication around EVENT_SOURCE_DEVICE_PATH") Signed-off-by: Haixin Yu <yuhaixin.yhx@linux.alibaba.com> Tested-by: Jing Zhang <renyu.zj@linux.alibaba.com> Cc: Adrian Hunter <adrian.hunter@intel.com> Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com> Cc: Ian Rogers <irogers@google.com> Cc: Ingo Molnar <mingo@redhat.com> Cc: James Clark <james.clark@arm.com> Cc: Jiri Olsa <jolsa@kernel.org> Cc: John Garry <john.g.garry@oracle.com> Cc: Leo Yan <leo.yan@linaro.org> Cc: Mark Rutland <mark.rutland@arm.com> Cc: Mike Leach <mike.leach@linaro.org> Cc: Namhyung Kim <namhyung@kernel.org> Cc: Peter Zijlstra <peterz@infradead.org> Cc: Will Deacon <will@kernel.org> Cc: linux-arm-kernel@lists.infradead.org Link: https://lore.kernel.org/r/ZL4G7rWXkfv-Ectq@B-Q60VQ05P-2326.local Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
66 lines
1.4 KiB
C
66 lines
1.4 KiB
C
// SPDX-License-Identifier: GPL-2.0
|
|
|
|
#include <internal/cpumap.h>
|
|
#include "../../../util/cpumap.h"
|
|
#include "../../../util/pmu.h"
|
|
#include "../../../util/pmus.h"
|
|
#include <api/fs/fs.h>
|
|
#include <math.h>
|
|
|
|
static struct perf_pmu *pmu__find_core_pmu(void)
|
|
{
|
|
struct perf_pmu *pmu = NULL;
|
|
|
|
while ((pmu = perf_pmus__scan_core(pmu))) {
|
|
/*
|
|
* The cpumap should cover all CPUs. Otherwise, some CPUs may
|
|
* not support some events or have different event IDs.
|
|
*/
|
|
if (RC_CHK_ACCESS(pmu->cpus)->nr != cpu__max_cpu().cpu)
|
|
return NULL;
|
|
|
|
return pmu;
|
|
}
|
|
return NULL;
|
|
}
|
|
|
|
const struct pmu_metrics_table *pmu_metrics_table__find(void)
|
|
{
|
|
struct perf_pmu *pmu = pmu__find_core_pmu();
|
|
|
|
if (pmu)
|
|
return perf_pmu__find_metrics_table(pmu);
|
|
|
|
return NULL;
|
|
}
|
|
|
|
const struct pmu_events_table *pmu_events_table__find(void)
|
|
{
|
|
struct perf_pmu *pmu = pmu__find_core_pmu();
|
|
|
|
if (pmu)
|
|
return perf_pmu__find_events_table(pmu);
|
|
|
|
return NULL;
|
|
}
|
|
|
|
double perf_pmu__cpu_slots_per_cycle(void)
|
|
{
|
|
char path[PATH_MAX];
|
|
unsigned long long slots = 0;
|
|
struct perf_pmu *pmu = pmu__find_core_pmu();
|
|
|
|
if (pmu) {
|
|
perf_pmu__pathname_scnprintf(path, sizeof(path),
|
|
pmu->name, "caps/slots");
|
|
/*
|
|
* The value of slots is not greater than 32 bits, but
|
|
* filename__read_int can't read value with 0x prefix,
|
|
* so use filename__read_ull instead.
|
|
*/
|
|
filename__read_ull(path, &slots);
|
|
}
|
|
|
|
return slots ? (double)slots : NAN;
|
|
}
|