perf pmu: Simplify arguments of __perf_pmu__new_alias
authorJin Yao <yao.jin@linux.intel.com>
Tue, 27 Apr 2021 07:01:16 +0000 (15:01 +0800)
committerArnaldo Carvalho de Melo <acme@redhat.com>
Thu, 29 Apr 2021 13:30:59 +0000 (10:30 -0300)
Simplify the arguments of __perf_pmu__new_alias() by passing the whole
'struct pme_event' pointer.

Signed-off-by: Jin Yao <yao.jin@linux.intel.com>
Reviewed-by: Jiri Olsa <jolsa@kernel.org>
Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
Cc: Andi Kleen <ak@linux.intel.com>
Cc: Ingo Molnar <mingo@redhat.com>
Cc: Kan Liang <kan.liang@intel.com>
Cc: Peter Zijlstra <peterz@infradead.org>
Link: https://lore.kernel.org/r/20210427070139.25256-4-yao.jin@linux.intel.com
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
tools/perf/util/pmu.c

index 286d5e4..8214def 100644 (file)
@@ -306,18 +306,25 @@ static bool perf_pmu_merge_alias(struct perf_pmu_alias *newalias,
 }
 
 static int __perf_pmu__new_alias(struct list_head *list, char *dir, char *name,
-                                char *desc, char *val,
-                                char *long_desc, char *topic,
-                                char *unit, char *perpkg,
-                                char *metric_expr,
-                                char *metric_name,
-                                char *deprecated)
+                                char *desc, char *val, struct pmu_event *pe)
 {
        struct parse_events_term *term;
        struct perf_pmu_alias *alias;
        int ret;
        int num;
        char newval[256];
+       char *long_desc = NULL, *topic = NULL, *unit = NULL, *perpkg = NULL,
+            *metric_expr = NULL, *metric_name = NULL, *deprecated = NULL;
+
+       if (pe) {
+               long_desc = (char *)pe->long_desc;
+               topic = (char *)pe->topic;
+               unit = (char *)pe->unit;
+               perpkg = (char *)pe->perpkg;
+               metric_expr = (char *)pe->metric_expr;
+               metric_name = (char *)pe->metric_name;
+               deprecated = (char *)pe->deprecated;
+       }
 
        alias = malloc(sizeof(*alias));
        if (!alias)
@@ -406,8 +413,7 @@ static int perf_pmu__new_alias(struct list_head *list, char *dir, char *name, FI
        /* Remove trailing newline from sysfs file */
        strim(buf);
 
-       return __perf_pmu__new_alias(list, dir, name, NULL, buf, NULL, NULL, NULL,
-                                    NULL, NULL, NULL, NULL);
+       return __perf_pmu__new_alias(list, dir, name, NULL, buf, NULL);
 }
 
 static inline bool pmu_alias_info_file(char *name)
@@ -798,11 +804,7 @@ new_alias:
                /* need type casts to override 'const' */
                __perf_pmu__new_alias(head, NULL, (char *)pe->name,
                                (char *)pe->desc, (char *)pe->event,
-                               (char *)pe->long_desc, (char *)pe->topic,
-                               (char *)pe->unit, (char *)pe->perpkg,
-                               (char *)pe->metric_expr,
-                               (char *)pe->metric_name,
-                               (char *)pe->deprecated);
+                               pe);
        }
 }
 
@@ -869,13 +871,7 @@ static int pmu_add_sys_aliases_iter_fn(struct pmu_event *pe, void *data)
                                      (char *)pe->name,
                                      (char *)pe->desc,
                                      (char *)pe->event,
-                                     (char *)pe->long_desc,
-                                     (char *)pe->topic,
-                                     (char *)pe->unit,
-                                     (char *)pe->perpkg,
-                                     (char *)pe->metric_expr,
-                                     (char *)pe->metric_name,
-                                     (char *)pe->deprecated);
+                                     pe);
        }
 
        return 0;