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/urgent

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

  * Synthesize anon MMAP records again, fix from Don Zickus.

  * Add an option in 'perf record' to force per-cpu mmaps, from Adrian Hunter.

  * Limit max callchain using max_stack on DWARF unwinding too.

  * Fix segfault in the UI browser caused by off by one handling END key.

  * Add '--demangle'/'--no-demangle' to perf probe, so that we can overcome
    current limitations in handling C++ symbols, from Azat Khuzhin .

  * Tweak 'perf trace' summary output, from Pekka Enberg.

Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
Signed-off-by: Ingo Molnar <mingo@kernel.org>
  • Loading branch information
Ingo Molnar committed Nov 15, 2013
2 parents e310718 + 539e6bb commit 89b4be1
Show file tree
Hide file tree
Showing 16 changed files with 50 additions and 30 deletions.
6 changes: 6 additions & 0 deletions tools/perf/Documentation/perf-record.txt
Original file line number Diff line number Diff line change
Expand Up @@ -201,6 +201,12 @@ abort events and some memory events in precise mode on modern Intel CPUs.
--transaction::
Record transaction flags for transaction related events.

--force-per-cpu::
Force the use of per-cpu mmaps. By default, when tasks are specified (i.e. -p,
-t or -u options) per-thread mmaps are created. This option overrides that and
forces per-cpu mmaps. A side-effect of that is that inheritance is
automatically enabled. Add the -i option also to disable inheritance.

SEE ALSO
--------
linkperf:perf-stat[1], linkperf:perf-list[1]
2 changes: 2 additions & 0 deletions tools/perf/builtin-probe.c
Original file line number Diff line number Diff line change
Expand Up @@ -325,6 +325,8 @@ int cmd_probe(int argc, const char **argv, const char *prefix __maybe_unused)
opt_set_filter),
OPT_CALLBACK('x', "exec", NULL, "executable|path",
"target executable name or path", opt_set_target),
OPT_BOOLEAN(0, "demangle", &symbol_conf.demangle,
"Disable symbol demangling"),
OPT_END()
};
int ret;
Expand Down
2 changes: 2 additions & 0 deletions tools/perf/builtin-record.c
Original file line number Diff line number Diff line change
Expand Up @@ -888,6 +888,8 @@ const struct option record_options[] = {
"sample by weight (on special events only)"),
OPT_BOOLEAN(0, "transaction", &record.opts.sample_transaction,
"sample transaction flags (special events only)"),
OPT_BOOLEAN(0, "force-per-cpu", &record.opts.target.force_per_cpu,
"force the use of per-cpu mmaps"),
OPT_END()
};

Expand Down
4 changes: 2 additions & 2 deletions tools/perf/builtin-top.c
Original file line number Diff line number Diff line change
Expand Up @@ -1172,15 +1172,15 @@ int cmd_top(int argc, const char **argv, const char *prefix __maybe_unused)
status = target__validate(target);
if (status) {
target__strerror(target, status, errbuf, BUFSIZ);
ui__warning("%s", errbuf);
ui__warning("%s\n", errbuf);
}

status = target__parse_uid(target);
if (status) {
int saved_errno = errno;

target__strerror(target, status, errbuf, BUFSIZ);
ui__error("%s", errbuf);
ui__error("%s\n", errbuf);

status = -saved_errno;
goto out_delete_evlist;
Expand Down
10 changes: 5 additions & 5 deletions tools/perf/builtin-trace.c
Original file line number Diff line number Diff line change
Expand Up @@ -2112,9 +2112,9 @@ static size_t thread__dump_stats(struct thread_trace *ttrace,

printed += fprintf(fp, "\n");

printed += fprintf(fp, " msec/call\n");
printed += fprintf(fp, " syscall calls min avg max stddev\n");
printed += fprintf(fp, " --------------- -------- -------- -------- -------- ------\n");
printed += fprintf(fp, " syscall calls min avg max stddev\n");
printed += fprintf(fp, " (msec) (msec) (msec) (%%)\n");
printed += fprintf(fp, " --------------- -------- --------- --------- --------- ------\n");

/* each int_node is a syscall */
while (inode) {
Expand All @@ -2131,9 +2131,9 @@ static size_t thread__dump_stats(struct thread_trace *ttrace,

sc = &trace->syscalls.table[inode->i];
printed += fprintf(fp, " %-15s", sc->name);
printed += fprintf(fp, " %8" PRIu64 " %8.3f %8.3f",
printed += fprintf(fp, " %8" PRIu64 " %9.3f %9.3f",
n, min, avg);
printed += fprintf(fp, " %8.3f %6.2f\n", max, pct);
printed += fprintf(fp, " %9.3f %9.2f%%\n", max, pct);
}

inode = intlist__next(inode);
Expand Down
3 changes: 1 addition & 2 deletions tools/perf/tests/parse-events.c
Original file line number Diff line number Diff line change
Expand Up @@ -441,9 +441,8 @@ static int test__checkevent_pmu_name(struct perf_evlist *evlist)

static int test__checkevent_pmu_events(struct perf_evlist *evlist)
{
struct perf_evsel *evsel;
struct perf_evsel *evsel = perf_evlist__first(evlist);

evsel = list_entry(evlist->entries.next, struct perf_evsel, node);
TEST_ASSERT_VAL("wrong number of entries", 1 == evlist->nr_entries);
TEST_ASSERT_VAL("wrong type", PERF_TYPE_RAW == evsel->attr.type);
TEST_ASSERT_VAL("wrong exclude_user",
Expand Down
4 changes: 2 additions & 2 deletions tools/perf/ui/browser.c
Original file line number Diff line number Diff line change
Expand Up @@ -569,7 +569,7 @@ void ui_browser__argv_seek(struct ui_browser *browser, off_t offset, int whence)
browser->top = browser->top + browser->top_idx + offset;
break;
case SEEK_END:
browser->top = browser->top + browser->nr_entries + offset;
browser->top = browser->top + browser->nr_entries - 1 + offset;
break;
default:
return;
Expand Down Expand Up @@ -680,7 +680,7 @@ static void __ui_browser__line_arrow_down(struct ui_browser *browser,
if (end >= browser->top_idx + browser->height)
end_row = browser->height - 1;
else
end_row = end - browser->top_idx;;
end_row = end - browser->top_idx;

ui_browser__gotorc(browser, row, column);
SLsmg_draw_vline(end_row - row + 1);
Expand Down
11 changes: 5 additions & 6 deletions tools/perf/ui/browsers/hists.c
Original file line number Diff line number Diff line change
Expand Up @@ -1847,15 +1847,15 @@ static int perf_evsel_menu__run(struct perf_evsel_menu *menu,
switch (key) {
case K_TAB:
if (pos->node.next == &evlist->entries)
pos = list_entry(evlist->entries.next, struct perf_evsel, node);
pos = perf_evlist__first(evlist);
else
pos = list_entry(pos->node.next, struct perf_evsel, node);
pos = perf_evsel__next(pos);
goto browse_hists;
case K_UNTAB:
if (pos->node.prev == &evlist->entries)
pos = list_entry(evlist->entries.prev, struct perf_evsel, node);
pos = perf_evlist__last(evlist);
else
pos = list_entry(pos->node.prev, struct perf_evsel, node);
pos = perf_evsel__prev(pos);
goto browse_hists;
case K_ESC:
if (!ui_browser__dialog_yesno(&menu->b,
Expand Down Expand Up @@ -1943,8 +1943,7 @@ int perf_evlist__tui_browse_hists(struct perf_evlist *evlist, const char *help,

single_entry:
if (nr_entries == 1) {
struct perf_evsel *first = list_entry(evlist->entries.next,
struct perf_evsel, node);
struct perf_evsel *first = perf_evlist__first(evlist);
const char *ev_name = perf_evsel__name(first);

return perf_evsel__hists_browse(first, nr_entries, help,
Expand Down
6 changes: 4 additions & 2 deletions tools/perf/util/event.c
Original file line number Diff line number Diff line change
Expand Up @@ -209,8 +209,10 @@ static int perf_event__synthesize_mmap_events(struct perf_tool *tool,
&event->mmap.start, &event->mmap.len, prot,
&event->mmap.pgoff,
execname);

if (n != 5)
/*
* Anon maps don't have the execname.
*/
if (n < 4)
continue;
/*
* Just like the kernel, see __perf_event_mmap in kernel/perf_event.c
Expand Down
6 changes: 4 additions & 2 deletions tools/perf/util/evlist.c
Original file line number Diff line number Diff line change
Expand Up @@ -819,7 +819,9 @@ int perf_evlist__create_maps(struct perf_evlist *evlist, struct target *target)
if (evlist->threads == NULL)
return -1;

if (target__has_task(target))
if (target->force_per_cpu)
evlist->cpus = cpu_map__new(target->cpu_list);
else if (target__has_task(target))
evlist->cpus = cpu_map__dummy_new();
else if (!target__has_cpu(target) && !target->uses_mmap)
evlist->cpus = cpu_map__dummy_new();
Expand Down Expand Up @@ -1148,7 +1150,7 @@ size_t perf_evlist__fprintf(struct perf_evlist *evlist, FILE *fp)
perf_evsel__name(evsel));
}

return printed + fprintf(fp, "\n");;
return printed + fprintf(fp, "\n");
}

int perf_evlist__strerror_tp(struct perf_evlist *evlist __maybe_unused,
Expand Down
4 changes: 2 additions & 2 deletions tools/perf/util/evsel.c
Original file line number Diff line number Diff line change
Expand Up @@ -645,15 +645,15 @@ void perf_evsel__config(struct perf_evsel *evsel,
}
}

if (target__has_cpu(&opts->target))
if (target__has_cpu(&opts->target) || opts->target.force_per_cpu)
perf_evsel__set_sample_bit(evsel, CPU);

if (opts->period)
perf_evsel__set_sample_bit(evsel, PERIOD);

if (!perf_missing_features.sample_id_all &&
(opts->sample_time || !opts->no_inherit ||
target__has_cpu(&opts->target)))
target__has_cpu(&opts->target) || opts->target.force_per_cpu))
perf_evsel__set_sample_bit(evsel, TIME);

if (opts->raw_samples) {
Expand Down
5 changes: 5 additions & 0 deletions tools/perf/util/evsel.h
Original file line number Diff line number Diff line change
Expand Up @@ -279,6 +279,11 @@ static inline struct perf_evsel *perf_evsel__next(struct perf_evsel *evsel)
return list_entry(evsel->node.next, struct perf_evsel, node);
}

static inline struct perf_evsel *perf_evsel__prev(struct perf_evsel *evsel)
{
return list_entry(evsel->node.prev, struct perf_evsel, node);
}

/**
* perf_evsel__is_group_leader - Return whether given evsel is a leader event
*
Expand Down
2 changes: 1 addition & 1 deletion tools/perf/util/machine.c
Original file line number Diff line number Diff line change
Expand Up @@ -1368,7 +1368,7 @@ int machine__resolve_callchain(struct machine *machine,

return unwind__get_entries(unwind_entry, &callchain_cursor, machine,
thread, evsel->attr.sample_regs_user,
sample);
sample, max_stack);

}

Expand Down
1 change: 1 addition & 0 deletions tools/perf/util/target.h
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ struct target {
uid_t uid;
bool system_wide;
bool uses_mmap;
bool force_per_cpu;
};

enum target_errno {
Expand Down
9 changes: 5 additions & 4 deletions tools/perf/util/unwind.c
Original file line number Diff line number Diff line change
Expand Up @@ -559,7 +559,7 @@ static unw_accessors_t accessors = {
};

static int get_entries(struct unwind_info *ui, unwind_entry_cb_t cb,
void *arg)
void *arg, int max_stack)
{
unw_addr_space_t addr_space;
unw_cursor_t c;
Expand All @@ -575,7 +575,7 @@ static int get_entries(struct unwind_info *ui, unwind_entry_cb_t cb,
if (ret)
display_error(ret);

while (!ret && (unw_step(&c) > 0)) {
while (!ret && (unw_step(&c) > 0) && max_stack--) {
unw_word_t ip;

unw_get_reg(&c, UNW_REG_IP, &ip);
Expand All @@ -588,7 +588,8 @@ static int get_entries(struct unwind_info *ui, unwind_entry_cb_t cb,

int unwind__get_entries(unwind_entry_cb_t cb, void *arg,
struct machine *machine, struct thread *thread,
u64 sample_uregs, struct perf_sample *data)
u64 sample_uregs, struct perf_sample *data,
int max_stack)
{
unw_word_t ip;
struct unwind_info ui = {
Expand All @@ -610,5 +611,5 @@ int unwind__get_entries(unwind_entry_cb_t cb, void *arg,
if (ret)
return -ENOMEM;

return get_entries(&ui, cb, arg);
return get_entries(&ui, cb, arg, max_stack);
}
5 changes: 3 additions & 2 deletions tools/perf/util/unwind.h
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ int unwind__get_entries(unwind_entry_cb_t cb, void *arg,
struct machine *machine,
struct thread *thread,
u64 sample_uregs,
struct perf_sample *data);
struct perf_sample *data, int max_stack);
int unwind__arch_reg_id(int regnum);
#else
static inline int
Expand All @@ -27,7 +27,8 @@ unwind__get_entries(unwind_entry_cb_t cb __maybe_unused,
struct machine *machine __maybe_unused,
struct thread *thread __maybe_unused,
u64 sample_uregs __maybe_unused,
struct perf_sample *data __maybe_unused)
struct perf_sample *data __maybe_unused,
int max_stack __maybe_unused)
{
return 0;
}
Expand Down

0 comments on commit 89b4be1

Please sign in to comment.