]> asedeno.scripts.mit.edu Git - linux.git/commitdiff
perf tools: Read and store caps/max_precise in perf_pmu
authorJiri Olsa <jolsa@kernel.org>
Tue, 5 Mar 2019 15:25:32 +0000 (16:25 +0100)
committerArnaldo Carvalho de Melo <acme@redhat.com>
Wed, 6 Mar 2019 21:18:17 +0000 (18:18 -0300)
Read the caps/max_precise value and store it in struct perf_pmu to be
used when setting the maximum precise_ip field in following patch.

Signed-off-by: Jiri Olsa <jolsa@kernel.org>
Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
Cc: Andi Kleen <ak@linux.intel.com>
Cc: Jonas Rabenstein <jonas.rabenstein@studium.uni-erlangen.de>
Cc: Nageswara R Sastry <nasastry@in.ibm.com>
Cc: Namhyung Kim <namhyung@kernel.org>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Ravi Bangoria <ravi.bangoria@linux.ibm.com>
Link: http://lkml.kernel.org/r/20190305152536.21035-5-jolsa@kernel.org
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
tools/perf/util/pmu.c
tools/perf/util/pmu.h

index 51d437f55d18c3b201f7f13d2408732b8cc0c8d1..6199a3174ab95eccd1c135dc7d477161296f9883 100644 (file)
@@ -752,6 +752,19 @@ perf_pmu__get_default_config(struct perf_pmu *pmu __maybe_unused)
        return NULL;
 }
 
+static int pmu_max_precise(const char *name)
+{
+       char path[PATH_MAX];
+       int max_precise = -1;
+
+       scnprintf(path, PATH_MAX,
+                "bus/event_source/devices/%s/caps/max_precise",
+                name);
+
+       sysfs__read_int(path, &max_precise);
+       return max_precise;
+}
+
 static struct perf_pmu *pmu_lookup(const char *name)
 {
        struct perf_pmu *pmu;
@@ -784,6 +797,7 @@ static struct perf_pmu *pmu_lookup(const char *name)
        pmu->name = strdup(name);
        pmu->type = type;
        pmu->is_uncore = pmu_is_uncore(name);
+       pmu->max_precise = pmu_max_precise(name);
        pmu_add_cpu_aliases(&aliases, pmu);
 
        INIT_LIST_HEAD(&pmu->format);
index 47253c3daf55b8cc6f8e4849f300101f8786fc3d..bd9ec2704a579c606f47cc90c4052dd229869995 100644 (file)
@@ -26,6 +26,7 @@ struct perf_pmu {
        __u32 type;
        bool selectable;
        bool is_uncore;
+       int max_precise;
        struct perf_event_attr *default_config;
        struct cpu_map *cpus;
        struct list_head format;  /* HEAD struct perf_pmu_format -> list */