perf tools fixes for v5.17: 5th batch

- Avoid iteration for 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.
 
 Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
 -----BEGIN PGP SIGNATURE-----
 
 iHUEABYKAB0WIQR2GiIUctdOfX2qHhGyPKLppCJ+JwUCYjXrDgAKCRCyPKLppCJ+
 J4L0AP40Gl42kn0TVk+L4R1kGgu1b/FN50+0nEWI/NKuwYbuUwEAnE221PRyJX6T
 medW6iS0cnjCpPK3m3G0tOW6EtHisQA=
 =hD/d
 -----END PGP SIGNATURE-----

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
This commit is contained in:
Linus Torvalds 2022-03-19 11:04:10 -07:00
commit 97e9c8eb4b
3 changed files with 19 additions and 13 deletions

View File

@ -29,7 +29,7 @@ struct evsel *arch_evlist__leader(struct list_head *list)
__evlist__for_each_entry(list, evsel) {
if (evsel->pmu_name && !strcmp(evsel->pmu_name, "cpu") &&
evsel->name && strstr(evsel->name, "slots"))
evsel->name && strcasestr(evsel->name, "slots"))
return evsel;
}
return first;

View File

@ -346,7 +346,7 @@ struct evlist_cpu_iterator evlist__cpu_begin(struct evlist *evlist, struct affin
{
struct evlist_cpu_iterator itr = {
.container = evlist,
.evsel = evlist__first(evlist),
.evsel = NULL,
.cpu_map_idx = 0,
.evlist_cpu_map_idx = 0,
.evlist_cpu_map_nr = perf_cpu_map__nr(evlist->core.all_cpus),
@ -354,16 +354,22 @@ struct evlist_cpu_iterator evlist__cpu_begin(struct evlist *evlist, struct affin
.affinity = affinity,
};
if (itr.affinity) {
itr.cpu = perf_cpu_map__cpu(evlist->core.all_cpus, 0);
affinity__set(itr.affinity, itr.cpu.cpu);
itr.cpu_map_idx = perf_cpu_map__idx(itr.evsel->core.cpus, itr.cpu);
/*
* If this CPU isn't in the evsel's cpu map then advance through
* the list.
*/
if (itr.cpu_map_idx == -1)
evlist_cpu_iterator__next(&itr);
if (evlist__empty(evlist)) {
/* Ensure the empty list doesn't iterate. */
itr.evlist_cpu_map_idx = itr.evlist_cpu_map_nr;
} else {
itr.evsel = evlist__first(evlist);
if (itr.affinity) {
itr.cpu = perf_cpu_map__cpu(evlist->core.all_cpus, 0);
affinity__set(itr.affinity, itr.cpu.cpu);
itr.cpu_map_idx = perf_cpu_map__idx(itr.evsel->core.cpus, itr.cpu);
/*
* If this CPU isn't in the evsel's cpu map then advance
* through the list.
*/
if (itr.cpu_map_idx == -1)
evlist_cpu_iterator__next(&itr);
}
}
return itr;
}

View File

@ -231,7 +231,7 @@ void symbols__fixup_end(struct rb_root_cached *symbols)
prev = curr;
curr = rb_entry(nd, struct symbol, rb_node);
if (prev->end == prev->start && prev->end != curr->start)
if (prev->end == prev->start || prev->end != curr->start)
arch__symbols__fixup_end(prev, curr);
}