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:

Infrastructure fixes and changes:

  * Fix off-by-one bugs in map->end handling (Stephane Eranian)

  * Fix off-by-one bug in maps__find(), also related to map->end handling (Namhyung Kim)

  * Make struct symbol->end be the first addr after the symbol range, to make it
    match the convention used for struct map->end. (Arnaldo Carvalho de Melo)

  * Fix perf_evlist__add_pollfd() error handling in 'perf kvm stat live' (Jiri Olsa)

  * Fix python test build by moving callchain_param to an object linked into the
    python binding (Jiri Olsa)

  * Do not include a struct hists per perf_evsel, untangling the histogram code
    from perf_evsel, to pave the way for exporting a minimalistic
    tools/lib/api/perf/ library usable by tools/perf and initially by the rasd
    daemon being developed by Borislav Petkov, Robert Richter and Jean Pihet.
    (Arnaldo Carvalho de Melo)

  * Make perf_evlist__open(evlist, NULL, NULL), i.e. without cpu and thread
    maps mean syswide monitoring, reducing the boilerplate for tools that
    only want system wide mode. (Arnaldo Carvalho de Melo)

Signed-off-by: Arnaldo Carvalho de Melo <[email protected]>
Signed-off-by: Ingo Molnar <[email protected]>
  • Loading branch information
Ingo Molnar committed Oct 15, 2014
2 parents 7765490 + 2c241bd commit ec4212d
Show file tree
Hide file tree
Showing 35 changed files with 392 additions and 229 deletions.
14 changes: 9 additions & 5 deletions tools/perf/builtin-annotate.c
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ static int perf_evsel__add_sample(struct perf_evsel *evsel,
struct addr_location *al,
struct perf_annotate *ann)
{
struct hists *hists = evsel__hists(evsel);
struct hist_entry *he;
int ret;

Expand All @@ -66,13 +67,12 @@ static int perf_evsel__add_sample(struct perf_evsel *evsel,
return 0;
}

he = __hists__add_entry(&evsel->hists, al, NULL, NULL, NULL, 1, 1, 0,
true);
he = __hists__add_entry(hists, al, NULL, NULL, NULL, 1, 1, 0, true);
if (he == NULL)
return -ENOMEM;

ret = hist_entry__inc_addr_samples(he, evsel->idx, al->addr);
hists__inc_nr_samples(&evsel->hists, true);
hists__inc_nr_samples(hists, true);
return ret;
}

Expand Down Expand Up @@ -214,6 +214,7 @@ static int __cmd_annotate(struct perf_annotate *ann)

if (dump_trace) {
perf_session__fprintf_nr_events(session, stdout);
perf_evlist__fprintf_nr_events(session->evlist, stdout);
goto out;
}

Expand All @@ -225,7 +226,7 @@ static int __cmd_annotate(struct perf_annotate *ann)

total_nr_samples = 0;
evlist__for_each(session->evlist, pos) {
struct hists *hists = &pos->hists;
struct hists *hists = evsel__hists(pos);
u32 nr_samples = hists->stats.nr_events[PERF_RECORD_SAMPLE];

if (nr_samples > 0) {
Expand Down Expand Up @@ -325,7 +326,10 @@ int cmd_annotate(int argc, const char **argv, const char *prefix __maybe_unused)
"Show event group information together"),
OPT_END()
};
int ret;
int ret = hists__init();

if (ret < 0)
return ret;

argc = parse_options(argc, argv, options, annotate_usage, 0);

Expand Down
21 changes: 12 additions & 9 deletions tools/perf/builtin-diff.c
Original file line number Diff line number Diff line change
Expand Up @@ -327,14 +327,15 @@ static int diff__process_sample_event(struct perf_tool *tool __maybe_unused,
struct machine *machine)
{
struct addr_location al;
struct hists *hists = evsel__hists(evsel);

if (perf_event__preprocess_sample(event, machine, &al, sample) < 0) {
pr_warning("problem processing %d event, skipping it.\n",
event->header.type);
return -1;
}

if (hists__add_entry(&evsel->hists, &al, sample->period,
if (hists__add_entry(hists, &al, sample->period,
sample->weight, sample->transaction)) {
pr_warning("problem incrementing symbol period, skipping event\n");
return -1;
Expand All @@ -346,9 +347,9 @@ static int diff__process_sample_event(struct perf_tool *tool __maybe_unused,
* hists__output_resort() and precompute needs the total
* period in order to sort entries by percentage delta.
*/
evsel->hists.stats.total_period += sample->period;
hists->stats.total_period += sample->period;
if (!al.filtered)
evsel->hists.stats.total_non_filtered_period += sample->period;
hists->stats.total_non_filtered_period += sample->period;

return 0;
}
Expand Down Expand Up @@ -382,7 +383,7 @@ static void perf_evlist__collapse_resort(struct perf_evlist *evlist)
struct perf_evsel *evsel;

evlist__for_each(evlist, evsel) {
struct hists *hists = &evsel->hists;
struct hists *hists = evsel__hists(evsel);

hists__collapse_resort(hists, NULL);
}
Expand Down Expand Up @@ -631,24 +632,26 @@ static void data_process(void)
bool first = true;

evlist__for_each(evlist_base, evsel_base) {
struct hists *hists_base = evsel__hists(evsel_base);
struct data__file *d;
int i;

data__for_each_file_new(i, d) {
struct perf_evlist *evlist = d->session->evlist;
struct perf_evsel *evsel;
struct hists *hists;

evsel = evsel_match(evsel_base, evlist);
if (!evsel)
continue;

d->hists = &evsel->hists;
hists = evsel__hists(evsel);
d->hists = hists;

hists__match(&evsel_base->hists, &evsel->hists);
hists__match(hists_base, hists);

if (!show_baseline_only)
hists__link(&evsel_base->hists,
&evsel->hists);
hists__link(hists_base, hists);
}

fprintf(stdout, "%s# Event '%s'\n#\n", first ? "" : "\n",
Expand All @@ -659,7 +662,7 @@ static void data_process(void)
if (verbose || data__files_cnt > 2)
data__fprintf();

hists__process(&evsel_base->hists);
hists__process(hists_base);
}
}

Expand Down
22 changes: 7 additions & 15 deletions tools/perf/builtin-kvm.c
Original file line number Diff line number Diff line change
Expand Up @@ -896,8 +896,7 @@ static int perf_kvm__handle_stdin(void)

static int kvm_events_live_report(struct perf_kvm_stat *kvm)
{
struct pollfd *pollfds = NULL;
int nr_fds, nr_stdin, ret, err = -EINVAL;
int nr_stdin, ret, err = -EINVAL;
struct termios save;

/* live flag must be set first */
Expand All @@ -919,34 +918,27 @@ static int kvm_events_live_report(struct perf_kvm_stat *kvm)
signal(SIGINT, sig_handler);
signal(SIGTERM, sig_handler);

/* use pollfds -- need to add timerfd and stdin */
nr_fds = kvm->evlist->pollfd.nr;

/* add timer fd */
if (perf_kvm__timerfd_create(kvm) < 0) {
err = -1;
goto out;
}

if (perf_evlist__add_pollfd(kvm->evlist, kvm->timerfd))
if (perf_evlist__add_pollfd(kvm->evlist, kvm->timerfd) < 0)
goto out;

nr_fds++;

if (perf_evlist__add_pollfd(kvm->evlist, fileno(stdin)))
nr_stdin = perf_evlist__add_pollfd(kvm->evlist, fileno(stdin));
if (nr_stdin < 0)
goto out;

nr_stdin = nr_fds;
nr_fds++;
if (fd_set_nonblock(fileno(stdin)) != 0)
goto out;

pollfds = kvm->evlist->pollfd.entries;

/* everything is good - enable the events and process */
perf_evlist__enable(kvm->evlist);

while (!done) {
struct fdarray *fda = &kvm->evlist->pollfd;
int rc;

rc = perf_kvm__mmap_read(kvm);
Expand All @@ -957,11 +949,11 @@ static int kvm_events_live_report(struct perf_kvm_stat *kvm)
if (err)
goto out;

if (pollfds[nr_stdin].revents & POLLIN)
if (fda->entries[nr_stdin].revents & POLLIN)
done = perf_kvm__handle_stdin();

if (!rc && !done)
err = poll(pollfds, nr_fds, 100);
err = fdarray__poll(fda, 100);
}

perf_evlist__disable(kvm->evlist);
Expand Down
1 change: 1 addition & 0 deletions tools/perf/builtin-record.c
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
#include "util/parse-options.h"
#include "util/parse-events.h"

#include "util/callchain.h"
#include "util/header.h"
#include "util/event.h"
#include "util/evlist.h"
Expand Down
24 changes: 15 additions & 9 deletions tools/perf/builtin-report.c
Original file line number Diff line number Diff line change
Expand Up @@ -288,12 +288,14 @@ static size_t hists__fprintf_nr_sample_events(struct hists *hists, struct report
evname = buf;

for_each_group_member(pos, evsel) {
const struct hists *pos_hists = evsel__hists(pos);

if (symbol_conf.filter_relative) {
nr_samples += pos->hists.stats.nr_non_filtered_samples;
nr_events += pos->hists.stats.total_non_filtered_period;
nr_samples += pos_hists->stats.nr_non_filtered_samples;
nr_events += pos_hists->stats.total_non_filtered_period;
} else {
nr_samples += pos->hists.stats.nr_events[PERF_RECORD_SAMPLE];
nr_events += pos->hists.stats.total_period;
nr_samples += pos_hists->stats.nr_events[PERF_RECORD_SAMPLE];
nr_events += pos_hists->stats.total_period;
}
}
}
Expand All @@ -318,7 +320,7 @@ static int perf_evlist__tty_browse_hists(struct perf_evlist *evlist,
struct perf_evsel *pos;

evlist__for_each(evlist, pos) {
struct hists *hists = &pos->hists;
struct hists *hists = evsel__hists(pos);
const char *evname = perf_evsel__name(pos);

if (symbol_conf.event_group &&
Expand Down Expand Up @@ -427,7 +429,7 @@ static void report__collapse_hists(struct report *rep)
ui_progress__init(&prog, rep->nr_entries, "Merging related events...");

evlist__for_each(rep->session->evlist, pos) {
struct hists *hists = &pos->hists;
struct hists *hists = evsel__hists(pos);

if (pos->idx == 0)
hists->symbol_filter_str = rep->symbol_filter_str;
Expand All @@ -437,7 +439,7 @@ static void report__collapse_hists(struct report *rep)
/* Non-group events are considered as leader */
if (symbol_conf.event_group &&
!perf_evsel__is_group_leader(pos)) {
struct hists *leader_hists = &pos->leader->hists;
struct hists *leader_hists = evsel__hists(pos->leader);

hists__match(leader_hists, hists);
hists__link(leader_hists, hists);
Expand Down Expand Up @@ -485,6 +487,7 @@ static int __cmd_report(struct report *rep)

if (dump_trace) {
perf_session__fprintf_nr_events(session, stdout);
perf_evlist__fprintf_nr_events(session->evlist, stdout);
return 0;
}
}
Expand All @@ -500,7 +503,7 @@ static int __cmd_report(struct report *rep)
}

evlist__for_each(session->evlist, pos)
hists__output_resort(&pos->hists);
hists__output_resort(evsel__hists(pos));

return report__browse_hists(rep);
}
Expand Down Expand Up @@ -565,7 +568,6 @@ int cmd_report(int argc, const char **argv, const char *prefix __maybe_unused)
struct stat st;
bool has_br_stack = false;
int branch_mode = -1;
int ret = -1;
char callchain_default_opt[] = "fractal,0.5,callee";
const char * const report_usage[] = {
"perf report [<options>]",
Expand Down Expand Up @@ -692,6 +694,10 @@ int cmd_report(int argc, const char **argv, const char *prefix __maybe_unused)
struct perf_data_file file = {
.mode = PERF_DATA_MODE_READ,
};
int ret = hists__init();

if (ret < 0)
return ret;

perf_config(report__config, &report);

Expand Down
3 changes: 0 additions & 3 deletions tools/perf/builtin-sched.c
Original file line number Diff line number Diff line change
Expand Up @@ -1431,9 +1431,6 @@ static int perf_sched__process_tracepoint_sample(struct perf_tool *tool __maybe_
{
int err = 0;

evsel->hists.stats.total_period += sample->period;
hists__inc_nr_samples(&evsel->hists, true);

if (evsel->handler != NULL) {
tracepoint_handler f = evsel->handler;
err = f(tool, evsel, sample, machine);
Expand Down
1 change: 0 additions & 1 deletion tools/perf/builtin-script.c
Original file line number Diff line number Diff line change
Expand Up @@ -572,7 +572,6 @@ static int process_sample_event(struct perf_tool *tool __maybe_unused,

scripting_ops->process_event(event, sample, evsel, thread, &al);

evsel->hists.stats.total_period += sample->period;
return 0;
}

Expand Down
Loading

0 comments on commit ec4212d

Please sign in to comment.