Skip to content

Commit 90a86bd

Browse files
olsajiriacmel
authored andcommitted
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 <[email protected]> Cc: Alexander Shishkin <[email protected]> Cc: Andi Kleen <[email protected]> Cc: Jonas Rabenstein <[email protected]> Cc: Nageswara R Sastry <[email protected]> Cc: Namhyung Kim <[email protected]> Cc: Peter Zijlstra <[email protected]> Cc: Ravi Bangoria <[email protected]> Link: http://lkml.kernel.org/r/[email protected] Signed-off-by: Arnaldo Carvalho de Melo <[email protected]>
1 parent 2634958 commit 90a86bd

File tree

2 files changed

+15
-0
lines changed

2 files changed

+15
-0
lines changed

tools/perf/util/pmu.c

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -752,6 +752,19 @@ perf_pmu__get_default_config(struct perf_pmu *pmu __maybe_unused)
752752
return NULL;
753753
}
754754

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+
755768
static struct perf_pmu *pmu_lookup(const char *name)
756769
{
757770
struct perf_pmu *pmu;
@@ -784,6 +797,7 @@ static struct perf_pmu *pmu_lookup(const char *name)
784797
pmu->name = strdup(name);
785798
pmu->type = type;
786799
pmu->is_uncore = pmu_is_uncore(name);
800+
pmu->max_precise = pmu_max_precise(name);
787801
pmu_add_cpu_aliases(&aliases, pmu);
788802

789803
INIT_LIST_HEAD(&pmu->format);

tools/perf/util/pmu.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ struct perf_pmu {
2626
__u32 type;
2727
bool selectable;
2828
bool is_uncore;
29+
int max_precise;
2930
struct perf_event_attr *default_config;
3031
struct cpu_map *cpus;
3132
struct list_head format; /* HEAD struct perf_pmu_format -> list */

0 commit comments

Comments
 (0)