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

perf tools: Allow hpp fields to be sort keys

Add overhead{,_sys,_us,_guest_sys,_guest_us}, sample and period sort
keys so that they can be selected with --sort/-s option.

$ perf report -s period,comm --stdio
...
# Overhead Period Command
# ........ ............ ...............
#
47.06% 152 swapper
13.93% 45 qemu-system-arm
12.38% 40 synergys
3.72% 12 firefox
2.48% 8 xchat

Signed-off-by: Namhyung Kim <namhyung@kernel.org>
Acked-by: Ingo Molnar <mingo@kernel.org>
Link: http://lkml.kernel.org/r/1400480762-22852-9-git-send-email-namhyung@kernel.org
Signed-off-by: Jiri Olsa <jolsa@kernel.org>

authored by

Namhyung Kim and committed by
Jiri Olsa
a2ce067e fb821c9e

+67 -13
+3 -2
tools/perf/Documentation/perf-diff.txt
··· 50 50 51 51 -s:: 52 52 --sort=:: 53 - Sort by key(s): pid, comm, dso, symbol. 53 + Sort by key(s): pid, comm, dso, symbol, cpu, parent, srcline. 54 + Please see description of --sort in the perf-report man page. 54 55 55 56 -t:: 56 57 --field-separator=:: ··· 203 202 204 203 SEE ALSO 205 204 -------- 206 - linkperf:perf-record[1] 205 + linkperf:perf-record[1], linkperf:perf-report[1]
+9
tools/perf/Documentation/perf-report.txt
··· 79 79 abort cost. This is the global weight. 80 80 - local_weight: Local weight version of the weight above. 81 81 - transaction: Transaction abort flags. 82 + - overhead: Overhead percentage of sample 83 + - overhead_sys: Overhead percentage of sample running in system mode 84 + - overhead_us: Overhead percentage of sample running in user mode 85 + - overhead_guest_sys: Overhead percentage of sample running in system mode 86 + on guest machine 87 + - overhead_guest_us: Overhead percentage of sample running in user mode on 88 + guest machine 89 + - sample: Number of sample 90 + - period: Raw number of event count of sample 82 91 83 92 By default, comm, dso and symbol keys are used. 84 93 (i.e. --sort comm,dso,symbol)
+3 -2
tools/perf/Documentation/perf-top.txt
··· 113 113 -s:: 114 114 --sort:: 115 115 Sort by key(s): pid, comm, dso, symbol, parent, srcline, weight, 116 - local_weight, abort, in_tx, transaction 116 + local_weight, abort, in_tx, transaction, overhead, sample, period. 117 + Please see description of --sort in the perf-report man page. 117 118 118 119 -n:: 119 120 --show-nr-samples:: ··· 213 212 214 213 SEE ALSO 215 214 -------- 216 - linkperf:perf-stat[1], linkperf:perf-list[1] 215 + linkperf:perf-stat[1], linkperf:perf-list[1], linkperf:perf-report[1]
+2 -1
tools/perf/builtin-diff.c
··· 741 741 OPT_STRING('S', "symbols", &symbol_conf.sym_list_str, "symbol[,symbol...]", 742 742 "only consider these symbols"), 743 743 OPT_STRING('s', "sort", &sort_order, "key[,key2...]", 744 - "sort by key(s): pid, comm, dso, symbol, parent"), 744 + "sort by key(s): pid, comm, dso, symbol, parent, cpu, srcline, ..." 745 + " Please refer the man page for the complete list."), 745 746 OPT_STRING('t', "field-separator", &symbol_conf.field_sep, "separator", 746 747 "separator for columns, no spaces will be added between " 747 748 "columns '.' is reserved."),
+2 -4
tools/perf/builtin-report.c
··· 699 699 OPT_BOOLEAN(0, "header-only", &report.header_only, 700 700 "Show only data header."), 701 701 OPT_STRING('s', "sort", &sort_order, "key[,key2...]", 702 - "sort by key(s): pid, comm, dso, symbol, parent, cpu, srcline," 703 - " dso_to, dso_from, symbol_to, symbol_from, mispredict," 704 - " weight, local_weight, mem, symbol_daddr, dso_daddr, tlb, " 705 - "snoop, locked, abort, in_tx, transaction"), 702 + "sort by key(s): pid, comm, dso, symbol, parent, cpu, srcline, ..." 703 + " Please refer the man page for the complete list."), 706 704 OPT_BOOLEAN(0, "showcpuutilization", &symbol_conf.show_cpu_utilization, 707 705 "Show sample percentage for different cpu modes"), 708 706 OPT_STRING('p', "parent", &parent_pattern, "regex",
+2 -2
tools/perf/builtin-top.c
··· 1083 1083 OPT_INCR('v', "verbose", &verbose, 1084 1084 "be more verbose (show counter open errors, etc)"), 1085 1085 OPT_STRING('s', "sort", &sort_order, "key[,key2...]", 1086 - "sort by key(s): pid, comm, dso, symbol, parent, weight, local_weight," 1087 - " abort, in_tx, transaction"), 1086 + "sort by key(s): pid, comm, dso, symbol, parent, cpu, srcline, ..." 1087 + " Please refer the man page for the complete list."), 1088 1088 OPT_BOOLEAN('n', "show-nr-samples", &symbol_conf.show_nr_samples, 1089 1089 "Show a column with the number of samples"), 1090 1090 OPT_CALLBACK_NOOPT('g', NULL, &top.record_opts,
+7 -2
tools/perf/ui/hist.c
··· 346 346 int i; 347 347 348 348 for (i = 0; i < PERF_HPP__MAX_INDEX; i++) { 349 - INIT_LIST_HEAD(&perf_hpp__format[i].list); 350 - INIT_LIST_HEAD(&perf_hpp__format[i].sort_list); 349 + struct perf_hpp_fmt *fmt = &perf_hpp__format[i]; 350 + 351 + INIT_LIST_HEAD(&fmt->list); 352 + 353 + /* sort_list may be linked by setup_sorting() */ 354 + if (fmt->sort_list.next == NULL) 355 + INIT_LIST_HEAD(&fmt->sort_list); 351 356 } 352 357 353 358 perf_hpp__column_enable(PERF_HPP__OVERHEAD);
+39
tools/perf/util/sort.c
··· 1028 1028 1029 1029 #undef DIM 1030 1030 1031 + struct hpp_dimension { 1032 + const char *name; 1033 + struct perf_hpp_fmt *fmt; 1034 + int taken; 1035 + }; 1036 + 1037 + #define DIM(d, n) { .name = n, .fmt = &perf_hpp__format[d], } 1038 + 1039 + static struct hpp_dimension hpp_sort_dimensions[] = { 1040 + DIM(PERF_HPP__OVERHEAD, "overhead"), 1041 + DIM(PERF_HPP__OVERHEAD_SYS, "overhead_sys"), 1042 + DIM(PERF_HPP__OVERHEAD_US, "overhead_us"), 1043 + DIM(PERF_HPP__OVERHEAD_GUEST_SYS, "overhead_guest_sys"), 1044 + DIM(PERF_HPP__OVERHEAD_GUEST_US, "overhead_guest_us"), 1045 + DIM(PERF_HPP__SAMPLES, "sample"), 1046 + DIM(PERF_HPP__PERIOD, "period"), 1047 + }; 1048 + 1049 + #undef DIM 1050 + 1031 1051 struct hpp_sort_entry { 1032 1052 struct perf_hpp_fmt hpp; 1033 1053 struct sort_entry *se; ··· 1135 1115 return 0; 1136 1116 } 1137 1117 1118 + static int __hpp_dimension__add(struct hpp_dimension *hd) 1119 + { 1120 + if (!hd->taken) { 1121 + hd->taken = 1; 1122 + 1123 + perf_hpp__register_sort_field(hd->fmt); 1124 + } 1125 + return 0; 1126 + } 1127 + 1138 1128 int sort_dimension__add(const char *tok) 1139 1129 { 1140 1130 unsigned int i; ··· 1172 1142 } 1173 1143 1174 1144 return __sort_dimension__add(sd, i); 1145 + } 1146 + 1147 + for (i = 0; i < ARRAY_SIZE(hpp_sort_dimensions); i++) { 1148 + struct hpp_dimension *hd = &hpp_sort_dimensions[i]; 1149 + 1150 + if (strncasecmp(tok, hd->name, strlen(tok))) 1151 + continue; 1152 + 1153 + return __hpp_dimension__add(hd); 1175 1154 } 1176 1155 1177 1156 for (i = 0; i < ARRAY_SIZE(bstack_sort_dimensions); i++) {