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

Commit 640c03ce authored by Arnaldo Carvalho de Melo's avatar Arnaldo Carvalho de Melo
Browse files

perf session: Parse sample earlier



At perf_session__process_event, so that we reduce the number of lines in eache
tool sample processing routine that now receives a sample_data pointer already
parsed.

This will also be useful in the next patch, where we'll allow sample the
identity fields in MMAP, FORK, EXIT, etc, when it will be possible to see (cpu,
timestamp) just after before every event.

Also validate callchains in perf_session__process_event, i.e. as early as
possible, and keep a counter of the number of events discarded due to invalid
callchains, warning the user about it if it happens.

There is an assumption that was kept that all events have the same sample_type,
that will be dealt with in the future, when this preexisting limitation will be
removed.

Tested-by: default avatarThomas Gleixner <tglx@linutronix.de>
Reviewed-by: default avatarThomas Gleixner <tglx@linutronix.de>
Acked-by: default avatarIan Munsie <imunsie@au1.ibm.com>
Acked-by: default avatarThomas Gleixner <tglx@linutronix.de>
Cc: Frédéric Weisbecker <fweisbec@gmail.com>
Cc: Ian Munsie <imunsie@au1.ibm.com>
Cc: Mike Galbraith <efault@gmx.de>
Cc: Peter Zijlstra <a.p.zijlstra@chello.nl>
Cc: Paul Mackerras <paulus@samba.org>
Cc: Stephane Eranian <eranian@google.com>
LKML-Reference: <1291318772-30880-4-git-send-email-acme@infradead.org>
Signed-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
parent c980d109
Loading
Loading
Loading
Loading
+3 −3
Original line number Diff line number Diff line
@@ -58,12 +58,12 @@ static int hists__add_entry(struct hists *self, struct addr_location *al)
	return hist_entry__inc_addr_samples(he, al->addr);
}

static int process_sample_event(event_t *event, struct perf_session *session)
static int process_sample_event(event_t *event, struct sample_data *sample,
				struct perf_session *session)
{
	struct addr_location al;
	struct sample_data data;

	if (event__preprocess_sample(event, session, &al, &data, NULL) < 0) {
	if (event__preprocess_sample(event, session, &al, sample, NULL) < 0) {
		pr_warning("problem processing %d event, skipping it.\n",
			   event->header.type);
		return -1;
+6 −5
Original line number Diff line number Diff line
@@ -30,12 +30,13 @@ static int hists__add_entry(struct hists *self,
	return -ENOMEM;
}

static int diff__process_sample_event(event_t *event, struct perf_session *session)
static int diff__process_sample_event(event_t *event,
				      struct sample_data *sample,
				      struct perf_session *session)
{
	struct addr_location al;
	struct sample_data data = { .period = 1, };

	if (event__preprocess_sample(event, session, &al, &data, NULL) < 0) {
	if (event__preprocess_sample(event, session, &al, sample, NULL) < 0) {
		pr_warning("problem processing %d event, skipping it.\n",
			   event->header.type);
		return -1;
@@ -44,12 +45,12 @@ static int diff__process_sample_event(event_t *event, struct perf_session *sessi
	if (al.filtered || al.sym == NULL)
		return 0;

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

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

+24 −15
Original line number Diff line number Diff line
@@ -16,7 +16,7 @@
static char		const *input_name = "-";
static bool		inject_build_ids;

static int event__repipe(event_t *event __used,
static int event__repipe_synth(event_t *event,
			       struct perf_session *session __used)
{
	uint32_t size;
@@ -36,22 +36,30 @@ static int event__repipe(event_t *event __used,
	return 0;
}

static int event__repipe_mmap(event_t *self, struct perf_session *session)
static int event__repipe(event_t *event, struct sample_data *sample __used,
			 struct perf_session *session)
{
	return event__repipe_synth(event, session);
}

static int event__repipe_mmap(event_t *self, struct sample_data *sample,
			      struct perf_session *session)
{
	int err;

	err = event__process_mmap(self, session);
	event__repipe(self, session);
	err = event__process_mmap(self, sample, session);
	event__repipe(self, sample, session);

	return err;
}

static int event__repipe_task(event_t *self, struct perf_session *session)
static int event__repipe_task(event_t *self, struct sample_data *sample,
			      struct perf_session *session)
{
	int err;

	err = event__process_task(self, session);
	event__repipe(self, session);
	err = event__process_task(self, sample, session);
	event__repipe(self, sample, session);

	return err;
}
@@ -61,7 +69,7 @@ static int event__repipe_tracing_data(event_t *self,
{
	int err;

	event__repipe(self, session);
	event__repipe_synth(self, session);
	err = event__process_tracing_data(self, session);

	return err;
@@ -111,7 +119,8 @@ static int dso__inject_build_id(struct dso *self, struct perf_session *session)
	return 0;
}

static int event__inject_buildid(event_t *event, struct perf_session *session)
static int event__inject_buildid(event_t *event, struct sample_data *sample,
				 struct perf_session *session)
{
	struct addr_location al;
	struct thread *thread;
@@ -146,7 +155,7 @@ static int event__inject_buildid(event_t *event, struct perf_session *session)
	}

repipe:
	event__repipe(event, session);
	event__repipe(event, sample, session);
	return 0;
}

@@ -160,10 +169,10 @@ struct perf_event_ops inject_ops = {
	.read		= event__repipe,
	.throttle	= event__repipe,
	.unthrottle	= event__repipe,
	.attr		= event__repipe,
	.event_type 	= event__repipe,
	.tracing_data 	= event__repipe,
	.build_id 	= event__repipe,
	.attr		= event__repipe_synth,
	.event_type 	= event__repipe_synth,
	.tracing_data 	= event__repipe_synth,
	.build_id 	= event__repipe_synth,
};

extern volatile int session_done;
+5 −16
Original line number Diff line number Diff line
@@ -304,22 +304,11 @@ process_raw_event(event_t *raw_event __used, void *data,
	}
}

static int process_sample_event(event_t *event, struct perf_session *session)
static int process_sample_event(event_t *event, struct sample_data *sample,
				struct perf_session *session)
{
	struct sample_data data;
	struct thread *thread;
	struct thread *thread = perf_session__findnew(session, event->ip.pid);

	memset(&data, 0, sizeof(data));
	data.time = -1;
	data.cpu = -1;
	data.period = 1;

	event__parse_sample(event, session->sample_type, &data);

	dump_printf("(IP, %d): %d/%d: %#Lx period: %Ld\n", event->header.misc,
		    data.pid, data.tid, data.ip, data.period);

	thread = perf_session__findnew(session, event->ip.pid);
	if (thread == NULL) {
		pr_debug("problem processing %d event, skipping it.\n",
			 event->header.type);
@@ -328,8 +317,8 @@ static int process_sample_event(event_t *event, struct perf_session *session)

	dump_printf(" ... thread: %s:%d\n", thread->comm, thread->pid);

	process_raw_event(event, data.raw_data, data.cpu,
			  data.time, thread);
	process_raw_event(event, sample->raw_data, sample->cpu,
			  sample->time, thread);

	return 0;
}
+4 −8
Original line number Diff line number Diff line
@@ -834,22 +834,18 @@ static void dump_info(void)
		die("Unknown type of information\n");
}

static int process_sample_event(event_t *self, struct perf_session *s)
static int process_sample_event(event_t *self, struct sample_data *sample,
				struct perf_session *s)
{
	struct sample_data data;
	struct thread *thread;
	struct thread *thread = perf_session__findnew(s, sample->tid);

	bzero(&data, sizeof(data));
	event__parse_sample(self, s->sample_type, &data);

	thread = perf_session__findnew(s, data.tid);
	if (thread == NULL) {
		pr_debug("problem processing %d event, skipping it.\n",
			self->header.type);
		return -1;
	}

	process_raw_event(data.raw_data, data.cpu, data.time, thread);
	process_raw_event(sample->raw_data, sample->cpu, sample->time, thread);

	return 0;
}
Loading