Skip to content

Commit 97e9c8e

Browse files
committed
Merge tag 'perf-tools-fixes-for-v5.17-2022-03-19' of git://git.kernel.org/pub/scm/linux/kernel/git/acme/linux
Pull perf tools fixes from Arnaldo Carvalho de Melo: - Avoid iterating empty evlist, fixing a segfault with 'perf stat --null' - Ignore case in topdown.slots check, fixing issue with Intel Icelake JSON metrics. - Fix symbol size calculation condition for fixing up corner case symbol end address obtained from Kallsyms. * tag 'perf-tools-fixes-for-v5.17-2022-03-19' of git://git.kernel.org/pub/scm/linux/kernel/git/acme/linux: perf parse-events: Ignore case in topdown.slots check perf evlist: Avoid iteration for empty evlist. perf symbols: Fix symbol size calculation condition
2 parents ba6354f + 7bd1da1 commit 97e9c8e

3 files changed

Lines changed: 19 additions & 13 deletions

File tree

tools/perf/arch/x86/util/evlist.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ struct evsel *arch_evlist__leader(struct list_head *list)
2929

3030
__evlist__for_each_entry(list, evsel) {
3131
if (evsel->pmu_name && !strcmp(evsel->pmu_name, "cpu") &&
32-
evsel->name && strstr(evsel->name, "slots"))
32+
evsel->name && strcasestr(evsel->name, "slots"))
3333
return evsel;
3434
}
3535
return first;

tools/perf/util/evlist.c

Lines changed: 17 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -346,24 +346,30 @@ struct evlist_cpu_iterator evlist__cpu_begin(struct evlist *evlist, struct affin
346346
{
347347
struct evlist_cpu_iterator itr = {
348348
.container = evlist,
349-
.evsel = evlist__first(evlist),
349+
.evsel = NULL,
350350
.cpu_map_idx = 0,
351351
.evlist_cpu_map_idx = 0,
352352
.evlist_cpu_map_nr = perf_cpu_map__nr(evlist->core.all_cpus),
353353
.cpu = (struct perf_cpu){ .cpu = -1},
354354
.affinity = affinity,
355355
};
356356

357-
if (itr.affinity) {
358-
itr.cpu = perf_cpu_map__cpu(evlist->core.all_cpus, 0);
359-
affinity__set(itr.affinity, itr.cpu.cpu);
360-
itr.cpu_map_idx = perf_cpu_map__idx(itr.evsel->core.cpus, itr.cpu);
361-
/*
362-
* If this CPU isn't in the evsel's cpu map then advance through
363-
* the list.
364-
*/
365-
if (itr.cpu_map_idx == -1)
366-
evlist_cpu_iterator__next(&itr);
357+
if (evlist__empty(evlist)) {
358+
/* Ensure the empty list doesn't iterate. */
359+
itr.evlist_cpu_map_idx = itr.evlist_cpu_map_nr;
360+
} else {
361+
itr.evsel = evlist__first(evlist);
362+
if (itr.affinity) {
363+
itr.cpu = perf_cpu_map__cpu(evlist->core.all_cpus, 0);
364+
affinity__set(itr.affinity, itr.cpu.cpu);
365+
itr.cpu_map_idx = perf_cpu_map__idx(itr.evsel->core.cpus, itr.cpu);
366+
/*
367+
* If this CPU isn't in the evsel's cpu map then advance
368+
* through the list.
369+
*/
370+
if (itr.cpu_map_idx == -1)
371+
evlist_cpu_iterator__next(&itr);
372+
}
367373
}
368374
return itr;
369375
}

tools/perf/util/symbol.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -231,7 +231,7 @@ void symbols__fixup_end(struct rb_root_cached *symbols)
231231
prev = curr;
232232
curr = rb_entry(nd, struct symbol, rb_node);
233233

234-
if (prev->end == prev->start && prev->end != curr->start)
234+
if (prev->end == prev->start || prev->end != curr->start)
235235
arch__symbols__fixup_end(prev, curr);
236236
}
237237

0 commit comments

Comments
 (0)