Skip to content

Commit 45a3975

Browse files
77liuqiacmel
authored andcommitted
perf auxtrace arm: Refactor event list iteration in auxtrace_record__init()
Add find_pmu_for_event() and use to simplify logic in auxtrace_record_init(). find_pmu_for_event() will be reused in subsequent patches. Reviewed-by: John Garry <[email protected]> Reviewed-by: Jonathan Cameron <[email protected]> Reviewed-by: Leo Yan <[email protected]> Signed-off-by: Qi Liu <[email protected]> Signed-off-by: Yicong Yang <[email protected]> Cc: Alexander Shishkin <[email protected]> Cc: Bjorn Helgaas <[email protected]> Cc: Greg Kroah-Hartman <[email protected]> Cc: Ingo Molnar <[email protected]> Cc: James Clark <[email protected]> Cc: Lorenzo Pieralisi <[email protected]> Cc: Mark Rutland <[email protected]> Cc: Mathieu Poirier <[email protected]> Cc: Mike Leach <[email protected]> Cc: Peter Zijlstra <[email protected]> Cc: Qi Liu <[email protected]> Cc: Shameerali Kolothum Thodi <[email protected]> Cc: Shaokun Zhang <[email protected]> Cc: Suzuki Poulouse <[email protected]> Cc: Will Deacon <[email protected]> Cc: Zeng Prime <[email protected]> Cc: [email protected] Cc: [email protected] Cc: [email protected] Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Arnaldo Carvalho de Melo <[email protected]>
1 parent 58d4802 commit 45a3975

File tree

1 file changed

+34
-19
lines changed

1 file changed

+34
-19
lines changed

tools/perf/arch/arm/util/auxtrace.c

Lines changed: 34 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -50,16 +50,32 @@ static struct perf_pmu **find_all_arm_spe_pmus(int *nr_spes, int *err)
5050
return arm_spe_pmus;
5151
}
5252

53+
static struct perf_pmu *find_pmu_for_event(struct perf_pmu **pmus,
54+
int pmu_nr, struct evsel *evsel)
55+
{
56+
int i;
57+
58+
if (!pmus)
59+
return NULL;
60+
61+
for (i = 0; i < pmu_nr; i++) {
62+
if (evsel->core.attr.type == pmus[i]->type)
63+
return pmus[i];
64+
}
65+
66+
return NULL;
67+
}
68+
5369
struct auxtrace_record
5470
*auxtrace_record__init(struct evlist *evlist, int *err)
5571
{
56-
struct perf_pmu *cs_etm_pmu;
72+
struct perf_pmu *cs_etm_pmu = NULL;
73+
struct perf_pmu **arm_spe_pmus = NULL;
5774
struct evsel *evsel;
58-
bool found_etm = false;
75+
struct perf_pmu *found_etm = NULL;
5976
struct perf_pmu *found_spe = NULL;
60-
struct perf_pmu **arm_spe_pmus = NULL;
77+
int auxtrace_event_cnt = 0;
6178
int nr_spes = 0;
62-
int i = 0;
6379

6480
if (!evlist)
6581
return NULL;
@@ -68,24 +84,23 @@ struct auxtrace_record
6884
arm_spe_pmus = find_all_arm_spe_pmus(&nr_spes, err);
6985

7086
evlist__for_each_entry(evlist, evsel) {
71-
if (cs_etm_pmu &&
72-
evsel->core.attr.type == cs_etm_pmu->type)
73-
found_etm = true;
74-
75-
if (!nr_spes || found_spe)
76-
continue;
77-
78-
for (i = 0; i < nr_spes; i++) {
79-
if (evsel->core.attr.type == arm_spe_pmus[i]->type) {
80-
found_spe = arm_spe_pmus[i];
81-
break;
82-
}
83-
}
87+
if (cs_etm_pmu && !found_etm)
88+
found_etm = find_pmu_for_event(&cs_etm_pmu, 1, evsel);
89+
90+
if (arm_spe_pmus && !found_spe)
91+
found_spe = find_pmu_for_event(arm_spe_pmus, nr_spes, evsel);
8492
}
93+
8594
free(arm_spe_pmus);
8695

87-
if (found_etm && found_spe) {
88-
pr_err("Concurrent ARM Coresight ETM and SPE operation not currently supported\n");
96+
if (found_etm)
97+
auxtrace_event_cnt++;
98+
99+
if (found_spe)
100+
auxtrace_event_cnt++;
101+
102+
if (auxtrace_event_cnt > 1) {
103+
pr_err("Concurrent AUX trace operation not currently supported\n");
89104
*err = -EOPNOTSUPP;
90105
return NULL;
91106
}

0 commit comments

Comments
 (0)