summaryrefslogtreecommitdiff
path: root/tools/perf/arch/arm64/util/pmu.c
diff options
context:
space:
mode:
authorJiri Kosina <jkosina@suse.cz>2023-04-26 23:52:34 +0300
committerJiri Kosina <jkosina@suse.cz>2023-04-26 23:52:34 +0300
commitcdc780f044a803aff8845b949f800f0f3d095d5f (patch)
tree6695a80568f6b4aef414070f17859f434e229957 /tools/perf/arch/arm64/util/pmu.c
parent38518593ec55e897abda4b4be77b2ec8ec4447d1 (diff)
parent37386669887d3f2ccf021322c5558353d20f2387 (diff)
downloadlinux-cdc780f044a803aff8845b949f800f0f3d095d5f.tar.xz
Merge branch 'for-6.4/amd-sfh' into for-linus
- assorted functional fixes for amd-sfh driver (Basavaraj Natikar)
Diffstat (limited to 'tools/perf/arch/arm64/util/pmu.c')
-rw-r--r--tools/perf/arch/arm64/util/pmu.c44
1 files changed, 42 insertions, 2 deletions
diff --git a/tools/perf/arch/arm64/util/pmu.c b/tools/perf/arch/arm64/util/pmu.c
index 477e513972a4..fa143acb4c8d 100644
--- a/tools/perf/arch/arm64/util/pmu.c
+++ b/tools/perf/arch/arm64/util/pmu.c
@@ -3,8 +3,10 @@
#include <internal/cpumap.h>
#include "../../../util/cpumap.h"
#include "../../../util/pmu.h"
+#include <api/fs/fs.h>
+#include <math.h>
-const struct pmu_events_table *pmu_events_table__find(void)
+static struct perf_pmu *pmu__find_core_pmu(void)
{
struct perf_pmu *pmu = NULL;
@@ -19,8 +21,46 @@ const struct pmu_events_table *pmu_events_table__find(void)
if (pmu->cpus->nr != cpu__max_cpu().cpu)
return NULL;
- return perf_pmu__find_table(pmu);
+ 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 sysfs__read_int
+ * can't read value with 0x prefix, so use sysfs__read_ull instead.
+ */
+ sysfs__read_ull(path, &slots);
+ }
+
+ return slots ? (double)slots : NAN;
+}