Commit 45db55f2 authored by Ian Rogers's avatar Ian Rogers Committed by Arnaldo Carvalho de Melo

perf metricgroup: Make 'evlist_used' variable a bitmap instead of array of bools

Use a bitmap rather than an array of bools.
Signed-off-by: default avatarIan Rogers <irogers@google.com>
Acked-by: default avatarJiri Olsa <jolsa@redhat.com>
Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
Cc: Andi Kleen <ak@linux.intel.com>
Cc: Andrii Nakryiko <andriin@fb.com>
Cc: Cong Wang <xiyou.wangcong@gmail.com>
Cc: Jin Yao <yao.jin@linux.intel.com>
Cc: John Garry <john.garry@huawei.com>
Cc: Kajol Jain <kjain@linux.ibm.com>
Cc: Kan Liang <kan.liang@linux.intel.com>
Cc: Kim Phillips <kim.phillips@amd.com>
Cc: Mark Rutland <mark.rutland@arm.com>
Cc: Namhyung Kim <namhyung@kernel.org>
Cc: Paul Clarke <pc@us.ibm.com>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Song Liu <songliubraving@fb.com>
Cc: Srikar Dronamraju <srikar@linux.vnet.ibm.com>
Cc: Stephane Eranian <eranian@google.com>
Cc: Vince Weaver <vincent.weaver@maine.edu>
Cc: bpf@vger.kernel.org
Cc: netdev@vger.kernel.org
Link: http://lore.kernel.org/lkml/20200520072814.128267-2-irogers@google.comSigned-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
parent ae762641
...@@ -95,7 +95,7 @@ struct egroup { ...@@ -95,7 +95,7 @@ struct egroup {
static struct evsel *find_evsel_group(struct evlist *perf_evlist, static struct evsel *find_evsel_group(struct evlist *perf_evlist,
struct expr_parse_ctx *pctx, struct expr_parse_ctx *pctx,
struct evsel **metric_events, struct evsel **metric_events,
bool *evlist_used) unsigned long *evlist_used)
{ {
struct evsel *ev; struct evsel *ev;
bool leader_found; bool leader_found;
...@@ -105,7 +105,7 @@ static struct evsel *find_evsel_group(struct evlist *perf_evlist, ...@@ -105,7 +105,7 @@ static struct evsel *find_evsel_group(struct evlist *perf_evlist,
double *val_ptr; double *val_ptr;
evlist__for_each_entry (perf_evlist, ev) { evlist__for_each_entry (perf_evlist, ev) {
if (evlist_used[j++]) if (test_bit(j++, evlist_used))
continue; continue;
if (hashmap__find(&pctx->ids, ev->name, (void **)&val_ptr)) { if (hashmap__find(&pctx->ids, ev->name, (void **)&val_ptr)) {
if (!metric_events[i]) if (!metric_events[i])
...@@ -141,7 +141,7 @@ static struct evsel *find_evsel_group(struct evlist *perf_evlist, ...@@ -141,7 +141,7 @@ static struct evsel *find_evsel_group(struct evlist *perf_evlist,
j++; j++;
} }
ev = metric_events[i]; ev = metric_events[i];
evlist_used[ev->idx] = true; set_bit(ev->idx, evlist_used);
} }
return metric_events[0]; return metric_events[0];
...@@ -157,13 +157,11 @@ static int metricgroup__setup_events(struct list_head *groups, ...@@ -157,13 +157,11 @@ static int metricgroup__setup_events(struct list_head *groups,
int ret = 0; int ret = 0;
struct egroup *eg; struct egroup *eg;
struct evsel *evsel; struct evsel *evsel;
bool *evlist_used; unsigned long *evlist_used;
evlist_used = calloc(perf_evlist->core.nr_entries, sizeof(bool)); evlist_used = bitmap_alloc(perf_evlist->core.nr_entries);
if (!evlist_used) { if (!evlist_used)
ret = -ENOMEM; return -ENOMEM;
return ret;
}
list_for_each_entry (eg, groups, nd) { list_for_each_entry (eg, groups, nd) {
struct evsel **metric_events; struct evsel **metric_events;
...@@ -201,7 +199,7 @@ static int metricgroup__setup_events(struct list_head *groups, ...@@ -201,7 +199,7 @@ static int metricgroup__setup_events(struct list_head *groups,
list_add(&expr->nd, &me->head); list_add(&expr->nd, &me->head);
} }
free(evlist_used); bitmap_free(evlist_used);
return ret; return ret;
} }
......
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