kernel/patches/0195-perf-metricgroup-Make-evlist_used-variable-a-bitmap-.patch
2023-11-10 14:47:39 +08:00

111 lines
3.5 KiB
Diff

From bea495f5119ce30bcfa4725b87aa639e10b803ef Mon Sep 17 00:00:00 2001
From: Ian Rogers <irogers@google.com>
Date: Wed, 20 May 2020 00:28:08 -0700
Subject: [PATCH 078/201] perf metricgroup: Make 'evlist_used' variable a
bitmap instead of array of bools
mainline inclusion
from mainline-v5.8-rc1
commit 45db55f2ef5e98ef096096efad975dc684a9493f
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=45db55f2ef5e98ef096096efad975dc684a9493f
----------------------------------------------------------------------
Use a bitmap rather than an array of bools.
Signed-off-by: Ian Rogers <irogers@google.com>
Acked-by: Jiri 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.com
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
Signed-off-by: hongrongxuan <hongrongxuan@huawei.com>
Conflicts:
tools/perf/util/metricgroup.c
---
tools/perf/util/metricgroup.c | 18 ++++++++----------
1 file changed, 8 insertions(+), 10 deletions(-)
diff --git a/tools/perf/util/metricgroup.c b/tools/perf/util/metricgroup.c
index bd1b54b30a87..4a5baf5719c4 100644
--- a/tools/perf/util/metricgroup.c
+++ b/tools/perf/util/metricgroup.c
@@ -101,7 +101,7 @@ struct egroup {
static struct perf_evsel *find_evsel_group(struct perf_evlist *perf_evlist,
struct expr_parse_ctx *pctx,
struct perf_evsel **metric_events,
- bool *evlist_used)
+ unsigned long *evlist_used)
{
struct perf_evsel *ev;
bool leader_found;
@@ -111,7 +111,7 @@ static struct perf_evsel *find_evsel_group(struct perf_evlist *perf_evlist,
double *val_ptr;
evlist__for_each_entry (perf_evlist, ev) {
- if (evlist_used[j++])
+ if (test_bit(j++, evlist_used))
continue;
if (hashmap__find(&pctx->ids, ev->name, (void **)&val_ptr)) {
if (!metric_events[i])
@@ -147,7 +147,7 @@ static struct perf_evsel *find_evsel_group(struct perf_evlist *perf_evlist,
j++;
}
ev = metric_events[i];
- evlist_used[ev->idx] = true;
+ set_bit(ev->idx, evlist_used);
}
return metric_events[0];
@@ -163,13 +163,11 @@ static int metricgroup__setup_events(struct list_head *groups,
int ret = 0;
struct egroup *eg;
struct perf_evsel *evsel;
- bool *evlist_used;
+ unsigned long *evlist_used;
- evlist_used = calloc(perf_evlist->nr_entries, sizeof(bool));
- if (!evlist_used) {
- ret = -ENOMEM;
- return ret;
- }
+ evlist_used = bitmap_alloc(perf_evlist->nr_entries);
+ if (!evlist_used)
+ return -ENOMEM;
list_for_each_entry (eg, groups, nd) {
struct perf_evsel **metric_events;
@@ -210,7 +208,7 @@ static int metricgroup__setup_events(struct list_head *groups,
list_add(&expr->nd, &me->head);
}
- free(evlist_used);
+ bitmap_free(evlist_used);
return ret;
}
--
2.27.0