Skip to content

Commit 5f8b4d5

Browse files
committed
perf hist: Remove dummy entries when finding real ones.
When he have an event group we have multiple struct hist instances, one per evsel, and in each of these hists we may have hist_entries that point to the same thing being observed, say a symbol, i.e. if we're looking at instructions and cycles, then we'll have one hist_entry in the "instructions" evsel and another in the "cycles" evsel. We need to link those to then show one column for each. When we're looking at some other pair of events, say instructions and cache misses, we may have just the "instructions" hist entry and not one for "cache misses", as instructions not necessarily generate cache misses, as the logic expects one hist_entry per evsel, we end up adding "dummy" hist_entries. This is enough for 'perf report', that does this matching operation (hists__match()) just once after processing all events, but for 'perf top', we do this at each refresh, so we may finally find events matching and then we need to trow away the dummies and link with the real events. So if we find a match, traverse the link of matches and trow away dummies for that hists. Cc: Adrian Hunter <adrian.hunter@intel.com> Cc: Jiri Olsa <jolsa@kernel.org> Cc: Namhyung Kim <namhyung@kernel.org> Link: https://lkml.kernel.org/n/tip-dwvtjqqifsbsczeb35q6mqkk@git.kernel.org Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
1 parent 3e70008 commit 5f8b4d5

1 file changed

Lines changed: 18 additions & 2 deletions

File tree

‎tools/perf/util/hist.c‎

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2436,7 +2436,7 @@ void hists__match(struct hists *leader, struct hists *other)
24362436
{
24372437
struct rb_root_cached *root;
24382438
struct rb_node *nd;
2439-
struct hist_entry *pos, *pair;
2439+
struct hist_entry *pos, *pair, *pos_pair, *tmp_pair;
24402440

24412441
if (symbol_conf.report_hierarchy) {
24422442
/* hierarchy report always collapses entries */
@@ -2453,8 +2453,24 @@ void hists__match(struct hists *leader, struct hists *other)
24532453
pos = rb_entry(nd, struct hist_entry, rb_node_in);
24542454
pair = hists__find_entry(other, pos);
24552455

2456-
if (pair && list_empty(&pair->pairs.node))
2456+
if (pair && list_empty(&pair->pairs.node)) {
2457+
list_for_each_entry_safe(pos_pair, tmp_pair, &pos->pairs.head, pairs.node) {
2458+
if (pos_pair->hists == other) {
2459+
/*
2460+
* XXX maybe decayed entries can appear
2461+
* here? but then we would have use
2462+
* after free, as decayed entries are
2463+
* freed see hists__delete_entry
2464+
*/
2465+
BUG_ON(!pos_pair->dummy);
2466+
list_del_init(&pos_pair->pairs.node);
2467+
hist_entry__delete(pos_pair);
2468+
break;
2469+
}
2470+
}
2471+
24572472
hist_entry__add_pair(pair, pos);
2473+
}
24582474
}
24592475
}
24602476

0 commit comments

Comments
 (0)