Skip to content

Commit

Permalink
Merge tag 'perf-core-for-mingo' of git://git.kernel.org/pub/scm/linux…
Browse files Browse the repository at this point in the history
…/kernel/git/jolsa/perf into perf/core

Pull perf/core improvements and fixes from Jiri Olsa:

  * Android related fixes for pager and map dso resolving (Michael Lentine)

  * Add -F option for specifying output fields (Namhyung Kim)

Signed-off-by: Jiri Olsa <jolsa@kernel.org>
Signed-off-by: Ingo Molnar <mingo@kernel.org>
  • Loading branch information
Ingo Molnar committed May 22, 2014
2 parents 6480c56 + eca8183 commit e450f90
Show file tree
Hide file tree
Showing 25 changed files with 1,601 additions and 386 deletions.
5 changes: 3 additions & 2 deletions tools/perf/Documentation/perf-diff.txt
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,8 @@ OPTIONS

-s::
--sort=::
Sort by key(s): pid, comm, dso, symbol.
Sort by key(s): pid, comm, dso, symbol, cpu, parent, srcline.
Please see description of --sort in the perf-report man page.

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

SEE ALSO
--------
linkperf:perf-record[1]
linkperf:perf-record[1], linkperf:perf-report[1]
19 changes: 19 additions & 0 deletions tools/perf/Documentation/perf-report.txt
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,15 @@ OPTIONS
abort cost. This is the global weight.
- local_weight: Local weight version of the weight above.
- transaction: Transaction abort flags.
- overhead: Overhead percentage of sample
- overhead_sys: Overhead percentage of sample running in system mode
- overhead_us: Overhead percentage of sample running in user mode
- overhead_guest_sys: Overhead percentage of sample running in system mode
on guest machine
- overhead_guest_us: Overhead percentage of sample running in user mode on
guest machine
- sample: Number of sample
- period: Raw number of event count of sample

By default, comm, dso and symbol keys are used.
(i.e. --sort comm,dso,symbol)
Expand All @@ -98,6 +107,16 @@ OPTIONS
And default sort keys are changed to comm, dso_from, symbol_from, dso_to
and symbol_to, see '--branch-stack'.

-F::
--fields=::
Specify output field - multiple keys can be specified in CSV format.
Following fields are available:
overhead, overhead_sys, overhead_us, sample and period.
Also it can contain any sort key(s).

By default, every sort keys not specified in -F will be appended
automatically.

-p::
--parent=<regex>::
A regex filter to identify parent. The parent is a caller of this
Expand Down
14 changes: 12 additions & 2 deletions tools/perf/Documentation/perf-top.txt
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,17 @@ Default is to monitor all CPUS.
-s::
--sort::
Sort by key(s): pid, comm, dso, symbol, parent, srcline, weight,
local_weight, abort, in_tx, transaction
local_weight, abort, in_tx, transaction, overhead, sample, period.
Please see description of --sort in the perf-report man page.

--fields=::
Specify output field - multiple keys can be specified in CSV format.
Following fields are available:
overhead, overhead_sys, overhead_us, sample and period.
Also it can contain any sort key(s).

By default, every sort keys not specified in --field will be appended
automatically.

-n::
--show-nr-samples::
Expand Down Expand Up @@ -212,4 +222,4 @@ Pressing any unmapped key displays a menu, and prompts for input.

SEE ALSO
--------
linkperf:perf-stat[1], linkperf:perf-list[1]
linkperf:perf-stat[1], linkperf:perf-list[1], linkperf:perf-report[1]
1 change: 1 addition & 0 deletions tools/perf/Makefile.perf
Original file line number Diff line number Diff line change
Expand Up @@ -399,6 +399,7 @@ LIB_OBJS += $(OUTPUT)tests/pmu.o
LIB_OBJS += $(OUTPUT)tests/hists_common.o
LIB_OBJS += $(OUTPUT)tests/hists_link.o
LIB_OBJS += $(OUTPUT)tests/hists_filter.o
LIB_OBJS += $(OUTPUT)tests/hists_output.o
LIB_OBJS += $(OUTPUT)tests/python-use.o
LIB_OBJS += $(OUTPUT)tests/bp_signal.o
LIB_OBJS += $(OUTPUT)tests/bp_signal_overflow.o
Expand Down
7 changes: 4 additions & 3 deletions tools/perf/builtin-diff.c
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,6 @@ static int data__files_cnt;
#define data__for_each_file(i, d) data__for_each_file_start(i, d, 0)
#define data__for_each_file_new(i, d) data__for_each_file_start(i, d, 1)

static char diff__default_sort_order[] = "dso,symbol";
static bool force;
static bool show_period;
static bool show_formula;
Expand Down Expand Up @@ -741,7 +740,8 @@ static const struct option options[] = {
OPT_STRING('S', "symbols", &symbol_conf.sym_list_str, "symbol[,symbol...]",
"only consider these symbols"),
OPT_STRING('s', "sort", &sort_order, "key[,key2...]",
"sort by key(s): pid, comm, dso, symbol, parent"),
"sort by key(s): pid, comm, dso, symbol, parent, cpu, srcline, ..."
" Please refer the man page for the complete list."),
OPT_STRING('t', "field-separator", &symbol_conf.field_sep, "separator",
"separator for columns, no spaces will be added between "
"columns '.' is reserved."),
Expand Down Expand Up @@ -1141,7 +1141,6 @@ int cmd_diff(int argc, const char **argv, const char *prefix __maybe_unused)
{
perf_config(perf_default_config, NULL);

sort_order = diff__default_sort_order;
argc = parse_options(argc, argv, options, diff_usage, 0);

if (symbol__init() < 0)
Expand All @@ -1152,6 +1151,8 @@ int cmd_diff(int argc, const char **argv, const char *prefix __maybe_unused)

ui_init();

sort__mode = SORT_MODE__DIFF;

if (setup_sorting() < 0)
usage_with_options(diff_usage, options);

Expand Down
41 changes: 10 additions & 31 deletions tools/perf/builtin-report.c
Original file line number Diff line number Diff line change
Expand Up @@ -699,10 +699,10 @@ int cmd_report(int argc, const char **argv, const char *prefix __maybe_unused)
OPT_BOOLEAN(0, "header-only", &report.header_only,
"Show only data header."),
OPT_STRING('s', "sort", &sort_order, "key[,key2...]",
"sort by key(s): pid, comm, dso, symbol, parent, cpu, srcline,"
" dso_to, dso_from, symbol_to, symbol_from, mispredict,"
" weight, local_weight, mem, symbol_daddr, dso_daddr, tlb, "
"snoop, locked, abort, in_tx, transaction"),
"sort by key(s): pid, comm, dso, symbol, parent, cpu, srcline, ..."
" Please refer the man page for the complete list."),
OPT_STRING('F', "fields", &field_order, "key[,keys...]",
"output field(s): overhead, period, sample plus all of sort keys"),
OPT_BOOLEAN(0, "showcpuutilization", &symbol_conf.show_cpu_utilization,
"Show sample percentage for different cpu modes"),
OPT_STRING('p', "parent", &parent_pattern, "regex",
Expand Down Expand Up @@ -807,52 +807,31 @@ int cmd_report(int argc, const char **argv, const char *prefix __maybe_unused)
if (branch_mode == -1 && has_br_stack)
sort__mode = SORT_MODE__BRANCH;

/* sort__mode could be NORMAL if --no-branch-stack */
if (sort__mode == SORT_MODE__BRANCH) {
/*
* if no sort_order is provided, then specify
* branch-mode specific order
*/
if (sort_order == default_sort_order)
sort_order = "comm,dso_from,symbol_from,"
"dso_to,symbol_to";

}
if (report.mem_mode) {
if (sort__mode == SORT_MODE__BRANCH) {
pr_err("branch and mem mode incompatible\n");
goto error;
}
sort__mode = SORT_MODE__MEMORY;

/*
* if no sort_order is provided, then specify
* branch-mode specific order
*/
if (sort_order == default_sort_order)
sort_order = "local_weight,mem,sym,dso,symbol_daddr,dso_daddr,snoop,tlb,locked";
}

if (setup_sorting() < 0) {
parse_options_usage(report_usage, options, "s", 1);
if (sort_order)
parse_options_usage(report_usage, options, "s", 1);
if (field_order)
parse_options_usage(sort_order ? NULL : report_usage,
options, "F", 1);
goto error;
}

if (parent_pattern != default_parent_pattern) {
if (sort_dimension__add("parent") < 0)
goto error;
}

/* Force tty output for header output. */
if (report.header || report.header_only)
use_browser = 0;

if (strcmp(input_name, "-") != 0)
setup_browser(true);
else {
else
use_browser = 0;
perf_hpp__init();
}

if (report.header || report.header_only) {
perf_session__fprintf_info(session, stdout,
Expand Down
20 changes: 12 additions & 8 deletions tools/perf/builtin-top.c
Original file line number Diff line number Diff line change
Expand Up @@ -1083,8 +1083,10 @@ int cmd_top(int argc, const char **argv, const char *prefix __maybe_unused)
OPT_INCR('v', "verbose", &verbose,
"be more verbose (show counter open errors, etc)"),
OPT_STRING('s', "sort", &sort_order, "key[,key2...]",
"sort by key(s): pid, comm, dso, symbol, parent, weight, local_weight,"
" abort, in_tx, transaction"),
"sort by key(s): pid, comm, dso, symbol, parent, cpu, srcline, ..."
" Please refer the man page for the complete list."),
OPT_STRING(0, "fields", &field_order, "key[,keys...]",
"output field(s): overhead, period, sample plus all of sort keys"),
OPT_BOOLEAN('n', "show-nr-samples", &symbol_conf.show_nr_samples,
"Show a column with the number of samples"),
OPT_CALLBACK_NOOPT('g', NULL, &top.record_opts,
Expand Down Expand Up @@ -1137,17 +1139,19 @@ int cmd_top(int argc, const char **argv, const char *prefix __maybe_unused)
if (argc)
usage_with_options(top_usage, options);

if (sort_order == default_sort_order)
sort_order = "dso,symbol";
sort__mode = SORT_MODE__TOP;
/* display thread wants entries to be collapsed in a different tree */
sort__need_collapse = 1;

if (setup_sorting() < 0) {
parse_options_usage(top_usage, options, "s", 1);
if (sort_order)
parse_options_usage(top_usage, options, "s", 1);
if (field_order)
parse_options_usage(sort_order ? NULL : top_usage,
options, "fields", 0);
goto out_delete_evlist;
}

/* display thread wants entries to be collapsed in a different tree */
sort__need_collapse = 1;

if (top.use_stdio)
use_browser = 0;
else if (top.use_tui)
Expand Down
4 changes: 4 additions & 0 deletions tools/perf/tests/builtin-test.c
Original file line number Diff line number Diff line change
Expand Up @@ -135,6 +135,10 @@ static struct test {
.desc = "Test thread mg sharing",
.func = test__thread_mg_share,
},
{
.desc = "Test output sorting of hist entries",
.func = test__hists_output,
},
{
.func = NULL,
},
Expand Down
57 changes: 57 additions & 0 deletions tools/perf/tests/hists_common.c
Original file line number Diff line number Diff line change
Expand Up @@ -146,3 +146,60 @@ struct machine *setup_fake_machine(struct machines *machines)
machine__delete(machine);
return NULL;
}

void print_hists_in(struct hists *hists)
{
int i = 0;
struct rb_root *root;
struct rb_node *node;

if (sort__need_collapse)
root = &hists->entries_collapsed;
else
root = hists->entries_in;

pr_info("----- %s --------\n", __func__);
node = rb_first(root);
while (node) {
struct hist_entry *he;

he = rb_entry(node, struct hist_entry, rb_node_in);

if (!he->filtered) {
pr_info("%2d: entry: %-8s [%-8s] %20s: period = %"PRIu64"\n",
i, thread__comm_str(he->thread),
he->ms.map->dso->short_name,
he->ms.sym->name, he->stat.period);
}

i++;
node = rb_next(node);
}
}

void print_hists_out(struct hists *hists)
{
int i = 0;
struct rb_root *root;
struct rb_node *node;

root = &hists->entries;

pr_info("----- %s --------\n", __func__);
node = rb_first(root);
while (node) {
struct hist_entry *he;

he = rb_entry(node, struct hist_entry, rb_node);

if (!he->filtered) {
pr_info("%2d: entry: %8s:%5d [%-8s] %20s: period = %"PRIu64"\n",
i, thread__comm_str(he->thread), he->thread->tid,
he->ms.map->dso->short_name,
he->ms.sym->name, he->stat.period);
}

i++;
node = rb_next(node);
}
}
3 changes: 3 additions & 0 deletions tools/perf/tests/hists_common.h
Original file line number Diff line number Diff line change
Expand Up @@ -41,4 +41,7 @@ struct machines;
*/
struct machine *setup_fake_machine(struct machines *machines);

void print_hists_in(struct hists *hists);
void print_hists_out(struct hists *hists);

#endif /* __PERF_TESTS__HISTS_COMMON_H__ */
38 changes: 6 additions & 32 deletions tools/perf/tests/hists_filter.c
Original file line number Diff line number Diff line change
Expand Up @@ -98,33 +98,6 @@ static int add_hist_entries(struct perf_evlist *evlist, struct machine *machine)
return TEST_FAIL;
}

static void print_hists(struct hists *hists)
{
int i = 0;
struct rb_root *root;
struct rb_node *node;

root = &hists->entries;

pr_info("----- %s --------\n", __func__);
node = rb_first(root);
while (node) {
struct hist_entry *he;

he = rb_entry(node, struct hist_entry, rb_node);

if (!he->filtered) {
pr_info("%2d: entry: %-8s [%-8s] %20s: period = %"PRIu64"\n",
i, thread__comm_str(he->thread),
he->ms.map->dso->short_name,
he->ms.sym->name, he->stat.period);
}

i++;
node = rb_next(node);
}
}

int test__hists_filter(void)
{
int err = TEST_FAIL;
Expand Down Expand Up @@ -169,7 +142,7 @@ int test__hists_filter(void)

if (verbose > 2) {
pr_info("Normal histogram\n");
print_hists(hists);
print_hists_out(hists);
}

TEST_ASSERT_VAL("Invalid nr samples",
Expand All @@ -193,7 +166,7 @@ int test__hists_filter(void)

if (verbose > 2) {
pr_info("Histogram for thread filter\n");
print_hists(hists);
print_hists_out(hists);
}

/* normal stats should be invariant */
Expand Down Expand Up @@ -222,7 +195,7 @@ int test__hists_filter(void)

if (verbose > 2) {
pr_info("Histogram for dso filter\n");
print_hists(hists);
print_hists_out(hists);
}

/* normal stats should be invariant */
Expand Down Expand Up @@ -257,7 +230,7 @@ int test__hists_filter(void)

if (verbose > 2) {
pr_info("Histogram for symbol filter\n");
print_hists(hists);
print_hists_out(hists);
}

/* normal stats should be invariant */
Expand All @@ -284,7 +257,7 @@ int test__hists_filter(void)

if (verbose > 2) {
pr_info("Histogram for all filters\n");
print_hists(hists);
print_hists_out(hists);
}

/* normal stats should be invariant */
Expand All @@ -310,6 +283,7 @@ int test__hists_filter(void)
out:
/* tear down everything */
perf_evlist__delete(evlist);
reset_output_field();
machines__exit(&machines);

return err;
Expand Down
Loading

0 comments on commit e450f90

Please sign in to comment.