From ab598ff7883c85c929b287a06501d9df15b1a42c Mon Sep 17 00:00:00 2001 From: Jin Yao Date: Wed, 28 Aug 2019 13:59:29 +0800 Subject: [PATCH 021/201] perf pmu: Change convert_scale from static to global mainline inclusion from mainline-v5.4-rc1 commit 287f2649f791819dd2d8f32f0213c8c521d6dfa0 category: feature bugzilla: https://gitee.com/openeuler/kernel/issues/I8C0CX Reference: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=287f2649f791819dd2d8f32f0213c8c521d6dfa0 ------------------------------------------------------------------------ The function convert_scale() can be used to convert string to unit and scale. For example, s = "6000000000ns"; convert_scale(s, &unit, &scale); unit = "ns", scale = 6000000000. Currently this function is static. This patch renames the function to perf_pmu__convert_scale and changes the function to global. No functional change. Signed-off-by: Jin Yao Cc: Alexander Shishkin Cc: Andi Kleen Cc: Jiri Olsa Cc: Kan Liang Cc: Peter Zijlstra Link: http://lore.kernel.org/lkml/20190828055932.8269-2-yao.jin@linux.intel.com Signed-off-by: Arnaldo Carvalho de Melo Signed-off-by: hongrongxuan --- tools/perf/util/pmu.c | 6 +++--- tools/perf/util/pmu.h | 2 ++ 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/tools/perf/util/pmu.c b/tools/perf/util/pmu.c index aa91fcb51a6d..256a9792bd7e 100644 --- a/tools/perf/util/pmu.c +++ b/tools/perf/util/pmu.c @@ -100,7 +100,7 @@ static int pmu_format(const char *name, struct list_head *format) return 0; } -static int convert_scale(const char *scale, char **end, double *sval) +int perf_pmu__convert_scale(const char *scale, char **end, double *sval) { char *lc; int ret = 0; @@ -163,7 +163,7 @@ static int perf_pmu__parse_scale(struct perf_pmu_alias *alias, char *dir, char * else scale[sret] = '\0'; - ret = convert_scale(scale, NULL, &alias->scale); + ret = perf_pmu__convert_scale(scale, NULL, &alias->scale); error: close(fd); return ret; @@ -371,7 +371,7 @@ static int __perf_pmu__new_alias(struct list_head *list, char *dir, char *name, desc ? strdup(desc) : NULL; alias->topic = topic ? strdup(topic) : NULL; if (unit) { - if (convert_scale(unit, &unit, &alias->scale) < 0) + if (perf_pmu__convert_scale(unit, &unit, &alias->scale) < 0) return -1; snprintf(alias->unit, sizeof(alias->unit), "%s", unit); } diff --git a/tools/perf/util/pmu.h b/tools/perf/util/pmu.h index 76fecec7b3f9..ea0e7c36eae9 100644 --- a/tools/perf/util/pmu.h +++ b/tools/perf/util/pmu.h @@ -94,4 +94,6 @@ struct perf_event_attr *perf_pmu__get_default_config(struct perf_pmu *pmu); struct pmu_events_map *perf_pmu__find_map(struct perf_pmu *pmu); +int perf_pmu__convert_scale(const char *scale, char **end, double *sval); + #endif /* __PMU_H */ -- 2.27.0