Skip to content

Commit df7deb2

Browse files
Jin Yaoacmel
authored andcommitted
perf top: Support --group-sort-idx to change the sort order
'perf report' supports the option --group-sort-idx, which sorts the output by the event at the index n in event group. For example: perf record -e cycles,instructions,cache-misses perf report --group --group-sort-idx 2 --stdio The perf-report output is sorted by cache-misses. This patch supports --group-sort-idx in perf-top. For example: perf top --group -e cycles,instructions,cache-misses --group-sort-idx 2 The perf-top output is sorted by cache-misses. Signed-off-by: Jin Yao <[email protected]> Suggested-by: Arnaldo Carvalho de Melo <[email protected]> Tested-by: Arnaldo Carvalho de Melo <[email protected]> Cc: Alexander Shishkin <[email protected]> Cc: Andi Kleen <[email protected]> Cc: Jin Yao <[email protected]> Cc: Jiri Olsa <[email protected]> Cc: Kan Liang <[email protected]> Cc: Peter Zijlstra <[email protected]> Link: http://lore.kernel.org/lkml/[email protected] Signed-off-by: Arnaldo Carvalho de Melo <[email protected]>
1 parent 78886f3 commit df7deb2

File tree

2 files changed

+9
-0
lines changed

2 files changed

+9
-0
lines changed

tools/perf/Documentation/perf-top.txt

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,11 @@ Default is to monitor all CPUS.
5353
--group::
5454
Put the counters into a counter group.
5555

56+
--group-sort-idx::
57+
Sort the output by the event at the index n in group. If n is invalid,
58+
sort by the first event. It can support multiple groups with different
59+
amount of events. WARNING: This should be used on grouped events.
60+
5661
-F <freq>::
5762
--freq=<freq>::
5863
Profile at this frequency. Use 'max' to use the currently maximum

tools/perf/builtin-top.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1560,6 +1560,10 @@ int cmd_top(int argc, const char **argv)
15601560
"Record namespaces events"),
15611561
OPT_BOOLEAN(0, "all-cgroups", &opts->record_cgroup,
15621562
"Record cgroup events"),
1563+
OPT_INTEGER(0, "group-sort-idx", &symbol_conf.group_sort_idx,
1564+
"Sort the output by the event at the index n in group. "
1565+
"If n is invalid, sort by the first event. "
1566+
"WARNING: should be used on grouped events."),
15631567
OPTS_EVSWITCH(&top.evswitch),
15641568
OPT_END()
15651569
};

0 commit comments

Comments
 (0)