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 improvements from Arnaldo Carvalho de Melo:

 * Replace event_name with perf_evsel__name, that handles the event
   modifiers and doesn't use static variables.

 * GTK browser improvements, from Namhyung Kim

 * Fix possible NULL pointer deref in the TUI annotate browser, from
   Samuel Liao

 * Add sort by source file:line number, using addr2line.

 * Allow printing histogram text snapshots at any point in top/report.

Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
Signed-off-by: Ingo Molnar <mingo@kernel.org>
  • Loading branch information
Ingo Molnar committed Jun 20, 2012
2 parents 2992c54 + c0a58fb commit 32c46e5
Show file tree
Hide file tree
Showing 39 changed files with 1,118 additions and 514 deletions.
2 changes: 1 addition & 1 deletion tools/perf/Documentation/perf-report.txt
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ OPTIONS

-s::
--sort=::
Sort by key(s): pid, comm, dso, symbol, parent.
Sort by key(s): pid, comm, dso, symbol, parent, srcline.

-p::
--parent=<regex>::
Expand Down
2 changes: 1 addition & 1 deletion tools/perf/Documentation/perf-top.txt
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ Default is to monitor all CPUS.

-s::
--sort::
Sort by key(s): pid, comm, dso, symbol, parent
Sort by key(s): pid, comm, dso, symbol, parent, srcline.

-n::
--show-nr-samples::
Expand Down
6 changes: 6 additions & 0 deletions tools/perf/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -503,6 +503,7 @@ else
LIB_OBJS += $(OUTPUT)ui/progress.o
LIB_OBJS += $(OUTPUT)ui/util.o
LIB_OBJS += $(OUTPUT)ui/tui/setup.o
LIB_OBJS += $(OUTPUT)ui/tui/util.o
LIB_H += ui/browser.h
LIB_H += ui/browsers/map.h
LIB_H += ui/helpline.h
Expand All @@ -522,13 +523,18 @@ else
msg := $(warning GTK2 not found, disables GTK2 support. Please install gtk2-devel or libgtk2.0-dev);
BASIC_CFLAGS += -DNO_GTK2_SUPPORT
else
ifeq ($(call try-cc,$(SOURCE_GTK2_INFOBAR),$(FLAGS_GTK2)),y)
BASIC_CFLAGS += -DHAVE_GTK_INFO_BAR
endif
BASIC_CFLAGS += $(shell pkg-config --cflags gtk+-2.0)
EXTLIBS += $(shell pkg-config --libs gtk+-2.0)
LIB_OBJS += $(OUTPUT)ui/gtk/browser.o
LIB_OBJS += $(OUTPUT)ui/gtk/setup.o
LIB_OBJS += $(OUTPUT)ui/gtk/util.o
# Make sure that it'd be included only once.
ifneq ($(findstring -DNO_NEWT_SUPPORT,$(BASIC_CFLAGS)),)
LIB_OBJS += $(OUTPUT)ui/setup.o
LIB_OBJS += $(OUTPUT)ui/util.o
endif
endif
endif
Expand Down
2 changes: 1 addition & 1 deletion tools/perf/builtin-evlist.c
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ static int __cmd_evlist(const char *input_name, struct perf_attr_details *detail
list_for_each_entry(pos, &session->evlist->entries, node) {
bool first = true;

printf("%s", event_name(pos));
printf("%s", perf_evsel__name(pos));

if (details->verbose || details->freq) {
comma_printf(&first, " sample_freq=%" PRIu64,
Expand Down
4 changes: 2 additions & 2 deletions tools/perf/builtin-record.c
Original file line number Diff line number Diff line change
Expand Up @@ -265,7 +265,7 @@ static void perf_record__open(struct perf_record *rec)

if (err == ENOENT) {
ui__error("The %s event is not supported.\n",
event_name(pos));
perf_evsel__name(pos));
exit(EXIT_FAILURE);
}

Expand Down Expand Up @@ -916,7 +916,7 @@ int cmd_record(int argc, const char **argv, const char *prefix __used)
usage_with_options(record_usage, record_options);

list_for_each_entry(pos, &evsel_list->entries, node) {
if (perf_header__push_event(pos->attr.config, event_name(pos)))
if (perf_header__push_event(pos->attr.config, perf_evsel__name(pos)))
goto out_free_fd;
}

Expand Down
10 changes: 5 additions & 5 deletions tools/perf/builtin-report.c
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ static int perf_report__add_branch_hist_entry(struct perf_tool *tool,

if ((sort__has_parent || symbol_conf.use_callchain)
&& sample->callchain) {
err = machine__resolve_callchain(machine, evsel, al->thread,
err = machine__resolve_callchain(machine, al->thread,
sample->callchain, &parent);
if (err)
return err;
Expand Down Expand Up @@ -140,7 +140,7 @@ static int perf_evsel__add_hist_entry(struct perf_evsel *evsel,
struct hist_entry *he;

if ((sort__has_parent || symbol_conf.use_callchain) && sample->callchain) {
err = machine__resolve_callchain(machine, evsel, al->thread,
err = machine__resolve_callchain(machine, al->thread,
sample->callchain, &parent);
if (err)
return err;
Expand Down Expand Up @@ -230,7 +230,7 @@ static int process_read_event(struct perf_tool *tool,
struct perf_report *rep = container_of(tool, struct perf_report, tool);

if (rep->show_threads) {
const char *name = evsel ? event_name(evsel) : "unknown";
const char *name = evsel ? perf_evsel__name(evsel) : "unknown";
perf_read_values_add_value(&rep->show_threads_values,
event->read.pid, event->read.tid,
event->read.id,
Expand All @@ -239,7 +239,7 @@ static int process_read_event(struct perf_tool *tool,
}

dump_printf(": %d %d %s %" PRIu64 "\n", event->read.pid, event->read.tid,
evsel ? event_name(evsel) : "FAIL",
evsel ? perf_evsel__name(evsel) : "FAIL",
event->read.value);

return 0;
Expand Down Expand Up @@ -314,7 +314,7 @@ static int perf_evlist__tty_browse_hists(struct perf_evlist *evlist,

list_for_each_entry(pos, &evlist->entries, node) {
struct hists *hists = &pos->hists;
const char *evname = event_name(pos);
const char *evname = perf_evsel__name(pos);

hists__fprintf_nr_sample_events(hists, evname, stdout);
hists__fprintf(hists, NULL, false, true, 0, 0, stdout);
Expand Down
2 changes: 1 addition & 1 deletion tools/perf/builtin-sched.c
Original file line number Diff line number Diff line change
Expand Up @@ -1601,7 +1601,7 @@ static int perf_sched__process_tracepoint_sample(struct perf_tool *tool,

if (thread == NULL) {
pr_debug("problem processing %s event, skipping it.\n",
evsel->name);
perf_evsel__name(evsel));
return -1;
}

Expand Down
42 changes: 22 additions & 20 deletions tools/perf/builtin-script.c
Original file line number Diff line number Diff line change
Expand Up @@ -137,18 +137,19 @@ static const char *output_field2str(enum perf_output_field field)

#define PRINT_FIELD(x) (output[attr->type].fields & PERF_OUTPUT_##x)

static int perf_event_attr__check_stype(struct perf_event_attr *attr,
u64 sample_type, const char *sample_msg,
enum perf_output_field field)
static int perf_evsel__check_stype(struct perf_evsel *evsel,
u64 sample_type, const char *sample_msg,
enum perf_output_field field)
{
struct perf_event_attr *attr = &evsel->attr;
int type = attr->type;
const char *evname;

if (attr->sample_type & sample_type)
return 0;

if (output[type].user_set) {
evname = __event_name(attr->type, attr->config);
evname = perf_evsel__name(evsel);
pr_err("Samples for '%s' event do not have %s attribute set. "
"Cannot print '%s' field.\n",
evname, sample_msg, output_field2str(field));
Expand All @@ -157,7 +158,7 @@ static int perf_event_attr__check_stype(struct perf_event_attr *attr,

/* user did not ask for it explicitly so remove from the default list */
output[type].fields &= ~field;
evname = __event_name(attr->type, attr->config);
evname = perf_evsel__name(evsel);
pr_debug("Samples for '%s' event do not have %s attribute set. "
"Skipping '%s' field.\n",
evname, sample_msg, output_field2str(field));
Expand All @@ -175,8 +176,8 @@ static int perf_evsel__check_attr(struct perf_evsel *evsel,
return -EINVAL;

if (PRINT_FIELD(IP)) {
if (perf_event_attr__check_stype(attr, PERF_SAMPLE_IP, "IP",
PERF_OUTPUT_IP))
if (perf_evsel__check_stype(evsel, PERF_SAMPLE_IP, "IP",
PERF_OUTPUT_IP))
return -EINVAL;

if (!no_callchain &&
Expand All @@ -185,8 +186,8 @@ static int perf_evsel__check_attr(struct perf_evsel *evsel,
}

if (PRINT_FIELD(ADDR) &&
perf_event_attr__check_stype(attr, PERF_SAMPLE_ADDR, "ADDR",
PERF_OUTPUT_ADDR))
perf_evsel__check_stype(evsel, PERF_SAMPLE_ADDR, "ADDR",
PERF_OUTPUT_ADDR))
return -EINVAL;

if (PRINT_FIELD(SYM) && !PRINT_FIELD(IP) && !PRINT_FIELD(ADDR)) {
Expand All @@ -208,18 +209,18 @@ static int perf_evsel__check_attr(struct perf_evsel *evsel,
}

if ((PRINT_FIELD(PID) || PRINT_FIELD(TID)) &&
perf_event_attr__check_stype(attr, PERF_SAMPLE_TID, "TID",
PERF_OUTPUT_TID|PERF_OUTPUT_PID))
perf_evsel__check_stype(evsel, PERF_SAMPLE_TID, "TID",
PERF_OUTPUT_TID|PERF_OUTPUT_PID))
return -EINVAL;

if (PRINT_FIELD(TIME) &&
perf_event_attr__check_stype(attr, PERF_SAMPLE_TIME, "TIME",
PERF_OUTPUT_TIME))
perf_evsel__check_stype(evsel, PERF_SAMPLE_TIME, "TIME",
PERF_OUTPUT_TIME))
return -EINVAL;

if (PRINT_FIELD(CPU) &&
perf_event_attr__check_stype(attr, PERF_SAMPLE_CPU, "CPU",
PERF_OUTPUT_CPU))
perf_evsel__check_stype(evsel, PERF_SAMPLE_CPU, "CPU",
PERF_OUTPUT_CPU))
return -EINVAL;

return 0;
Expand Down Expand Up @@ -258,9 +259,10 @@ static int perf_session__check_output_opt(struct perf_session *session)

static void print_sample_start(struct perf_sample *sample,
struct thread *thread,
struct perf_event_attr *attr)
struct perf_evsel *evsel)
{
int type;
struct perf_event_attr *attr = &evsel->attr;
struct event_format *event;
const char *evname = NULL;
unsigned long secs;
Expand Down Expand Up @@ -305,7 +307,7 @@ static void print_sample_start(struct perf_sample *sample,
if (event)
evname = event->name;
} else
evname = __event_name(attr->type, attr->config);
evname = perf_evsel__name(evsel);

printf("%s: ", evname ? evname : "[unknown]");
}
Expand Down Expand Up @@ -387,7 +389,7 @@ static void print_sample_bts(union perf_event *event,
printf(" ");
else
printf("\n");
perf_event__print_ip(event, sample, machine, evsel,
perf_event__print_ip(event, sample, machine,
PRINT_FIELD(SYM), PRINT_FIELD(DSO),
PRINT_FIELD(SYMOFFSET));
}
Expand All @@ -412,7 +414,7 @@ static void process_event(union perf_event *event __unused,
if (output[attr->type].fields == 0)
return;

print_sample_start(sample, thread, attr);
print_sample_start(sample, thread, evsel);

if (is_bts_event(attr)) {
print_sample_bts(event, sample, evsel, machine, thread);
Expand All @@ -431,7 +433,7 @@ static void process_event(union perf_event *event __unused,
printf(" ");
else
printf("\n");
perf_event__print_ip(event, sample, machine, evsel,
perf_event__print_ip(event, sample, machine,
PRINT_FIELD(SYM), PRINT_FIELD(DSO),
PRINT_FIELD(SYMOFFSET));
}
Expand Down
12 changes: 6 additions & 6 deletions tools/perf/builtin-stat.c
Original file line number Diff line number Diff line change
Expand Up @@ -391,7 +391,7 @@ static int read_counter_aggr(struct perf_evsel *counter)

if (verbose) {
fprintf(output, "%s: %" PRIu64 " %" PRIu64 " %" PRIu64 "\n",
event_name(counter), count[0], count[1], count[2]);
perf_evsel__name(counter), count[0], count[1], count[2]);
}

/*
Expand Down Expand Up @@ -496,7 +496,7 @@ static int run_perf_stat(int argc __used, const char **argv)
errno == ENXIO) {
if (verbose)
ui__warning("%s event is not supported by the kernel.\n",
event_name(counter));
perf_evsel__name(counter));
counter->supported = false;
continue;
}
Expand Down Expand Up @@ -594,7 +594,7 @@ static void nsec_printout(int cpu, struct perf_evsel *evsel, double avg)
csv_output ? 0 : -4,
evsel_list->cpus->map[cpu], csv_sep);

fprintf(output, fmt, cpustr, msecs, csv_sep, event_name(evsel));
fprintf(output, fmt, cpustr, msecs, csv_sep, perf_evsel__name(evsel));

if (evsel->cgrp)
fprintf(output, "%s%s", csv_sep, evsel->cgrp->name);
Expand Down Expand Up @@ -792,7 +792,7 @@ static void abs_printout(int cpu, struct perf_evsel *evsel, double avg)
else
cpu = 0;

fprintf(output, fmt, cpustr, avg, csv_sep, event_name(evsel));
fprintf(output, fmt, cpustr, avg, csv_sep, perf_evsel__name(evsel));

if (evsel->cgrp)
fprintf(output, "%s%s", csv_sep, evsel->cgrp->name);
Expand Down Expand Up @@ -908,7 +908,7 @@ static void print_counter_aggr(struct perf_evsel *counter)
counter->supported ? CNTR_NOT_COUNTED : CNTR_NOT_SUPPORTED,
csv_sep,
csv_output ? 0 : -24,
event_name(counter));
perf_evsel__name(counter));

if (counter->cgrp)
fprintf(output, "%s%s", csv_sep, counter->cgrp->name);
Expand Down Expand Up @@ -961,7 +961,7 @@ static void print_counter(struct perf_evsel *counter)
counter->supported ? CNTR_NOT_COUNTED : CNTR_NOT_SUPPORTED,
csv_sep,
csv_output ? 0 : -24,
event_name(counter));
perf_evsel__name(counter));

if (counter->cgrp)
fprintf(output, "%s%s",
Expand Down
2 changes: 1 addition & 1 deletion tools/perf/builtin-test.c
Original file line number Diff line number Diff line change
Expand Up @@ -583,7 +583,7 @@ static int test__basic_mmap(void)
if (nr_events[evsel->idx] != expected_nr_events[evsel->idx]) {
pr_debug("expected %d %s events, got %d\n",
expected_nr_events[evsel->idx],
event_name(evsel), nr_events[evsel->idx]);
perf_evsel__name(evsel), nr_events[evsel->idx]);
goto out_munmap;
}
}
Expand Down
12 changes: 6 additions & 6 deletions tools/perf/builtin-top.c
Original file line number Diff line number Diff line change
Expand Up @@ -245,7 +245,7 @@ static void perf_top__show_details(struct perf_top *top)
if (notes->src == NULL)
goto out_unlock;

printf("Showing %s for %s\n", event_name(top->sym_evsel), symbol->name);
printf("Showing %s for %s\n", perf_evsel__name(top->sym_evsel), symbol->name);
printf(" Events Pcnt (>=%d%%)\n", top->sym_pcnt_filter);

more = symbol__annotate_printf(symbol, he->ms.map, top->sym_evsel->idx,
Expand Down Expand Up @@ -408,7 +408,7 @@ static void perf_top__print_mapped_keys(struct perf_top *top)
fprintf(stdout, "\t[e] display entries (lines). \t(%d)\n", top->print_entries);

if (top->evlist->nr_entries > 1)
fprintf(stdout, "\t[E] active event counter. \t(%s)\n", event_name(top->sym_evsel));
fprintf(stdout, "\t[E] active event counter. \t(%s)\n", perf_evsel__name(top->sym_evsel));

fprintf(stdout, "\t[f] profile display filter (count). \t(%d)\n", top->count_filter);

Expand Down Expand Up @@ -503,13 +503,13 @@ static void perf_top__handle_keypress(struct perf_top *top, int c)
fprintf(stderr, "\nAvailable events:");

list_for_each_entry(top->sym_evsel, &top->evlist->entries, node)
fprintf(stderr, "\n\t%d %s", top->sym_evsel->idx, event_name(top->sym_evsel));
fprintf(stderr, "\n\t%d %s", top->sym_evsel->idx, perf_evsel__name(top->sym_evsel));

prompt_integer(&counter, "Enter details event counter");

if (counter >= top->evlist->nr_entries) {
top->sym_evsel = list_entry(top->evlist->entries.next, struct perf_evsel, node);
fprintf(stderr, "Sorry, no such event, using %s.\n", event_name(top->sym_evsel));
fprintf(stderr, "Sorry, no such event, using %s.\n", perf_evsel__name(top->sym_evsel));
sleep(1);
break;
}
Expand Down Expand Up @@ -774,7 +774,7 @@ static void perf_event__process_sample(struct perf_tool *tool,

if ((sort__has_parent || symbol_conf.use_callchain) &&
sample->callchain) {
err = machine__resolve_callchain(machine, evsel, al.thread,
err = machine__resolve_callchain(machine, al.thread,
sample->callchain, &parent);
if (err)
return;
Expand Down Expand Up @@ -960,7 +960,7 @@ static void perf_top__start_counters(struct perf_top *top)

if (err == ENOENT) {
ui__error("The %s event is not supported.\n",
event_name(counter));
perf_evsel__name(counter));
goto out_err;
} else if (err == EMFILE) {
ui__error("Too many events are opened.\n"
Expand Down
13 changes: 13 additions & 0 deletions tools/perf/config/feature-tests.mak
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,19 @@ int main(int argc, char *argv[])
return 0;
}
endef

define SOURCE_GTK2_INFOBAR
#pragma GCC diagnostic ignored \"-Wstrict-prototypes\"
#include <gtk/gtk.h>
#pragma GCC diagnostic error \"-Wstrict-prototypes\"

int main(void)
{
gtk_info_bar_new();

return 0;
}
endef
endif

ifndef NO_LIBPERL
Expand Down
Loading

0 comments on commit 32c46e5

Please sign in to comment.