Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 743eb868 authored by Arnaldo Carvalho de Melo's avatar Arnaldo Carvalho de Melo
Browse files

perf tools: Resolve machine earlier and pass it to perf_event_ops

Reducing the exposure of perf_session further, so that we can use the
classes in cases where no perf.data file is created.

Cc: David Ahern <dsahern@gmail.com>
Cc: Frederic Weisbecker <fweisbec@gmail.com>
Cc: Mike Galbraith <efault@gmx.de>
Cc: Paul Mackerras <paulus@samba.org>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Stephane Eranian <eranian@google.com>
Link: http://lkml.kernel.org/n/tip-stua66dcscsezzrcdugvbmvd@git.kernel.org


Signed-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
parent d20deb64
Loading
Loading
Loading
Loading
+2 −2
Original line number Diff line number Diff line
@@ -83,12 +83,12 @@ static int process_sample_event(struct perf_event_ops *ops,
				union perf_event *event,
				struct perf_sample *sample,
				struct perf_evsel *evsel,
				struct perf_session *session)
				struct machine *machine)
{
	struct perf_annotate *ann = container_of(ops, struct perf_annotate, ops);
	struct addr_location al;

	if (perf_event__preprocess_sample(event, session, &al, sample,
	if (perf_event__preprocess_sample(event, machine, &al, sample,
					  symbol__annotate_init) < 0) {
		pr_warning("problem processing %d event, skipping it.\n",
			   event->header.type);
+5 −4
Original line number Diff line number Diff line
@@ -9,6 +9,7 @@
#include "util/debug.h"
#include "util/event.h"
#include "util/hist.h"
#include "util/evsel.h"
#include "util/session.h"
#include "util/sort.h"
#include "util/symbol.h"
@@ -34,11 +35,11 @@ static int diff__process_sample_event(struct perf_event_ops *ops __used,
				      union perf_event *event,
				      struct perf_sample *sample,
				      struct perf_evsel *evsel __used,
				      struct perf_session *session)
				      struct machine *machine)
{
	struct addr_location al;

	if (perf_event__preprocess_sample(event, session, &al, sample, NULL) < 0) {
	if (perf_event__preprocess_sample(event, machine, &al, sample, NULL) < 0) {
		pr_warning("problem processing %d event, skipping it.\n",
			   event->header.type);
		return -1;
@@ -47,12 +48,12 @@ static int diff__process_sample_event(struct perf_event_ops *ops __used,
	if (al.filtered || al.sym == NULL)
		return 0;

	if (hists__add_entry(&session->hists, &al, sample->period)) {
	if (hists__add_entry(&evsel->hists, &al, sample->period)) {
		pr_warning("problem incrementing symbol period, skipping event\n");
		return -1;
	}

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

+38 −32
Original line number Diff line number Diff line
@@ -18,7 +18,7 @@ static bool inject_build_ids;

static int perf_event__repipe_synth(struct perf_event_ops *ops __used,
				    union perf_event *event,
				    struct perf_session *session __used)
				    struct machine *machine __used)
{
	uint32_t size;
	void *buf = event;
@@ -37,10 +37,23 @@ static int perf_event__repipe_synth(struct perf_event_ops *ops __used,
	return 0;
}

static int perf_event__repipe_op2_synth(struct perf_event_ops *ops,
					union perf_event *event,
					struct perf_session *session __used)
{
	return perf_event__repipe_synth(ops, event, NULL);
}

static int perf_event__repipe_event_type_synth(struct perf_event_ops *ops,
					       union perf_event *event)
{
	return perf_event__repipe_synth(ops, event, NULL);
}

static int perf_event__repipe_tracing_data_synth(union perf_event *event,
						 struct perf_session *session)
						 struct perf_session *session __used)
{
	return perf_event__repipe_synth(NULL, event, session);
	return perf_event__repipe_synth(NULL, event, NULL);
}

static int perf_event__repipe_attr(union perf_event *event,
@@ -52,29 +65,29 @@ static int perf_event__repipe_attr(union perf_event *event,
static int perf_event__repipe(struct perf_event_ops *ops,
			      union perf_event *event,
			      struct perf_sample *sample __used,
			      struct perf_session *session)
			      struct machine *machine)
{
	return perf_event__repipe_synth(ops, event, session);
	return perf_event__repipe_synth(ops, event, machine);
}

static int perf_event__repipe_sample(struct perf_event_ops *ops,
				     union perf_event *event,
			      struct perf_sample *sample __used,
			      struct perf_evsel *evsel __used,
			      struct perf_session *session)
			      struct machine *machine)
{
	return perf_event__repipe_synth(ops, event, session);
	return perf_event__repipe_synth(ops, event, machine);
}

static int perf_event__repipe_mmap(struct perf_event_ops *ops,
				   union perf_event *event,
				   struct perf_sample *sample,
				   struct perf_session *session)
				   struct machine *machine)
{
	int err;

	err = perf_event__process_mmap(ops, event, sample, session);
	perf_event__repipe(ops, event, sample, session);
	err = perf_event__process_mmap(ops, event, sample, machine);
	perf_event__repipe(ops, event, sample, machine);

	return err;
}
@@ -82,12 +95,12 @@ static int perf_event__repipe_mmap(struct perf_event_ops *ops,
static int perf_event__repipe_task(struct perf_event_ops *ops,
				   union perf_event *event,
				   struct perf_sample *sample,
				   struct perf_session *session)
				   struct machine *machine)
{
	int err;

	err = perf_event__process_task(ops, event, sample, session);
	perf_event__repipe(ops, event, sample, session);
	err = perf_event__process_task(ops, event, sample, machine);
	perf_event__repipe(ops, event, sample, machine);

	return err;
}
@@ -97,7 +110,7 @@ static int perf_event__repipe_tracing_data(union perf_event *event,
{
	int err;

	perf_event__repipe_synth(NULL, event, session);
	perf_event__repipe_synth(NULL, event, NULL);
	err = perf_event__process_tracing_data(event, session);

	return err;
@@ -118,10 +131,9 @@ static int dso__read_build_id(struct dso *self)
}

static int dso__inject_build_id(struct dso *self, struct perf_event_ops *ops,
				struct perf_session *session)
				struct machine *machine)
{
	u16 misc = PERF_RECORD_MISC_USER;
	struct machine *machine;
	int err;

	if (dso__read_build_id(self) < 0) {
@@ -129,17 +141,11 @@ static int dso__inject_build_id(struct dso *self, struct perf_event_ops *ops,
		return -1;
	}

	machine = perf_session__find_host_machine(session);
	if (machine == NULL) {
		pr_err("Can't find machine for session\n");
		return -1;
	}

	if (self->kernel)
		misc = PERF_RECORD_MISC_KERNEL;

	err = perf_event__synthesize_build_id(ops, self, misc, perf_event__repipe,
					      machine, session);
					      machine);
	if (err) {
		pr_err("Can't synthesize build_id event for %s\n", self->long_name);
		return -1;
@@ -152,7 +158,7 @@ static int perf_event__inject_buildid(struct perf_event_ops *ops,
				      union perf_event *event,
				      struct perf_sample *sample,
				      struct perf_evsel *evsel __used,
				      struct perf_session *session)
				      struct machine *machine)
{
	struct addr_location al;
	struct thread *thread;
@@ -160,21 +166,21 @@ static int perf_event__inject_buildid(struct perf_event_ops *ops,

	cpumode = event->header.misc & PERF_RECORD_MISC_CPUMODE_MASK;

	thread = perf_session__findnew(session, event->ip.pid);
	thread = machine__findnew_thread(machine, event->ip.pid);
	if (thread == NULL) {
		pr_err("problem processing %d event, skipping it.\n",
		       event->header.type);
		goto repipe;
	}

	thread__find_addr_map(thread, session, cpumode, MAP__FUNCTION,
			      event->ip.pid, event->ip.ip, &al);
	thread__find_addr_map(thread, machine, cpumode, MAP__FUNCTION,
			      event->ip.ip, &al);

	if (al.map != NULL) {
		if (!al.map->dso->hit) {
			al.map->dso->hit = 1;
			if (map__load(al.map, NULL) >= 0) {
				dso__inject_build_id(al.map->dso, ops, session);
				dso__inject_build_id(al.map->dso, ops, machine);
				/*
				 * If this fails, too bad, let the other side
				 * account this as unresolved.
@@ -187,7 +193,7 @@ static int perf_event__inject_buildid(struct perf_event_ops *ops,
	}

repipe:
	perf_event__repipe(ops, event, sample, session);
	perf_event__repipe(ops, event, sample, machine);
	return 0;
}

@@ -198,13 +204,13 @@ struct perf_event_ops inject_ops = {
	.fork		= perf_event__repipe,
	.exit		= perf_event__repipe,
	.lost		= perf_event__repipe,
	.read		= perf_event__repipe,
	.read		= perf_event__repipe_sample,
	.throttle	= perf_event__repipe,
	.unthrottle	= perf_event__repipe,
	.attr		= perf_event__repipe_attr,
	.event_type	= perf_event__repipe_synth,
	.event_type	= perf_event__repipe_event_type_synth,
	.tracing_data	= perf_event__repipe_tracing_data_synth,
	.build_id	= perf_event__repipe_synth,
	.build_id	= perf_event__repipe_op2_synth,
};

extern volatile int session_done;
+2 −2
Original line number Diff line number Diff line
@@ -307,9 +307,9 @@ static int process_sample_event(struct perf_event_ops *ops __used,
				union perf_event *event,
				struct perf_sample *sample,
				struct perf_evsel *evsel __used,
				struct perf_session *session)
				struct machine *machine)
{
	struct thread *thread = perf_session__findnew(session, event->ip.pid);
	struct thread *thread = machine__findnew_thread(machine, event->ip.pid);

	if (thread == NULL) {
		pr_debug("problem processing %d event, skipping it.\n",
+2 −2
Original line number Diff line number Diff line
@@ -849,9 +849,9 @@ static int process_sample_event(struct perf_event_ops *ops __used,
				union perf_event *event,
				struct perf_sample *sample,
				struct perf_evsel *evsel __used,
				struct perf_session *s)
				struct machine *machine)
{
	struct thread *thread = perf_session__findnew(s, sample->tid);
	struct thread *thread = machine__findnew_thread(machine, sample->tid);

	if (thread == NULL) {
		pr_debug("problem processing %d event, skipping it.\n",
Loading