Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

perf x86/topdown: Make topdown metrics comparators be symmetric

The commit "3b5edc0421e2 (perf x86/topdown: Don't move topdown metric
events in group)" modifies topdown metrics comparator to move topdown
metrics events which are not in same group with previous event. But it
just modifies the 2nd comparator and causes the comparators become
asymmetric.

Thus modify the 1st topdown metrics comparator and make the two
comparators be symmetric, and refine the comments as well.

Suggested-by: Ian Rogers <irogers@google.com>
Signed-off-by: Dapeng Mi <dapeng1.mi@linux.intel.com>
Reviewed-by: Ian Rogers <irogers@google.com>
Link: https://lore.kernel.org/r/20241011110207.1032235-1-dapeng1.mi@linux.intel.com
Signed-off-by: Namhyung Kim <namhyung@kernel.org>

authored by

Dapeng Mi and committed by
Namhyung Kim
b68b5b36 42fd7cac

+9 -6
+9 -6
tools/perf/arch/x86/util/evlist.c
··· 52 52 * 3,015,058 cycles 53 53 * <not supported> topdown-retiring 54 54 * 55 - * if slots event and topdown metrics events are in two groups, the group which 55 + * If slots event and topdown metrics events are in two groups, the group which 56 56 * has topdown metrics events must contain only the topdown metrics event, 57 57 * otherwise topdown metrics event can't be regrouped correctly as well, e.g. 58 58 * ··· 69 69 return -1; 70 70 if (arch_is_topdown_slots(rhs)) 71 71 return 1; 72 - /* Followed by topdown events. */ 73 - if (arch_is_topdown_metrics(lhs) && !arch_is_topdown_metrics(rhs)) 74 - return -1; 72 + 75 73 /* 76 - * Move topdown events forward only when topdown events 77 - * are not in same group with previous event. 74 + * Move topdown metrics events forward only when topdown metrics 75 + * events are not in same group with previous slots event. If 76 + * topdown metrics events are already in same group with slots 77 + * event, do nothing. 78 78 */ 79 + if (arch_is_topdown_metrics(lhs) && !arch_is_topdown_metrics(rhs) && 80 + lhs->core.leader != rhs->core.leader) 81 + return -1; 79 82 if (!arch_is_topdown_metrics(lhs) && arch_is_topdown_metrics(rhs) && 80 83 lhs->core.leader != rhs->core.leader) 81 84 return 1;