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

Commit d549c769 authored by Arnaldo Carvalho de Melo's avatar Arnaldo Carvalho de Melo Committed by Ingo Molnar
Browse files

perf session: Remove sample_type_check from event_ops



This is really something tools need to do before asking for the
events to be processed, leaving perf_session__process_events to
do just that, process events.

Also add a msg parameter to perf_session__has_traces() so that
the right message can be printed, fixing a regression added by
me in the previous cset (right timechart message) and also
fixing 'perf kmem', that was not asking if 'perf kmem record'
was ran.

Signed-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
Cc: Frédéric Weisbecker <fweisbec@gmail.com>
Cc: Mike Galbraith <efault@gmx.de>
Cc: Peter Zijlstra <a.p.zijlstra@chello.nl>
Cc: Paul Mackerras <paulus@samba.org>
LKML-Reference: <1261957026-15580-6-git-send-email-acme@infradead.org>
Signed-off-by: default avatarIngo Molnar <mingo@elte.hu>
parent 27295592
Loading
Loading
Loading
Loading
+4 −2
Original line number Diff line number Diff line
@@ -345,7 +345,6 @@ static int process_sample_event(event_t *event, struct perf_session *session)
static struct perf_event_ops event_ops = {
	.process_sample_event	= process_sample_event,
	.process_comm_event	= event__process_comm,
	.sample_type_check	= perf_session__has_traces,
};

static double fragmentation(unsigned long n_req, unsigned long n_alloc)
@@ -492,11 +491,14 @@ static void sort_result(void)

static int __cmd_kmem(void)
{
	int err;
	int err = -EINVAL;
	struct perf_session *session = perf_session__new(input_name, O_RDONLY, 0);
	if (session == NULL)
		return -ENOMEM;

	if (!perf_session__has_traces(session, "kmem record"))
		goto out_delete;

	setup_pager();
	err = perf_session__process_events(session, &event_ops);
	if (err != 0)
+9 −7
Original line number Diff line number Diff line
@@ -156,14 +156,14 @@ static int process_read_event(event_t *event, struct perf_session *session __use
	return 0;
}

static int sample_type_check(struct perf_session *session)
static int perf_session__setup_sample_type(struct perf_session *self)
{
	if (!(session->sample_type & PERF_SAMPLE_CALLCHAIN)) {
	if (!(self->sample_type & PERF_SAMPLE_CALLCHAIN)) {
		if (sort__has_parent) {
			fprintf(stderr, "selected --sort parent, but no"
					" callchain data. Did you call"
					" perf record without -g?\n");
			return -1;
			return -EINVAL;
		}
		if (symbol_conf.use_callchain) {
			fprintf(stderr, "selected -g but no callchain data."
@@ -176,7 +176,7 @@ static int sample_type_check(struct perf_session *session)
			if (register_callchain_param(&callchain_param) < 0) {
				fprintf(stderr, "Can't register callchain"
						" params\n");
				return -1;
				return -EINVAL;
			}
	}

@@ -191,13 +191,11 @@ static struct perf_event_ops event_ops = {
	.process_fork_event	= event__process_task,
	.process_lost_event	= event__process_lost,
	.process_read_event	= process_read_event,
	.sample_type_check	= sample_type_check,
};


static int __cmd_report(void)
{
	int ret;
	int ret = -EINVAL;
	struct perf_session *session;

	session = perf_session__new(input_name, O_RDONLY, force);
@@ -207,6 +205,10 @@ static int __cmd_report(void)
	if (show_threads)
		perf_read_values_init(&show_threads_values);

	ret = perf_session__setup_sample_type(session);
	if (ret)
		goto out_delete;

	ret = perf_session__process_events(session, &event_ops);
	if (ret)
		goto out_delete;
+4 −3
Original line number Diff line number Diff line
@@ -1657,17 +1657,18 @@ static struct perf_event_ops event_ops = {
	.process_sample_event	= process_sample_event,
	.process_comm_event	= event__process_comm,
	.process_lost_event	= process_lost_event,
	.sample_type_check	= perf_session__has_traces,
};

static int read_events(void)
{
	int err;
	int err = -EINVAL;
	struct perf_session *session = perf_session__new(input_name, O_RDONLY, 0);
	if (session == NULL)
		return -ENOMEM;

	if (perf_session__has_traces(session, "record -R"))
		err = perf_session__process_events(session, &event_ops);

	perf_session__delete(session);
	return err;
}
+4 −2
Original line number Diff line number Diff line
@@ -1034,17 +1034,19 @@ static struct perf_event_ops event_ops = {
	.process_fork_event	= process_fork_event,
	.process_exit_event	= process_exit_event,
	.process_sample_event	= queue_sample_event,
	.sample_type_check	= perf_session__has_traces,
};

static int __cmd_timechart(void)
{
	struct perf_session *session = perf_session__new(input_name, O_RDONLY, 0);
	int ret;
	int ret = -EINVAL;

	if (session == NULL)
		return -ENOMEM;

	if (!perf_session__has_traces(session, "timechart record"))
		goto out_delete;

	ret = perf_session__process_events(session, &event_ops);
	if (ret)
		goto out_delete;
+3 −1
Original line number Diff line number Diff line
@@ -106,7 +106,6 @@ static int process_sample_event(event_t *event, struct perf_session *session)
static struct perf_event_ops event_ops = {
	.process_sample_event	= process_sample_event,
	.process_comm_event	= event__process_comm,
	.sample_type_check	= perf_session__has_traces,
};

static int __cmd_trace(struct perf_session *session)
@@ -580,6 +579,9 @@ int cmd_trace(int argc, const char **argv, const char *prefix __used)
	if (session == NULL)
		return -ENOMEM;

	if (!perf_session__has_traces(session, "record -R"))
		return -EINVAL;

	if (generate_script_lang) {
		struct stat perf_stat;

Loading