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

Commit 1c80025a authored by Frederic Weisbecker's avatar Frederic Weisbecker Committed by Ingo Molnar
Browse files

tracing/ftrace: change the type of the init() callback



Impact: extend the ->init() method with the ability to fail

This bring a way to know if the initialization of a tracer successed.
A tracer must return 0 on success and a traditional error (ie:
-ENOMEM) if it fails.

If a tracer fails to init, it is free to print a detailed warn. The
tracing api will not and switch to a new tracer will just return the
error from the init callback.

Note: this will be used for the return tracer.

Signed-off-by: default avatarFrederic Weisbecker <fweisbec@gmail.com>
Signed-off-by: default avatarIngo Molnar <mingo@elte.hu>
parent e6e7a65a
Loading
Loading
Loading
Loading
+5 −2
Original line number Diff line number Diff line
@@ -2638,8 +2638,11 @@ static int tracing_set_tracer(char *buf)
		current_trace->reset(tr);

	current_trace = t;
	if (t->init)
		t->init(tr);
	if (t->init) {
		ret = t->init(tr);
		if (ret)
			goto out;
	}

	trace_branch_enable(tr);
 out:
+2 −1
Original line number Diff line number Diff line
@@ -264,7 +264,8 @@ enum print_line_t {
 */
struct tracer {
	const char		*name;
	void			(*init)(struct trace_array *tr);
	/* Your tracer should raise a warning if init fails */
	int			(*init)(struct trace_array *tr);
	void			(*reset)(struct trace_array *tr);
	void			(*start)(struct trace_array *tr);
	void			(*stop)(struct trace_array *tr);
+2 −1
Original line number Diff line number Diff line
@@ -47,7 +47,7 @@ static void reset_boot_trace(struct trace_array *tr)
		tracing_reset(tr, cpu);
}

static void boot_trace_init(struct trace_array *tr)
static int boot_trace_init(struct trace_array *tr)
{
	int cpu;
	boot_trace = tr;
@@ -56,6 +56,7 @@ static void boot_trace_init(struct trace_array *tr)
		tracing_reset(tr, cpu);

	tracing_sched_switch_assign_trace(tr);
	return 0;
}

static enum print_line_t
+2 −1
Original line number Diff line number Diff line
@@ -125,7 +125,7 @@ static void stop_branch_trace(struct trace_array *tr)
	disable_branch_tracing();
}

static void branch_trace_init(struct trace_array *tr)
static int branch_trace_init(struct trace_array *tr)
{
	int cpu;

@@ -133,6 +133,7 @@ static void branch_trace_init(struct trace_array *tr)
		tracing_reset(tr, cpu);

	start_branch_trace(tr);
	return 0;
}

static void branch_trace_reset(struct trace_array *tr)
+2 −1
Original line number Diff line number Diff line
@@ -42,9 +42,10 @@ static void stop_function_trace(struct trace_array *tr)
	tracing_stop_cmdline_record();
}

static void function_trace_init(struct trace_array *tr)
static int function_trace_init(struct trace_array *tr)
{
	start_function_trace(tr);
	return 0;
}

static void function_trace_reset(struct trace_array *tr)
Loading