mirror of
https://kernel.googlesource.com/pub/scm/linux/kernel/git/stable/linux-stable.git
synced 2025-09-13 11:07:46 +10:00
This will allow writing formulas that are conditional on a specific CPU type or CPU version. It calls through to the existing strcmp_cpuid_str() function in Perf which has a default weak version, and an arch specific version for x86 and arm64. The function takes an 'ID' type value, which is a string. But in this case Arm CPU IDs are hex numbers prefixed with '0x'. metric.py assumes strings are only used by event names, and that they can't start with a number ('0'), so an additional change has to be made to the regex to convert hex numbers back to 'ID' types. Signed-off-by: James Clark <james.clark@arm.com> Reviewed-by: John Garry <john.g.garry@oracle.com> Cc: Adrian Hunter <adrian.hunter@intel.com> Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com> Cc: Eduard Zingerman <eddyz87@gmail.com> Cc: Haixin Yu <yuhaixin.yhx@linux.alibaba.com> Cc: Ian Rogers <irogers@google.com> Cc: Ingo Molnar <mingo@redhat.com> Cc: Jing Zhang <renyu.zj@linux.alibaba.com> Cc: Jiri Olsa <jolsa@kernel.org> Cc: Kajol Jain <kjain@linux.ibm.com> Cc: Kan Liang <kan.liang@linux.intel.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: Nick Forrington <nick.forrington@arm.com> Cc: Peter Zijlstra <peterz@infradead.org> Cc: Rob Herring <robh@kernel.org> Cc: Sohom Datta <sohomdatta1@gmail.com> Cc: Will Deacon <will@kernel.org> Cc: linux-arm-kernel@lists.infradead.org Link: https://lore.kernel.org/r/20230816114841.1679234-5-james.clark@arm.com Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
50 lines
1.1 KiB
C
50 lines
1.1 KiB
C
// SPDX-License-Identifier: GPL-2.0
|
|
|
|
#include <internal/cpumap.h>
|
|
#include "../../../util/cpumap.h"
|
|
#include "../../../util/header.h"
|
|
#include "../../../util/pmu.h"
|
|
#include "../../../util/pmus.h"
|
|
#include <api/fs/fs.h>
|
|
#include <math.h>
|
|
|
|
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;
|
|
}
|