Commit 5f2c8efa authored by James Clark's avatar James Clark Committed by Arnaldo Carvalho de Melo

perf pmu: Remove remaining duplication of bus/event_source/devices/...

Use the new perf_pmu__pathname_scnprintf() instead. No functional
changes.
Reviewed-by: default avatarLeo Yan <leo.yan@linaro.org>
Signed-off-by: default avatarJames Clark <james.clark@arm.com>
Acked-by: default avatarSuzuki Poulouse <suzuki.poulose@arm.com>
Tested-by: default avatarTanmay Jagdale <tanmay@marvell.com>
Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
Cc: Bharat Bhushan <bbhushan2@marvell.com>
Cc: George Cherian <gcherian@marvell.com>
Cc: Ingo Molnar <mingo@redhat.com>
Cc: Jiri Olsa <jolsa@kernel.org>
Cc: John Garry <john.g.garry@oracle.com>
Cc: Linu Cherian <lcherian@marvell.com>
Cc: Mark Rutland <mark.rutland@arm.com>
Cc: Mathieu Poirier <mathieu.poirier@linaro.org>
Cc: Mike Leach <mike.leach@linaro.org>
Cc: Namhyung Kim <namhyung@kernel.org>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Sunil Kovvuri Goutham <sgoutham@marvell.com>
Cc: Will Deacon <will@kernel.org>
Cc: coresight@lists.linaro.org
Cc: linux-arm-kernel@lists.infradead.org
Link: https://lore.kernel.org/r/20230120143702.4035046-4-james.clark@arm.comSigned-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
parent d50a79cd
...@@ -575,8 +575,6 @@ static void pmu_read_sysfs(void) ...@@ -575,8 +575,6 @@ static void pmu_read_sysfs(void)
* Uncore PMUs have a "cpumask" file under sysfs. CPU PMUs (e.g. on arm/arm64) * Uncore PMUs have a "cpumask" file under sysfs. CPU PMUs (e.g. on arm/arm64)
* may have a "cpus" file. * may have a "cpus" file.
*/ */
#define SYS_TEMPLATE_ID "./bus/event_source/devices/%s/identifier"
static struct perf_cpu_map *pmu_cpumask(const char *name) static struct perf_cpu_map *pmu_cpumask(const char *name)
{ {
struct perf_cpu_map *cpus; struct perf_cpu_map *cpus;
...@@ -619,9 +617,9 @@ static char *pmu_id(const char *name) ...@@ -619,9 +617,9 @@ static char *pmu_id(const char *name)
char path[PATH_MAX], *str; char path[PATH_MAX], *str;
size_t len; size_t len;
snprintf(path, PATH_MAX, SYS_TEMPLATE_ID, name); perf_pmu__pathname_scnprintf(path, sizeof(path), name, "identifier");
if (sysfs__read_str(path, &str, &len) < 0) if (filename__read_str(path, &str, &len) < 0)
return NULL; return NULL;
str[len - 1] = 0; /* remove line feed */ str[len - 1] = 0; /* remove line feed */
...@@ -867,16 +865,11 @@ pmu_find_alias_name(const char *name __maybe_unused) ...@@ -867,16 +865,11 @@ pmu_find_alias_name(const char *name __maybe_unused)
return NULL; return NULL;
} }
static int pmu_max_precise(const char *name) static int pmu_max_precise(struct perf_pmu *pmu)
{ {
char path[PATH_MAX];
int max_precise = -1; int max_precise = -1;
scnprintf(path, PATH_MAX, perf_pmu__scan_file(pmu, "caps/max_precise", "%d", &max_precise);
"bus/event_source/devices/%s/caps/max_precise",
name);
sysfs__read_int(path, &max_precise);
return max_precise; return max_precise;
} }
...@@ -935,7 +928,7 @@ static struct perf_pmu *pmu_lookup(const char *lookup_name) ...@@ -935,7 +928,7 @@ static struct perf_pmu *pmu_lookup(const char *lookup_name)
pmu->is_uncore = pmu_is_uncore(name); pmu->is_uncore = pmu_is_uncore(name);
if (pmu->is_uncore) if (pmu->is_uncore)
pmu->id = pmu_id(name); pmu->id = pmu_id(name);
pmu->max_precise = pmu_max_precise(name); pmu->max_precise = pmu_max_precise(pmu);
pmu_add_cpu_aliases(&aliases, pmu); pmu_add_cpu_aliases(&aliases, pmu);
pmu_add_sys_aliases(&aliases, pmu); pmu_add_sys_aliases(&aliases, pmu);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment