Re: [PATCH v2] trace: param: fix tp_printk option related with tp_printk_stop_on_boot

From: Steven Rostedt
Date: Tue Feb 08 2022 - 14:41:18 EST


On Wed, 9 Feb 2022 01:30:33 +0900
JaeSang Yoo <js.yoo.5b@xxxxxxxxx> wrote:

> Kernel param "tp_printk_stop_on_boot" starts with "tp_printk" which is
> the exact as the other kernel param "tp_printk".
> In compile & build process, It may not guaranteed that
> "tp_printk_stop_on_boot" always checked before "tp_printk".
> (By swapping its __setup() macro order, it may not work as expected.)
> Some kernel params which starts with other kernel params consider this
> problem. See commit 745a600cf1a6 ("um: console: Ignore console= option")
> or init/do_mounts.c:45 (setup function of "ro" kernel param)
>
> Kernel param "tp_printk" can be handled with its value(0 or off) or
> it can be handled without its value. (maybe it won't effect anything)
> Fix setup function to ignore when the "tp_printk" becomes prefix of
> other kernel param.
>
> Signed-off-by: JaeSang Yoo <jsyoo5b@xxxxxxxxx>
> ---
> kernel/trace/trace.c | 2 ++
> 1 file changed, 2 insertions(+)
>
> diff --git a/kernel/trace/trace.c b/kernel/trace/trace.c
> index c860f582b078..5c8a28d74cf8 100644
> --- a/kernel/trace/trace.c
> +++ b/kernel/trace/trace.c
> @@ -252,6 +252,8 @@ __setup("trace_clock=", set_trace_boot_clock);
>
> static int __init set_tracepoint_printk(char *str)
> {
> + if (*str == '_')
> + return 0

Did you test this?

Need a space here (besides the obvious bug).

Also, it needs a comment above:

/* Ignore the tp_printk_stop_on_boot */
if (*str == '_')
return 0;

-- Steve

> if ((strcmp(str, "=0") != 0 && strcmp(str, "=off") != 0))
> tracepoint_printk = 1;
> return 1;