]> asedeno.scripts.mit.edu Git - linux.git/commitdiff
perf pmu: Change convert_scale from static to global
authorJin Yao <yao.jin@linux.intel.com>
Wed, 28 Aug 2019 05:59:29 +0000 (13:59 +0800)
committerArnaldo Carvalho de Melo <acme@redhat.com>
Sun, 1 Sep 2019 01:27:51 +0000 (22:27 -0300)
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 <yao.jin@linux.intel.com>
Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
Cc: Andi Kleen <ak@linux.intel.com>
Cc: Jiri Olsa <jolsa@kernel.org>
Cc: Kan Liang <kan.liang@linux.intel.com>
Cc: Peter Zijlstra <peterz@infradead.org>
Link: http://lore.kernel.org/lkml/20190828055932.8269-2-yao.jin@linux.intel.com
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
tools/perf/util/pmu.c
tools/perf/util/pmu.h

index 6b3448f6eb94720e6b0dff295ce8b357f4d52769..fb597fa94234cbd7062e06e563eb35c99606303d 100644 (file)
@@ -102,7 +102,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;
@@ -165,7 +165,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;
@@ -373,7 +373,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);
        }
index 3f8b79b1dd85fa271abf575915121d0c4a8995c3..f36ade6df76d1c3c32a82e7140c4a98c9f036727 100644 (file)
@@ -96,4 +96,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 */