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:

  * Add an option in 'perf script' to print the source line number, from Adrian Hunter

  * Add --header/--header-only options to 'script' and 'report', the default is not
    tho show the header info, but as this has been the default for some time,
    leave a single line explaining how to obtain that information, from Jiri Olsa.

  * Fix symoff printing in callchains in 'perf script', from Adrian Hunter.

  * Assorted mmap_pages handling fixes, from Adrian Hunter.

  * Fix summary percentage when processing files in 'perf trace', from David Ahern.

  * Handle old kernels where the "raw_syscalls" tracepoints were called plan "syscalls",
    in 'perf trace', from David Ahern.

  * Several man pages typo fixes from Dongsheng Yang.

  * Add '-v' option to 'perf kvm', from Dongsheng Yang.

  * Make perf kvm diff support --guestmount, from Dongsheng Yang.

  * Get rid of several die() calls in libtraceevent, from Namhyung Kim.

  * Use basename() in a more robust way, to avoid problems related to different
    system library implementations for that function, from Stephane Eranian.

  * Remove open coded management of short_name_allocated member, from Adrian Hunter

  * Several cleanups in the "dso" methods, constifying some parameters and
    renaming some fields to clarify its purpose. (Arnaldo Carvalho de Melo.)

  * Add per-feature check flags, fixing libunwind related build problems on some
    architectures, from Jean Pihet.

Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
Signed-off-by: Ingo Molnar <mingo@kernel.org>
  • Loading branch information
Ingo Molnar committed Dec 11, 2013
2 parents 7897907 + 1448fef commit 8139321
Show file tree
Hide file tree
Showing 35 changed files with 375 additions and 163 deletions.
28 changes: 18 additions & 10 deletions tools/lib/traceevent/event-parse.c
Original file line number Diff line number Diff line change
Expand Up @@ -2710,7 +2710,6 @@ process_func_handler(struct event_format *event, struct pevent_function_handler
struct print_arg *farg;
enum event_type type;
char *token;
const char *test;
int i;

arg->type = PRINT_FUNC;
Expand All @@ -2727,15 +2726,19 @@ process_func_handler(struct event_format *event, struct pevent_function_handler
}

type = process_arg(event, farg, &token);
if (i < (func->nr_args - 1))
test = ",";
else
test = ")";

if (test_type_token(type, token, EVENT_DELIM, test)) {
free_arg(farg);
free_token(token);
return EVENT_ERROR;
if (i < (func->nr_args - 1)) {
if (type != EVENT_DELIM || strcmp(token, ",") != 0) {
warning("Error: function '%s()' expects %d arguments but event %s only uses %d",
func->name, func->nr_args,
event->name, i + 1);
goto err;
}
} else {
if (type != EVENT_DELIM || strcmp(token, ")") != 0) {
warning("Error: function '%s()' only expects %d arguments but event %s has more",
func->name, func->nr_args, event->name);
goto err;
}
}

*next_arg = farg;
Expand All @@ -2747,6 +2750,11 @@ process_func_handler(struct event_format *event, struct pevent_function_handler
*tok = token;

return type;

err:
free_arg(farg);
free_token(token);
return EVENT_ERROR;
}

static enum event_type
Expand Down
2 changes: 1 addition & 1 deletion tools/lib/traceevent/event-parse.h
Original file line number Diff line number Diff line change
Expand Up @@ -860,7 +860,7 @@ int pevent_event_filtered(struct event_filter *filter,

void pevent_filter_reset(struct event_filter *filter);

void pevent_filter_clear_trivial(struct event_filter *filter,
int pevent_filter_clear_trivial(struct event_filter *filter,
enum filter_trivial_type type);

void pevent_filter_free(struct event_filter *filter);
Expand Down
57 changes: 44 additions & 13 deletions tools/lib/traceevent/parse-filter.c
Original file line number Diff line number Diff line change
Expand Up @@ -182,7 +182,10 @@ struct event_filter *pevent_filter_alloc(struct pevent *pevent)
{
struct event_filter *filter;

filter = malloc_or_die(sizeof(*filter));
filter = malloc(sizeof(*filter));
if (filter == NULL)
return NULL;

memset(filter, 0, sizeof(*filter));
filter->pevent = pevent;
pevent_ref(pevent);
Expand Down Expand Up @@ -242,15 +245,19 @@ static void free_arg(struct filter_arg *arg)
free(arg);
}

static void add_event(struct event_list **events,
static int add_event(struct event_list **events,
struct event_format *event)
{
struct event_list *list;

list = malloc_or_die(sizeof(*list));
list = malloc(sizeof(*list));
if (list == NULL)
return -1;

list->next = *events;
*events = list;
list->event = event;
return 0;
}

static int event_match(struct event_format *event,
Expand All @@ -273,6 +280,7 @@ find_event(struct pevent *pevent, struct event_list **events,
regex_t ereg;
regex_t sreg;
int match = 0;
int fail = 0;
char *reg;
int ret;
int i;
Expand Down Expand Up @@ -307,7 +315,10 @@ find_event(struct pevent *pevent, struct event_list **events,
event = pevent->events[i];
if (event_match(event, sys_name ? &sreg : NULL, &ereg)) {
match = 1;
add_event(events, event);
if (add_event(events, event) < 0) {
fail = 1;
break;
}
}
}

Expand All @@ -317,6 +328,8 @@ find_event(struct pevent *pevent, struct event_list **events,

if (!match)
return -1;
if (fail)
return -2;

return 0;
}
Expand Down Expand Up @@ -349,8 +362,11 @@ create_arg_item(struct event_format *event, const char *token,
arg->value.type =
type == EVENT_DQUOTE ? FILTER_STRING : FILTER_CHAR;
arg->value.str = strdup(token);
if (!arg->value.str)
die("malloc string");
if (!arg->value.str) {
free_arg(arg);
show_error(error_str, "failed to allocate string filter arg");
return NULL;
}
break;
case EVENT_ITEM:
/* if it is a number, then convert it */
Expand Down Expand Up @@ -1210,7 +1226,13 @@ int pevent_filter_add_filter_str(struct event_filter *filter,
else
len = strlen(filter_str);

this_event = malloc_or_die(len + 1);
this_event = malloc(len + 1);
if (this_event == NULL) {
show_error(error_str, "Memory allocation failure");
/* This can only happen when events is NULL, but still */
free_events(events);
return -1;
}
memcpy(this_event, filter_str, len);
this_event[len] = 0;

Expand Down Expand Up @@ -1482,8 +1504,10 @@ int pevent_update_trivial(struct event_filter *dest, struct event_filter *source
* @type: remove only true, false, or both
*
* Removes filters that only contain a TRUE or FALES boolean arg.
*
* Returns 0 on success and -1 if there was a problem.
*/
void pevent_filter_clear_trivial(struct event_filter *filter,
int pevent_filter_clear_trivial(struct event_filter *filter,
enum filter_trivial_type type)
{
struct filter_type *filter_type;
Expand All @@ -1492,13 +1516,15 @@ void pevent_filter_clear_trivial(struct event_filter *filter,
int i;

if (!filter->filters)
return;
return 0;

/*
* Two steps, first get all ids with trivial filters.
* then remove those ids.
*/
for (i = 0; i < filter->filters; i++) {
int *new_ids;

filter_type = &filter->event_filters[i];
if (filter_type->filter->type != FILTER_ARG_BOOLEAN)
continue;
Expand All @@ -1513,19 +1539,24 @@ void pevent_filter_clear_trivial(struct event_filter *filter,
break;
}

ids = realloc(ids, sizeof(*ids) * (count + 1));
if (!ids)
die("Can't allocate ids");
new_ids = realloc(ids, sizeof(*ids) * (count + 1));
if (!new_ids) {
free(ids);
return -1;
}

ids = new_ids;
ids[count++] = filter_type->event_id;
}

if (!count)
return;
return 0;

for (i = 0; i < count; i++)
pevent_filter_remove_event(filter, ids[i]);

free(ids);
return 0;
}

/**
Expand Down
6 changes: 3 additions & 3 deletions tools/perf/Documentation/perf-archive.txt
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,9 @@ SYNOPSIS

DESCRIPTION
-----------
This command runs runs perf-buildid-list --with-hits, and collects the files
with the buildids found so that analysis of perf.data contents can be possible
on another machine.
This command runs perf-buildid-list --with-hits, and collects the files with the
buildids found so that analysis of perf.data contents can be possible on another
machine.


SEE ALSO
Expand Down
7 changes: 5 additions & 2 deletions tools/perf/Documentation/perf-kvm.txt
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,9 @@ SYNOPSIS
[verse]
'perf kvm' [--host] [--guest] [--guestmount=<path>
[--guestkallsyms=<path> --guestmodules=<path> | --guestvmlinux=<path>]]
{top|record|report|diff|buildid-list}
{top|record|report|diff|buildid-list} [<options>]
'perf kvm' [--host] [--guest] [--guestkallsyms=<path> --guestmodules=<path>
| --guestvmlinux=<path>] {top|record|report|diff|buildid-list|stat}
| --guestvmlinux=<path>] {top|record|report|diff|buildid-list|stat} [<options>]
'perf kvm stat [record|report|live] [<options>]

DESCRIPTION
Expand Down Expand Up @@ -93,6 +93,9 @@ OPTIONS
kernel module information. Users copy it out from guest os.
--guestvmlinux=<path>::
Guest os kernel vmlinux.
-v::
--verbose::
Be more verbose (show counter open errors, etc).

STAT REPORT OPTIONS
-------------------
Expand Down
9 changes: 9 additions & 0 deletions tools/perf/Documentation/perf-report.txt
Original file line number Diff line number Diff line change
Expand Up @@ -237,6 +237,15 @@ OPTIONS
Do not show entries which have an overhead under that percent.
(Default: 0).

--header::
Show header information in the perf.data file. This includes
various information like hostname, OS and perf version, cpu/mem
info, perf command line, event list and so on. Currently only
--stdio output supports this feature.

--header-only::
Show only perf.data header (forces --stdio).

SEE ALSO
--------
linkperf:perf-stat[1], linkperf:perf-annotate[1]
8 changes: 7 additions & 1 deletion tools/perf/Documentation/perf-script.txt
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ OPTIONS
-f::
--fields::
Comma separated list of fields to print. Options are:
comm, tid, pid, time, cpu, event, trace, ip, sym, dso, addr, symoff.
comm, tid, pid, time, cpu, event, trace, ip, sym, dso, addr, symoff, srcline.
Field list can be prepended with the type, trace, sw or hw,
to indicate to which event type the field list applies.
e.g., -f sw:comm,tid,time,ip,sym and -f trace:time,cpu,trace
Expand Down Expand Up @@ -209,6 +209,12 @@ OPTIONS
--show-mmap-events
Display mmap related events (e.g. MMAP, MMAP2).

--header
Show perf.data header.

--header-only
Show only perf.data header.

SEE ALSO
--------
linkperf:perf-record[1], linkperf:perf-script-perl[1],
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 @@ -373,7 +373,7 @@ int cmd_annotate(int argc, const char **argv, const char *prefix __maybe_unused)

if (argc) {
/*
* Special case: if there's an argument left then assume tha
* Special case: if there's an argument left then assume that
* it's a symbol filter:
*/
if (argc > 1)
Expand Down
3 changes: 1 addition & 2 deletions tools/perf/builtin-diff.c
Original file line number Diff line number Diff line change
Expand Up @@ -1000,8 +1000,7 @@ static int data_init(int argc, const char **argv)
data__files_cnt = argc;
use_default = false;
}
} else if (symbol_conf.default_guest_vmlinux_name ||
symbol_conf.default_guest_kallsyms) {
} else if (perf_guest) {
defaults[0] = "perf.data.host";
defaults[1] = "perf.data.guest";
}
Expand Down
11 changes: 4 additions & 7 deletions tools/perf/builtin-kvm.c
Original file line number Diff line number Diff line change
Expand Up @@ -1232,7 +1232,7 @@ static int read_events(struct perf_kvm_stat *kvm)
.ordered_samples = true,
};
struct perf_data_file file = {
.path = input_name,
.path = kvm->file_name,
.mode = PERF_DATA_MODE_READ,
};

Expand Down Expand Up @@ -1690,6 +1690,8 @@ int cmd_kvm(int argc, const char **argv, const char *prefix __maybe_unused)
"file", "file saving guest os /proc/kallsyms"),
OPT_STRING(0, "guestmodules", &symbol_conf.default_guest_modules,
"file", "file saving guest os /proc/modules"),
OPT_INCR('v', "verbose", &verbose,
"be more verbose (show counter open errors, etc)"),
OPT_END()
};

Expand All @@ -1711,12 +1713,7 @@ int cmd_kvm(int argc, const char **argv, const char *prefix __maybe_unused)
perf_guest = 1;

if (!file_name) {
if (perf_host && !perf_guest)
file_name = strdup("perf.data.host");
else if (!perf_host && perf_guest)
file_name = strdup("perf.data.guest");
else
file_name = strdup("perf.data.kvm");
file_name = get_filename_for_perf_kvm();

if (!file_name) {
pr_err("Failed to allocate memory for filename\n");
Expand Down
2 changes: 1 addition & 1 deletion tools/perf/builtin-record.c
Original file line number Diff line number Diff line change
Expand Up @@ -224,7 +224,7 @@ static int perf_record__open(struct perf_record *rec)
"Consider increasing "
"/proc/sys/kernel/perf_event_mlock_kb,\n"
"or try again with a smaller value of -m/--mmap_pages.\n"
"(current value: %d)\n", opts->mmap_pages);
"(current value: %u)\n", opts->mmap_pages);
rc = -errno;
} else {
pr_err("failed to mmap with %d (%s)\n", errno, strerror(errno));
Expand Down
22 changes: 19 additions & 3 deletions tools/perf/builtin-report.c
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,8 @@ struct perf_report {
bool show_threads;
bool inverted_callchain;
bool mem_mode;
bool header;
bool header_only;
int max_stack;
struct perf_read_values show_threads_values;
const char *pretty_printing_style;
Expand Down Expand Up @@ -514,9 +516,6 @@ static int __cmd_report(struct perf_report *rep)
return ret;
}

if (use_browser <= 0)
perf_session__fprintf_info(session, stdout, rep->show_full_info);

if (rep->show_threads)
perf_read_values_init(&rep->show_threads_values);

Expand Down Expand Up @@ -820,6 +819,9 @@ int cmd_report(int argc, const char **argv, const char *prefix __maybe_unused)
OPT_BOOLEAN(0, "gtk", &report.use_gtk, "Use the GTK2 interface"),
OPT_BOOLEAN(0, "stdio", &report.use_stdio,
"Use the stdio interface"),
OPT_BOOLEAN(0, "header", &report.header, "Show data header."),
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,"
Expand Down Expand Up @@ -963,13 +965,27 @@ int cmd_report(int argc, const char **argv, const char *prefix __maybe_unused)
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 {
use_browser = 0;
perf_hpp__init();
}

if (report.header || report.header_only) {
perf_session__fprintf_info(session, stdout,
report.show_full_info);
if (report.header_only)
return 0;
} else if (use_browser == 0) {
fputs("# To display the perf.data header info, please use --header/--header-only options.\n#\n",
stdout);
}

/*
* Only in the TUI browser we are doing integrated annotation,
* so don't allocate extra space that won't be used in the stdio
Expand Down
Loading

0 comments on commit 8139321

Please sign in to comment.