Skip to content

Commit 1381396

Browse files
olsajiriacmel
authored andcommitted
perf tools: Add map to parse_groups() function
For testing purposes we need to pass our own map of events from parse_groups() through metricgroup__add_metric. Acked-by: Ian Rogers <[email protected]> Cc: Alexander Shishkin <[email protected]> Cc: Andi Kleen <[email protected]> Cc: Ingo Molnar <[email protected]> Cc: Michael Petlan <[email protected]> Cc: Namhyung Kim <[email protected]> Cc: Peter Zijlstra <[email protected]> Cc: Stephane Eranian <[email protected]> Link: http://lore.kernel.org/lkml/[email protected] Signed-off-by: Arnaldo Carvalho de Melo <[email protected]>
1 parent 68173bd commit 1381396

File tree

1 file changed

+13
-10
lines changed

1 file changed

+13
-10
lines changed

tools/perf/util/metricgroup.c

Lines changed: 13 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -597,17 +597,14 @@ static int __metricgroup__add_metric(struct list_head *group_list,
597597

598598
static int metricgroup__add_metric(const char *metric, bool metric_no_group,
599599
struct strbuf *events,
600-
struct list_head *group_list)
600+
struct list_head *group_list,
601+
struct pmu_events_map *map)
601602
{
602-
struct pmu_events_map *map = perf_pmu__find_map(NULL);
603603
struct pmu_event *pe;
604604
struct egroup *eg;
605605
int i, ret;
606606
bool has_match = false;
607607

608-
if (!map)
609-
return 0;
610-
611608
for (i = 0; ; i++) {
612609
pe = &map->table[i];
613610

@@ -668,7 +665,8 @@ static int metricgroup__add_metric(const char *metric, bool metric_no_group,
668665

669666
static int metricgroup__add_metric_list(const char *list, bool metric_no_group,
670667
struct strbuf *events,
671-
struct list_head *group_list)
668+
struct list_head *group_list,
669+
struct pmu_events_map *map)
672670
{
673671
char *llist, *nlist, *p;
674672
int ret = -EINVAL;
@@ -683,7 +681,7 @@ static int metricgroup__add_metric_list(const char *list, bool metric_no_group,
683681

684682
while ((p = strsep(&llist, ",")) != NULL) {
685683
ret = metricgroup__add_metric(p, metric_no_group, events,
686-
group_list);
684+
group_list, map);
687685
if (ret == -EINVAL) {
688686
fprintf(stderr, "Cannot find metric or group `%s'\n",
689687
p);
@@ -713,7 +711,8 @@ static int parse_groups(struct evlist *perf_evlist, const char *str,
713711
bool metric_no_group,
714712
bool metric_no_merge,
715713
struct perf_pmu *fake_pmu,
716-
struct rblist *metric_events)
714+
struct rblist *metric_events,
715+
struct pmu_events_map *map)
717716
{
718717
struct parse_events_error parse_error;
719718
struct strbuf extra_events;
@@ -723,7 +722,7 @@ static int parse_groups(struct evlist *perf_evlist, const char *str,
723722
if (metric_events->nr_entries == 0)
724723
metricgroup__rblist_init(metric_events);
725724
ret = metricgroup__add_metric_list(str, metric_no_group,
726-
&extra_events, &group_list);
725+
&extra_events, &group_list, map);
727726
if (ret)
728727
return ret;
729728
pr_debug("adding %s\n", extra_events.buf);
@@ -748,9 +747,13 @@ int metricgroup__parse_groups(const struct option *opt,
748747
struct rblist *metric_events)
749748
{
750749
struct evlist *perf_evlist = *(struct evlist **)opt->value;
750+
struct pmu_events_map *map = perf_pmu__find_map(NULL);
751+
752+
if (!map)
753+
return 0;
751754

752755
return parse_groups(perf_evlist, str, metric_no_group,
753-
metric_no_merge, NULL, metric_events);
756+
metric_no_merge, NULL, metric_events, map);
754757
}
755758

756759
bool metricgroup__has_metric(const char *metric)

0 commit comments

Comments
 (0)