Re: [PATCH 3/3] tracing: Apply tracer specific options from kernel command line.

From: Steven Rostedt
Date: Mon Nov 02 2015 - 14:04:36 EST


On Sun, 18 Oct 2015 19:58:10 +0800
Jiaxing Wang <hello.wjx@xxxxxxxxx> wrote:


> +static int __init apply_trace_boot_options(void)
> +{
> + char *option;
> + char *buf;
> + char *str;
> + size_t len;
> +
> + if (trace_boot_options) {
> + len = strlen(trace_boot_options);
> +
> + buf = str = kmalloc(len + 1, GFP_KERNEL);
> + if (!buf)
> + return -ENOMEM;
> +
> + memcpy(buf, trace_boot_options, len + 1);
> +
> + while (str) {
> + option = strsep(&str, ",");
> + trace_set_options(&global_trace, option);
> + }
> +
> + kfree(buf);

Instead of allocating a buffer, do what I do in early_enable_events()
(see trace_events.c), where I put back the ',' after processing.

-- Steve

> + }
> +
> + return 0;
> +}
> +
> static ssize_t
> tracing_trace_options_write(struct file *filp, const char __user *ubuf,
> size_t cnt, loff_t *ppos)
> @@ -7153,12 +7185,7 @@ __init static int tracer_alloc_buffers(void)
> INIT_LIST_HEAD(&global_trace.events);
> list_add(&global_trace.list, &ftrace_trace_arrays);
>
> - while (trace_boot_options) {
> - char *option;
> -
> - option = strsep(&trace_boot_options, ",");
> - trace_set_options(&global_trace, option);
> - }
> + apply_trace_boot_options();
>
> register_snapshot_cmd();
>

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/