diff options
| author | Jiri Olsa <jolsa@kernel.org> | 2019-03-05 10:25:32 -0500 |
|---|---|---|
| committer | Arnaldo Carvalho de Melo <acme@redhat.com> | 2019-03-06 16:18:17 -0500 |
| commit | 90a86bde97ba050cb3c9ccb215252ee2d2d705fa (patch) | |
| tree | 85ddcfbad66f9a70b8b52cdcdb789d23628ab85d /tools | |
| parent | 2634958586368dcbf09c0d2a17dee02d1fc53e0d (diff) | |
perf tools: Read and store caps/max_precise in perf_pmu
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>
Diffstat (limited to 'tools')
| -rw-r--r-- | tools/perf/util/pmu.c | 14 | ||||
| -rw-r--r-- | tools/perf/util/pmu.h | 1 |
2 files changed, 15 insertions, 0 deletions
diff --git a/tools/perf/util/pmu.c b/tools/perf/util/pmu.c index 51d437f55d18..6199a3174ab9 100644 --- a/tools/perf/util/pmu.c +++ b/tools/perf/util/pmu.c | |||
| @@ -752,6 +752,19 @@ perf_pmu__get_default_config(struct perf_pmu *pmu __maybe_unused) | |||
| 752 | return NULL; | 752 | return NULL; |
| 753 | } | 753 | } |
| 754 | 754 | ||
| 755 | static int pmu_max_precise(const char *name) | ||
| 756 | { | ||
| 757 | char path[PATH_MAX]; | ||
| 758 | int max_precise = -1; | ||
| 759 | |||
| 760 | scnprintf(path, PATH_MAX, | ||
| 761 | "bus/event_source/devices/%s/caps/max_precise", | ||
| 762 | name); | ||
| 763 | |||
| 764 | sysfs__read_int(path, &max_precise); | ||
| 765 | return max_precise; | ||
| 766 | } | ||
| 767 | |||
| 755 | static struct perf_pmu *pmu_lookup(const char *name) | 768 | static struct perf_pmu *pmu_lookup(const char *name) |
| 756 | { | 769 | { |
| 757 | struct perf_pmu *pmu; | 770 | struct perf_pmu *pmu; |
| @@ -784,6 +797,7 @@ static struct perf_pmu *pmu_lookup(const char *name) | |||
| 784 | pmu->name = strdup(name); | 797 | pmu->name = strdup(name); |
| 785 | pmu->type = type; | 798 | pmu->type = type; |
| 786 | pmu->is_uncore = pmu_is_uncore(name); | 799 | pmu->is_uncore = pmu_is_uncore(name); |
| 800 | pmu->max_precise = pmu_max_precise(name); | ||
| 787 | pmu_add_cpu_aliases(&aliases, pmu); | 801 | pmu_add_cpu_aliases(&aliases, pmu); |
| 788 | 802 | ||
| 789 | INIT_LIST_HEAD(&pmu->format); | 803 | INIT_LIST_HEAD(&pmu->format); |
diff --git a/tools/perf/util/pmu.h b/tools/perf/util/pmu.h index 47253c3daf55..bd9ec2704a57 100644 --- a/tools/perf/util/pmu.h +++ b/tools/perf/util/pmu.h | |||
| @@ -26,6 +26,7 @@ struct perf_pmu { | |||
| 26 | __u32 type; | 26 | __u32 type; |
| 27 | bool selectable; | 27 | bool selectable; |
| 28 | bool is_uncore; | 28 | bool is_uncore; |
| 29 | int max_precise; | ||
| 29 | struct perf_event_attr *default_config; | 30 | struct perf_event_attr *default_config; |
| 30 | struct cpu_map *cpus; | 31 | struct cpu_map *cpus; |
| 31 | struct list_head format; /* HEAD struct perf_pmu_format -> list */ | 32 | struct list_head format; /* HEAD struct perf_pmu_format -> list */ |
