Commit ec4212d8 authored by Ingo Molnar's avatar Ingo Molnar
Browse files

Merge tag 'perf-core-for-mingo' of...

Merge tag 'perf-core-for-mingo' of git://git.kernel.org/pub/scm/linux/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: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
Signed-off-by: default avatarIngo Molnar <mingo@kernel.org>
parents 77654908 2c241bd3
Loading
Loading
Loading
Loading
+9 −5
Original line number Diff line number Diff line
@@ -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;

@@ -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;
}

@@ -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;
	}

@@ -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) {
@@ -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);

+12 −9
Original line number Diff line number Diff line
@@ -327,6 +327,7 @@ 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",
@@ -334,7 +335,7 @@ static int diff__process_sample_event(struct perf_tool *tool __maybe_unused,
		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;
@@ -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;
}
@@ -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);
	}
@@ -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",
@@ -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);
	}
}

+7 −15
Original line number Diff line number Diff line
@@ -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 */
@@ -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);
@@ -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);
+1 −0
Original line number Diff line number Diff line
@@ -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"
+15 −9
Original line number Diff line number Diff line
@@ -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;
			}
		}
	}
@@ -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 &&
@@ -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;
@@ -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);
@@ -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;
		}
	}
@@ -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);
}
@@ -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>]",
@@ -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);

Loading