lkml.org 
[lkml]   [2008]   [Nov]   [16]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: [PATCH 2/4] tracing/ftrace: Change the type of the init() callback
On Sun, 16 Nov 2008 05:57:26 +0100
Frederic Weisbecker <fweisbec@gmail.com> wrote:

> Impact: Handle errors during initialization of a tracer
>
> 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: Frederic Weisbecker <fweisbec@gmail.com>
> Cc: Steven Rostedt <rostedt@goodmis.org>
> Cc: Pekka Paalanen <pq@iki.fi>
> Cc: Steven Noonan <steven@uplinklabs.net>
> ---
> kernel/trace/trace.c | 7 ++-
> kernel/trace/trace.h | 3 +-
> kernel/trace/trace_boot.c | 3 +-
> kernel/trace/trace_branch.c | 3 +-
> kernel/trace/trace_functions.c | 3 +-
> kernel/trace/trace_functions_return.c | 3 +-
> kernel/trace/trace_irqsoff.c | 9 +++-
> kernel/trace/trace_mmiotrace.c | 3 +-
> kernel/trace/trace_nop.c | 3 +-
> kernel/trace/trace_sched_switch.c | 3 +-
> kernel/trace/trace_sched_wakeup.c | 3 +-
> kernel/trace/trace_selftest.c | 66 ++++++++++++++++++++++++++++----
> kernel/trace/trace_sysprof.c | 3 +-
> 13 files changed, 88 insertions(+), 24 deletions(-)
>
> diff --git a/kernel/trace/trace.c b/kernel/trace/trace.c
> index 2d5672d..938ee31 100644
> --- a/kernel/trace/trace.c
> +++ b/kernel/trace/trace.c
> @@ -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:
> diff --git a/kernel/trace/trace.h b/kernel/trace/trace.h
> index 790ea8c..cdbd5cc 100644
> --- a/kernel/trace/trace.h
> +++ b/kernel/trace/trace.h
> @@ -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);

...

> diff --git a/kernel/trace/trace_mmiotrace.c b/kernel/trace/trace_mmiotrace.c
> index 51bcf37..433d650 100644
> --- a/kernel/trace/trace_mmiotrace.c
> +++ b/kernel/trace/trace_mmiotrace.c
> @@ -30,13 +30,14 @@ static void mmio_reset_data(struct trace_array *tr)
> tracing_reset(tr, cpu);
> }
>
> -static void mmio_trace_init(struct trace_array *tr)
> +static int mmio_trace_init(struct trace_array *tr)
> {
> pr_debug("in %s\n", __func__);
> mmio_trace_array = tr;
>
> mmio_reset_data(tr);
> enable_mmiotrace();
> + return 0;
> }
>
> static void mmio_trace_reset(struct trace_array *tr)

On a quick glance, I didn't see anything wrong in these parts.
I leave it for later to check if enable_mmiotrace() could fail
and if it should be propagated.

Thanks.

--
Pekka Paalanen
http://www.iki.fi/pq/


\
 
 \ /
  Last update: 2008-11-16 23:43    [W:0.027 / U:0.460 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site