Skip to content

Commit faba877

Browse files
committed
Merge tag 'perf-tools-fixes-v5.11-2-2021-01-22' of git://git.kernel.org/pub/scm/linux/kernel/git/acme/linux
Pull more perf tools fixes from Arnaldo Carvalho de Melo: - Fix id index used in Intel PT for heterogeneous systems - Fix overrun issue in 'perf script' for dynamically-allocated PMU type number - Fix 'perf stat' metrics containing the 'duration_time' synthetic event - Fix system PMU 'perf stat' metrics * tag 'perf-tools-fixes-v5.11-2-2021-01-22' of git://git.kernel.org/pub/scm/linux/kernel/git/acme/linux: perf script: Fix overrun issue for dynamically-allocated PMU type number perf metricgroup: Fix system PMU metrics perf metricgroup: Fix for metrics containing duration_time perf evlist: Fix id index for heterogeneous systems
2 parents 1c304c7 + 8adc0a0 commit faba877

3 files changed

Lines changed: 32 additions & 19 deletions

File tree

tools/lib/perf/evlist.c

Lines changed: 4 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -367,21 +367,13 @@ static struct perf_mmap* perf_evlist__alloc_mmap(struct perf_evlist *evlist, boo
367367
return map;
368368
}
369369

370-
static void perf_evlist__set_sid_idx(struct perf_evlist *evlist,
371-
struct perf_evsel *evsel, int idx, int cpu,
372-
int thread)
370+
static void perf_evsel__set_sid_idx(struct perf_evsel *evsel, int idx, int cpu, int thread)
373371
{
374372
struct perf_sample_id *sid = SID(evsel, cpu, thread);
375373

376374
sid->idx = idx;
377-
if (evlist->cpus && cpu >= 0)
378-
sid->cpu = evlist->cpus->map[cpu];
379-
else
380-
sid->cpu = -1;
381-
if (!evsel->system_wide && evlist->threads && thread >= 0)
382-
sid->tid = perf_thread_map__pid(evlist->threads, thread);
383-
else
384-
sid->tid = -1;
375+
sid->cpu = perf_cpu_map__cpu(evsel->cpus, cpu);
376+
sid->tid = perf_thread_map__pid(evsel->threads, thread);
385377
}
386378

387379
static struct perf_mmap*
@@ -500,8 +492,7 @@ mmap_per_evsel(struct perf_evlist *evlist, struct perf_evlist_mmap_ops *ops,
500492
if (perf_evlist__id_add_fd(evlist, evsel, cpu, thread,
501493
fd) < 0)
502494
return -1;
503-
perf_evlist__set_sid_idx(evlist, evsel, idx, cpu,
504-
thread);
495+
perf_evsel__set_sid_idx(evsel, idx, cpu, thread);
505496
}
506497
}
507498

tools/perf/builtin-script.c

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -186,6 +186,7 @@ struct output_option {
186186

187187
enum {
188188
OUTPUT_TYPE_SYNTH = PERF_TYPE_MAX,
189+
OUTPUT_TYPE_OTHER,
189190
OUTPUT_TYPE_MAX
190191
};
191192

@@ -283,6 +284,18 @@ static struct {
283284

284285
.invalid_fields = PERF_OUTPUT_TRACE | PERF_OUTPUT_BPF_OUTPUT,
285286
},
287+
288+
[OUTPUT_TYPE_OTHER] = {
289+
.user_set = false,
290+
291+
.fields = PERF_OUTPUT_COMM | PERF_OUTPUT_TID |
292+
PERF_OUTPUT_CPU | PERF_OUTPUT_TIME |
293+
PERF_OUTPUT_EVNAME | PERF_OUTPUT_IP |
294+
PERF_OUTPUT_SYM | PERF_OUTPUT_SYMOFFSET |
295+
PERF_OUTPUT_DSO | PERF_OUTPUT_PERIOD,
296+
297+
.invalid_fields = PERF_OUTPUT_TRACE | PERF_OUTPUT_BPF_OUTPUT,
298+
},
286299
};
287300

288301
struct evsel_script {
@@ -343,8 +356,11 @@ static inline int output_type(unsigned int type)
343356
case PERF_TYPE_SYNTH:
344357
return OUTPUT_TYPE_SYNTH;
345358
default:
346-
return type;
359+
if (type < PERF_TYPE_MAX)
360+
return type;
347361
}
362+
363+
return OUTPUT_TYPE_OTHER;
348364
}
349365

350366
static inline unsigned int attr_type(unsigned int type)

tools/perf/util/metricgroup.c

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -162,6 +162,14 @@ static bool contains_event(struct evsel **metric_events, int num_events,
162162
return false;
163163
}
164164

165+
static bool evsel_same_pmu(struct evsel *ev1, struct evsel *ev2)
166+
{
167+
if (!ev1->pmu_name || !ev2->pmu_name)
168+
return false;
169+
170+
return !strcmp(ev1->pmu_name, ev2->pmu_name);
171+
}
172+
165173
/**
166174
* Find a group of events in perf_evlist that correspond to those from a parsed
167175
* metric expression. Note, as find_evsel_group is called in the same order as
@@ -280,8 +288,7 @@ static struct evsel *find_evsel_group(struct evlist *perf_evlist,
280288
*/
281289
if (!has_constraint &&
282290
ev->leader != metric_events[i]->leader &&
283-
!strcmp(ev->leader->pmu_name,
284-
metric_events[i]->leader->pmu_name))
291+
evsel_same_pmu(ev->leader, metric_events[i]->leader))
285292
break;
286293
if (!strcmp(metric_events[i]->name, ev->name)) {
287294
set_bit(ev->idx, evlist_used);
@@ -766,7 +773,6 @@ int __weak arch_get_runtimeparam(struct pmu_event *pe __maybe_unused)
766773
struct metricgroup_add_iter_data {
767774
struct list_head *metric_list;
768775
const char *metric;
769-
struct metric **m;
770776
struct expr_ids *ids;
771777
int *ret;
772778
bool *has_match;
@@ -1058,12 +1064,13 @@ static int metricgroup__add_metric_sys_event_iter(struct pmu_event *pe,
10581064
void *data)
10591065
{
10601066
struct metricgroup_add_iter_data *d = data;
1067+
struct metric *m = NULL;
10611068
int ret;
10621069

10631070
if (!match_pe_metric(pe, d->metric))
10641071
return 0;
10651072

1066-
ret = add_metric(d->metric_list, pe, d->metric_no_group, d->m, NULL, d->ids);
1073+
ret = add_metric(d->metric_list, pe, d->metric_no_group, &m, NULL, d->ids);
10671074
if (ret)
10681075
return ret;
10691076

@@ -1114,7 +1121,6 @@ static int metricgroup__add_metric(const char *metric, bool metric_no_group,
11141121
.metric_list = &list,
11151122
.metric = metric,
11161123
.metric_no_group = metric_no_group,
1117-
.m = &m,
11181124
.ids = &ids,
11191125
.has_match = &has_match,
11201126
.ret = &ret,

0 commit comments

Comments
 (0)