Skip to content

Commit 84b6ee8

Browse files
namhyungacmel
authored andcommitted
perf hists: Fix comparing of dynamic entries
When hist_entry__cmp() and hist_entry__collapse() are called, they should check if the dynamic entry is comparing matching hists only. Otherwise it might access different hists resulting in incorrect output. Signed-off-by: Namhyung Kim <[email protected]> Acked-by: Jiri Olsa <[email protected]> Cc: Andi Kleen <[email protected]> Cc: David Ahern <[email protected]> Cc: Peter Zijlstra <[email protected]> Cc: Stephane Eranian <[email protected]> Cc: Wang Nan <[email protected]> Link: http://lkml.kernel.org/r/[email protected] Signed-off-by: Arnaldo Carvalho de Melo <[email protected]>
1 parent 2ddda79 commit 84b6ee8

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

tools/perf/util/hist.c

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1002,6 +1002,10 @@ hist_entry__cmp(struct hist_entry *left, struct hist_entry *right)
10021002
int64_t cmp = 0;
10031003

10041004
hists__for_each_sort_list(hists, fmt) {
1005+
if (perf_hpp__is_dynamic_entry(fmt) &&
1006+
!perf_hpp__defined_dynamic_entry(fmt, hists))
1007+
continue;
1008+
10051009
cmp = fmt->cmp(fmt, left, right);
10061010
if (cmp)
10071011
break;
@@ -1018,6 +1022,10 @@ hist_entry__collapse(struct hist_entry *left, struct hist_entry *right)
10181022
int64_t cmp = 0;
10191023

10201024
hists__for_each_sort_list(hists, fmt) {
1025+
if (perf_hpp__is_dynamic_entry(fmt) &&
1026+
!perf_hpp__defined_dynamic_entry(fmt, hists))
1027+
continue;
1028+
10211029
cmp = fmt->collapse(fmt, left, right);
10221030
if (cmp)
10231031
break;

0 commit comments

Comments
 (0)