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/acme/linux into perf/core

Pull perf/core improvements and fixes from Arnaldo Carvalho de Melo:

New features:

 - Add 'L' hotkey to dynamicly set the percent threshold for histogram
   entries and callchains, i.e. dynamicly do what the --percent-limit
   command line option to 'top' and 'report' does. (Namhyung Kim)

Infrastructure changes:

 - Per hists field and sort lists, that will be used, for instance,
   in the c2c tool (Jiri Olsa)

Documentation changes:

 - Update documentation of --sort and --perf-limit options
   for 'perf report' (Namhyung Kim)

Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
Signed-off-by: Ingo Molnar <mingo@kernel.org>
  • Loading branch information
Ingo Molnar committed Feb 4, 2016
2 parents b83ea91 + b62e8df commit d3aaf09
Show file tree
Hide file tree
Showing 14 changed files with 425 additions and 236 deletions.
37 changes: 20 additions & 17 deletions tools/perf/Documentation/perf-report.txt
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,22 @@ OPTIONS
And default sort keys are changed to comm, dso_from, symbol_from, dso_to
and symbol_to, see '--branch-stack'.

If the --mem-mode option is used, the following sort keys are also available
(incompatible with --branch-stack):
symbol_daddr, dso_daddr, locked, tlb, mem, snoop, dcacheline.

- symbol_daddr: name of data symbol being executed on at the time of sample
- dso_daddr: name of library or module containing the data being executed
on at the time of the sample
- locked: whether the bus was locked at the time of the sample
- tlb: type of tlb access for the data at the time of the sample
- mem: type of memory access for the data at the time of the sample
- snoop: type of snoop (if any) for the data at the time of the sample
- dcacheline: the cacheline the data address is on at the time of the sample

And the default sort keys are changed to local_weight, mem, sym, dso,
symbol_daddr, dso_daddr, snoop, tlb, locked, see '--mem-mode'.

If the data file has tracepoint event(s), following (dynamic) sort keys
are also available:
trace, trace_fields, [<event>.]<field>[/raw]
Expand Down Expand Up @@ -151,22 +167,6 @@ OPTIONS
By default, every sort keys not specified in -F will be appended
automatically.

If --mem-mode option is used, following sort keys are also available
(incompatible with --branch-stack):
symbol_daddr, dso_daddr, locked, tlb, mem, snoop, dcacheline.

- symbol_daddr: name of data symbol being executed on at the time of sample
- dso_daddr: name of library or module containing the data being executed
on at the time of sample
- locked: whether the bus was locked at the time of sample
- tlb: type of tlb access for the data at the time of sample
- mem: type of memory access for the data at the time of sample
- snoop: type of snoop (if any) for the data at the time of sample
- dcacheline: the cacheline the data address is on at the time of sample

And default sort keys are changed to local_weight, mem, sym, dso,
symbol_daddr, dso_daddr, snoop, tlb, locked, see '--mem-mode'.

-p::
--parent=<regex>::
A regex filter to identify parent. The parent is a caller of this
Expand Down Expand Up @@ -351,7 +351,10 @@ OPTIONS

--percent-limit::
Do not show entries which have an overhead under that percent.
(Default: 0).
(Default: 0). Note that this option also sets the percent limit (threshold)
of callchains. However the default value of callchain threshold is
different than the default value of hist entries. Please see the
--call-graph option for details.

--percentage::
Determine how to display the overhead percentage of filtered entries.
Expand Down
2 changes: 1 addition & 1 deletion tools/perf/builtin-annotate.c
Original file line number Diff line number Diff line change
Expand Up @@ -245,7 +245,7 @@ static int __cmd_annotate(struct perf_annotate *ann)
hists__collapse_resort(hists, NULL);
/* Don't sort callchain */
perf_evsel__reset_sample_bit(pos, CALLCHAIN);
hists__output_resort(hists, NULL);
perf_evsel__output_resort(pos, NULL);

if (symbol_conf.event_group &&
!perf_evsel__is_group_leader(pos))
Expand Down
20 changes: 10 additions & 10 deletions tools/perf/builtin-report.c
Original file line number Diff line number Diff line change
Expand Up @@ -507,7 +507,7 @@ static void report__output_resort(struct report *rep)
ui_progress__init(&prog, rep->nr_entries, "Sorting events for output...");

evlist__for_each(rep->session->evlist, pos)
hists__output_resort(evsel__hists(pos), &prog);
perf_evsel__output_resort(pos, &prog);

ui_progress__finish();
}
Expand Down Expand Up @@ -912,15 +912,6 @@ int cmd_report(int argc, const char **argv, const char *prefix __maybe_unused)
symbol_conf.cumulate_callchain = false;
}

if (setup_sorting(session->evlist) < 0) {
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;
}

/* Force tty output for header output and per-thread stat. */
if (report.header || report.header_only || report.show_threads)
use_browser = 0;
Expand All @@ -930,6 +921,15 @@ int cmd_report(int argc, const char **argv, const char *prefix __maybe_unused)
else
use_browser = 0;

if (setup_sorting(session->evlist) < 0) {
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 (report.header || report.header_only) {
perf_session__fprintf_info(session, stdout,
report.show_full_info);
Expand Down
24 changes: 13 additions & 11 deletions tools/perf/builtin-top.c
Original file line number Diff line number Diff line change
Expand Up @@ -252,7 +252,8 @@ static void perf_top__print_sym_table(struct perf_top *top)
char bf[160];
int printed = 0;
const int win_width = top->winsize.ws_col - 1;
struct hists *hists = evsel__hists(top->sym_evsel);
struct perf_evsel *evsel = top->sym_evsel;
struct hists *hists = evsel__hists(evsel);

puts(CONSOLE_CLEAR);

Expand Down Expand Up @@ -288,7 +289,7 @@ static void perf_top__print_sym_table(struct perf_top *top)
}

hists__collapse_resort(hists, NULL);
hists__output_resort(hists, NULL);
perf_evsel__output_resort(evsel, NULL);

hists__output_recalc_col_len(hists, top->print_entries - printed);
putchar('\n');
Expand Down Expand Up @@ -540,14 +541,15 @@ static bool perf_top__handle_keypress(struct perf_top *top, int c)
static void perf_top__sort_new_samples(void *arg)
{
struct perf_top *t = arg;
struct perf_evsel *evsel = t->sym_evsel;
struct hists *hists;

perf_top__reset_sample_counters(t);

if (t->evlist->selected != NULL)
t->sym_evsel = t->evlist->selected;

hists = evsel__hists(t->sym_evsel);
hists = evsel__hists(evsel);

if (t->evlist->enabled) {
if (t->zero) {
Expand All @@ -559,7 +561,7 @@ static void perf_top__sort_new_samples(void *arg)
}

hists__collapse_resort(hists, NULL);
hists__output_resort(hists, NULL);
perf_evsel__output_resort(evsel, NULL);
}

static void *display_thread_tui(void *arg)
Expand Down Expand Up @@ -1243,6 +1245,13 @@ int cmd_top(int argc, const char **argv, const char *prefix __maybe_unused)
/* 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)
use_browser = 1;

setup_browser(false);

if (setup_sorting(top.evlist) < 0) {
if (sort_order)
parse_options_usage(top_usage, options, "s", 1);
Expand All @@ -1252,13 +1261,6 @@ int cmd_top(int argc, const char **argv, const char *prefix __maybe_unused)
goto out_delete_evlist;
}

if (top.use_stdio)
use_browser = 0;
else if (top.use_tui)
use_browser = 1;

setup_browser(false);

status = target__validate(target);
if (status) {
target__strerror(target, status, errbuf, BUFSIZ);
Expand Down
2 changes: 1 addition & 1 deletion tools/perf/tests/hists_cumulate.c
Original file line number Diff line number Diff line change
Expand Up @@ -191,7 +191,7 @@ static int do_test(struct hists *hists, struct result *expected, size_t nr_expec
* function since TEST_ASSERT_VAL() returns in case of failure.
*/
hists__collapse_resort(hists, NULL);
hists__output_resort(hists, NULL);
perf_evsel__output_resort(hists_to_evsel(hists), NULL);

if (verbose > 2) {
pr_info("use callchain: %d, cumulate callchain: %d\n",
Expand Down
2 changes: 1 addition & 1 deletion tools/perf/tests/hists_filter.c
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,7 @@ int test__hists_filter(int subtest __maybe_unused)
struct hists *hists = evsel__hists(evsel);

hists__collapse_resort(hists, NULL);
hists__output_resort(hists, NULL);
perf_evsel__output_resort(evsel, NULL);

if (verbose > 2) {
pr_info("Normal histogram\n");
Expand Down
10 changes: 5 additions & 5 deletions tools/perf/tests/hists_output.c
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,7 @@ static int test1(struct perf_evsel *evsel, struct machine *machine)
goto out;

hists__collapse_resort(hists, NULL);
hists__output_resort(hists, NULL);
perf_evsel__output_resort(evsel, NULL);

if (verbose > 2) {
pr_info("[fields = %s, sort = %s]\n", field_order, sort_order);
Expand Down Expand Up @@ -256,7 +256,7 @@ static int test2(struct perf_evsel *evsel, struct machine *machine)
goto out;

hists__collapse_resort(hists, NULL);
hists__output_resort(hists, NULL);
perf_evsel__output_resort(evsel, NULL);

if (verbose > 2) {
pr_info("[fields = %s, sort = %s]\n", field_order, sort_order);
Expand Down Expand Up @@ -310,7 +310,7 @@ static int test3(struct perf_evsel *evsel, struct machine *machine)
goto out;

hists__collapse_resort(hists, NULL);
hists__output_resort(hists, NULL);
perf_evsel__output_resort(evsel, NULL);

if (verbose > 2) {
pr_info("[fields = %s, sort = %s]\n", field_order, sort_order);
Expand Down Expand Up @@ -388,7 +388,7 @@ static int test4(struct perf_evsel *evsel, struct machine *machine)
goto out;

hists__collapse_resort(hists, NULL);
hists__output_resort(hists, NULL);
perf_evsel__output_resort(evsel, NULL);

if (verbose > 2) {
pr_info("[fields = %s, sort = %s]\n", field_order, sort_order);
Expand Down Expand Up @@ -491,7 +491,7 @@ static int test5(struct perf_evsel *evsel, struct machine *machine)
goto out;

hists__collapse_resort(hists, NULL);
hists__output_resort(hists, NULL);
perf_evsel__output_resort(evsel, NULL);

if (verbose > 2) {
pr_info("[fields = %s, sort = %s]\n", field_order, sort_order);
Expand Down
63 changes: 59 additions & 4 deletions tools/perf/ui/browsers/hists.c
Original file line number Diff line number Diff line change
Expand Up @@ -1095,7 +1095,7 @@ static int hist_browser__show_entry(struct hist_browser *browser,

hist_browser__gotorc(browser, row, 0);

perf_hpp__for_each_format(fmt) {
hists__for_each_format(browser->hists, fmt) {
if (perf_hpp__should_skip(fmt, entry->hists) ||
column++ < browser->b.horiz_scroll)
continue;
Expand Down Expand Up @@ -1175,7 +1175,7 @@ static int hists_browser__scnprintf_headers(struct hist_browser *browser, char *
return ret;
}

perf_hpp__for_each_format(fmt) {
hists__for_each_format(browser->hists, fmt) {
if (perf_hpp__should_skip(fmt, hists) || column++ < browser->b.horiz_scroll)
continue;

Expand Down Expand Up @@ -1441,7 +1441,7 @@ static int hist_browser__fprintf_entry(struct hist_browser *browser,
if (symbol_conf.use_callchain)
printed += fprintf(fp, "%c ", folded_sign);

perf_hpp__for_each_format(fmt) {
hists__for_each_format(browser->hists, fmt) {
if (perf_hpp__should_skip(fmt, he->hists))
continue;

Expand Down Expand Up @@ -2029,6 +2029,42 @@ static void hist_browser__update_nr_entries(struct hist_browser *hb)
hb->nr_non_filtered_entries = nr_entries;
}

static void hist_browser__update_percent_limit(struct hist_browser *hb,
double percent)
{
struct hist_entry *he;
struct rb_node *nd = rb_first(&hb->hists->entries);
u64 total = hists__total_period(hb->hists);
u64 min_callchain_hits = total * (percent / 100);

hb->min_pcnt = callchain_param.min_percent = percent;

if (!symbol_conf.use_callchain)
return;

while ((nd = hists__filter_entries(nd, hb->min_pcnt)) != NULL) {
he = rb_entry(nd, struct hist_entry, rb_node);

if (callchain_param.mode == CHAIN_GRAPH_REL) {
total = he->stat.period;

if (symbol_conf.cumulate_callchain)
total = he->stat_acc->period;

min_callchain_hits = total * (percent / 100);
}

callchain_param.sort(&he->sorted_chain, he->callchain,
min_callchain_hits, &callchain_param);

/* force to re-evaluate folding state of callchains */
he->init_have_children = false;
hist_entry__set_folding(he, false);

nd = rb_next(nd);
}
}

static int perf_evsel__hists_browse(struct perf_evsel *evsel, int nr_events,
const char *helpline,
bool left_exits,
Expand Down Expand Up @@ -2064,6 +2100,7 @@ static int perf_evsel__hists_browse(struct perf_evsel *evsel, int nr_events,
"E Expand all callchains\n" \
"F Toggle percentage of filtered entries\n" \
"H Display column headers\n" \
"L Change percent limit\n" \
"m Display context menu\n" \
"S Zoom into current Processor Socket\n" \

Expand Down Expand Up @@ -2104,7 +2141,7 @@ static int perf_evsel__hists_browse(struct perf_evsel *evsel, int nr_events,
memset(options, 0, sizeof(options));
memset(actions, 0, sizeof(actions));

perf_hpp__for_each_format(fmt) {
hists__for_each_format(browser->hists, fmt) {
perf_hpp__reset_width(fmt, hists);
/*
* This is done just once, and activates the horizontal scrolling
Expand Down Expand Up @@ -2219,6 +2256,24 @@ static int perf_evsel__hists_browse(struct perf_evsel *evsel, int nr_events,
top->zero = !top->zero;
}
continue;
case 'L':
if (ui_browser__input_window("Percent Limit",
"Please enter the value you want to hide entries under that percent.",
buf, "ENTER: OK, ESC: Cancel",
delay_secs * 2) == K_ENTER) {
char *end;
double new_percent = strtod(buf, &end);

if (new_percent < 0 || new_percent > 100) {
ui_browser__warning(&browser->b, delay_secs * 2,
"Invalid percent: %.2f", new_percent);
continue;
}

hist_browser__update_percent_limit(browser, new_percent);
hist_browser__reset(browser);
}
continue;
case K_F1:
case 'h':
case '?':
Expand Down
6 changes: 3 additions & 3 deletions tools/perf/ui/gtk/hists.c
Original file line number Diff line number Diff line change
Expand Up @@ -306,7 +306,7 @@ static void perf_gtk__show_hists(GtkWidget *window, struct hists *hists,

nr_cols = 0;

perf_hpp__for_each_format(fmt)
hists__for_each_format(hists, fmt)
col_types[nr_cols++] = G_TYPE_STRING;

store = gtk_tree_store_newv(nr_cols, col_types);
Expand All @@ -317,7 +317,7 @@ static void perf_gtk__show_hists(GtkWidget *window, struct hists *hists,

col_idx = 0;

perf_hpp__for_each_format(fmt) {
hists__for_each_format(hists, fmt) {
if (perf_hpp__should_skip(fmt, hists))
continue;

Expand Down Expand Up @@ -367,7 +367,7 @@ static void perf_gtk__show_hists(GtkWidget *window, struct hists *hists,

col_idx = 0;

perf_hpp__for_each_format(fmt) {
hists__for_each_format(hists, fmt) {
if (perf_hpp__should_skip(fmt, h->hists))
continue;

Expand Down
Loading

0 comments on commit d3aaf09

Please sign in to comment.