Skip to content

Commit a2ce067

Browse files
namhyungolsajiri
authored andcommitted
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>
1 parent fb821c9 commit a2ce067

File tree

8 files changed

+67
-13
lines changed

8 files changed

+67
-13
lines changed

tools/perf/Documentation/perf-diff.txt

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,8 @@ OPTIONS
5050

5151
-s::
5252
--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.
5455

5556
-t::
5657
--field-separator=::
@@ -202,4 +203,4 @@ If specified the 'Weighted diff' column is displayed with value 'd' computed as:
202203

203204
SEE ALSO
204205
--------
205-
linkperf:perf-record[1]
206+
linkperf:perf-record[1], linkperf:perf-report[1]

tools/perf/Documentation/perf-report.txt

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,15 @@ OPTIONS
7979
abort cost. This is the global weight.
8080
- local_weight: Local weight version of the weight above.
8181
- 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
8291

8392
By default, comm, dso and symbol keys are used.
8493
(i.e. --sort comm,dso,symbol)

tools/perf/Documentation/perf-top.txt

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,8 @@ Default is to monitor all CPUS.
113113
-s::
114114
--sort::
115115
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.
117118

118119
-n::
119120
--show-nr-samples::
@@ -212,4 +213,4 @@ Pressing any unmapped key displays a menu, and prompts for input.
212213

213214
SEE ALSO
214215
--------
215-
linkperf:perf-stat[1], linkperf:perf-list[1]
216+
linkperf:perf-stat[1], linkperf:perf-list[1], linkperf:perf-report[1]

tools/perf/builtin-diff.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -741,7 +741,8 @@ static const struct option options[] = {
741741
OPT_STRING('S', "symbols", &symbol_conf.sym_list_str, "symbol[,symbol...]",
742742
"only consider these symbols"),
743743
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."),
745746
OPT_STRING('t', "field-separator", &symbol_conf.field_sep, "separator",
746747
"separator for columns, no spaces will be added between "
747748
"columns '.' is reserved."),

tools/perf/builtin-report.c

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -699,10 +699,8 @@ int cmd_report(int argc, const char **argv, const char *prefix __maybe_unused)
699699
OPT_BOOLEAN(0, "header-only", &report.header_only,
700700
"Show only data header."),
701701
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."),
706704
OPT_BOOLEAN(0, "showcpuutilization", &symbol_conf.show_cpu_utilization,
707705
"Show sample percentage for different cpu modes"),
708706
OPT_STRING('p', "parent", &parent_pattern, "regex",

tools/perf/builtin-top.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1083,8 +1083,8 @@ int cmd_top(int argc, const char **argv, const char *prefix __maybe_unused)
10831083
OPT_INCR('v', "verbose", &verbose,
10841084
"be more verbose (show counter open errors, etc)"),
10851085
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."),
10881088
OPT_BOOLEAN('n', "show-nr-samples", &symbol_conf.show_nr_samples,
10891089
"Show a column with the number of samples"),
10901090
OPT_CALLBACK_NOOPT('g', NULL, &top.record_opts,

tools/perf/ui/hist.c

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -346,8 +346,13 @@ void perf_hpp__init(void)
346346
int i;
347347

348348
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);
351356
}
352357

353358
perf_hpp__column_enable(PERF_HPP__OVERHEAD);

tools/perf/util/sort.c

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1028,6 +1028,26 @@ static struct sort_dimension memory_sort_dimensions[] = {
10281028

10291029
#undef DIM
10301030

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+
10311051
struct hpp_sort_entry {
10321052
struct perf_hpp_fmt hpp;
10331053
struct sort_entry *se;
@@ -1115,6 +1135,16 @@ static int __sort_dimension__add(struct sort_dimension *sd, enum sort_type idx)
11151135
return 0;
11161136
}
11171137

1138+
static int __hpp_dimension__add(struct hpp_dimension *hd)
1139+
{
1140+
if (!hd->taken) {
1141+
hd->taken = 1;
1142+
1143+
perf_hpp__register_sort_field(hd->fmt);
1144+
}
1145+
return 0;
1146+
}
1147+
11181148
int sort_dimension__add(const char *tok)
11191149
{
11201150
unsigned int i;
@@ -1144,6 +1174,15 @@ int sort_dimension__add(const char *tok)
11441174
return __sort_dimension__add(sd, i);
11451175
}
11461176

1177+
for (i = 0; i < ARRAY_SIZE(hpp_sort_dimensions); i++) {
1178+
struct hpp_dimension *hd = &hpp_sort_dimensions[i];
1179+
1180+
if (strncasecmp(tok, hd->name, strlen(tok)))
1181+
continue;
1182+
1183+
return __hpp_dimension__add(hd);
1184+
}
1185+
11471186
for (i = 0; i < ARRAY_SIZE(bstack_sort_dimensions); i++) {
11481187
struct sort_dimension *sd = &bstack_sort_dimensions[i];
11491188

0 commit comments

Comments
 (0)