All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] tracing: fix incorrect enabling of trace events by boot cmdline
@ 2015-04-16  4:44 Joonsoo Kim
  2015-04-16 13:39 ` Steven Rostedt
  0 siblings, 1 reply; 3+ messages in thread
From: Joonsoo Kim @ 2015-04-16  4:44 UTC (permalink / raw)
  To: Steven Rostedt; +Cc: Ingo Molnar, linux-kernel, Joonsoo Kim

There is a problem that trace events are not properly enabled with
boot cmdline. Problem is that if we pass "trace_event=kmem:mm_page_alloc"
to boot cmdline, it enables all kmem trace events.

It is caused by parsing mechanism. When we parse cmdline, buffer
contents is modified due to tokenization. And, if we use this buffer
again, we will get wrong result.

Unfortunately, this buffer should be accessed three times
to set trace events properly in boot time. So, we need to handle
this situation.

There is already handling code for ",", but, we need another for
":". This patch add it.

Signed-off-by: Joonsoo Kim <iamjoonsoo.kim@lge.com>
---
 kernel/trace/trace_events.c | 7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)

diff --git a/kernel/trace/trace_events.c b/kernel/trace/trace_events.c
index db54dda..ce5b194 100644
--- a/kernel/trace/trace_events.c
+++ b/kernel/trace/trace_events.c
@@ -565,6 +565,7 @@ static int __ftrace_set_clr_event(struct trace_array *tr, const char *match,
 static int ftrace_set_clr_event(struct trace_array *tr, char *buf, int set)
 {
 	char *event = NULL, *sub = NULL, *match;
+	int ret;
 
 	/*
 	 * The buf format can be <subsystem>:<event-name>
@@ -590,7 +591,11 @@ static int ftrace_set_clr_event(struct trace_array *tr, char *buf, int set)
 			event = NULL;
 	}
 
-	return __ftrace_set_clr_event(tr, match, sub, event, set);
+	ret = __ftrace_set_clr_event(tr, match, sub, event, set);
+
+	/* Put back the colon to allow this to be called again */
+	if (buf)
+		*(buf - 1) = ':';
 }
 
 /**
-- 
1.9.1


^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH] tracing: fix incorrect enabling of trace events by boot cmdline
  2015-04-16  4:44 [PATCH] tracing: fix incorrect enabling of trace events by boot cmdline Joonsoo Kim
@ 2015-04-16 13:39 ` Steven Rostedt
  2015-04-17  5:10   ` Joonsoo Kim
  0 siblings, 1 reply; 3+ messages in thread
From: Steven Rostedt @ 2015-04-16 13:39 UTC (permalink / raw)
  To: Joonsoo Kim; +Cc: Ingo Molnar, linux-kernel

On Thu, 16 Apr 2015 13:44:44 +0900
Joonsoo Kim <iamjoonsoo.kim@lge.com> wrote:

> There is a problem that trace events are not properly enabled with
> boot cmdline. Problem is that if we pass "trace_event=kmem:mm_page_alloc"
> to boot cmdline, it enables all kmem trace events.
> 
> It is caused by parsing mechanism. When we parse cmdline, buffer
> contents is modified due to tokenization. And, if we use this buffer
> again, we will get wrong result.
> 
> Unfortunately, this buffer should be accessed three times
> to set trace events properly in boot time. So, we need to handle
> this situation.
> 
> There is already handling code for ",", but, we need another for
> ":". This patch add it.

Thanks, but your patch has a bug in it. I'll fix it up.

> 
> Signed-off-by: Joonsoo Kim <iamjoonsoo.kim@lge.com>
> ---
>  kernel/trace/trace_events.c | 7 ++++++-
>  1 file changed, 6 insertions(+), 1 deletion(-)
> 
> diff --git a/kernel/trace/trace_events.c b/kernel/trace/trace_events.c
> index db54dda..ce5b194 100644
> --- a/kernel/trace/trace_events.c
> +++ b/kernel/trace/trace_events.c
> @@ -565,6 +565,7 @@ static int __ftrace_set_clr_event(struct trace_array *tr, const char *match,
>  static int ftrace_set_clr_event(struct trace_array *tr, char *buf, int set)
>  {
>  	char *event = NULL, *sub = NULL, *match;
> +	int ret;
>  
>  	/*
>  	 * The buf format can be <subsystem>:<event-name>
> @@ -590,7 +591,11 @@ static int ftrace_set_clr_event(struct trace_array *tr, char *buf, int set)
>  			event = NULL;
>  	}
>  
> -	return __ftrace_set_clr_event(tr, match, sub, event, set);
> +	ret = __ftrace_set_clr_event(tr, match, sub, event, set);
> +
> +	/* Put back the colon to allow this to be called again */
> +	if (buf)
> +		*(buf - 1) = ':';

You forgot to add:

	return ret;

-- Steve

>  }
>  
>  /**


^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] tracing: fix incorrect enabling of trace events by boot cmdline
  2015-04-16 13:39 ` Steven Rostedt
@ 2015-04-17  5:10   ` Joonsoo Kim
  0 siblings, 0 replies; 3+ messages in thread
From: Joonsoo Kim @ 2015-04-17  5:10 UTC (permalink / raw)
  To: Steven Rostedt; +Cc: Ingo Molnar, linux-kernel

On Thu, Apr 16, 2015 at 09:39:52AM -0400, Steven Rostedt wrote:
> On Thu, 16 Apr 2015 13:44:44 +0900
> Joonsoo Kim <iamjoonsoo.kim@lge.com> wrote:
> 
> > There is a problem that trace events are not properly enabled with
> > boot cmdline. Problem is that if we pass "trace_event=kmem:mm_page_alloc"
> > to boot cmdline, it enables all kmem trace events.
> > 
> > It is caused by parsing mechanism. When we parse cmdline, buffer
> > contents is modified due to tokenization. And, if we use this buffer
> > again, we will get wrong result.
> > 
> > Unfortunately, this buffer should be accessed three times
> > to set trace events properly in boot time. So, we need to handle
> > this situation.
> > 
> > There is already handling code for ",", but, we need another for
> > ":". This patch add it.
> 
> Thanks, but your patch has a bug in it. I'll fix it up.
> 
> > 
> > Signed-off-by: Joonsoo Kim <iamjoonsoo.kim@lge.com>
> > ---
> >  kernel/trace/trace_events.c | 7 ++++++-
> >  1 file changed, 6 insertions(+), 1 deletion(-)
> > 
> > diff --git a/kernel/trace/trace_events.c b/kernel/trace/trace_events.c
> > index db54dda..ce5b194 100644
> > --- a/kernel/trace/trace_events.c
> > +++ b/kernel/trace/trace_events.c
> > @@ -565,6 +565,7 @@ static int __ftrace_set_clr_event(struct trace_array *tr, const char *match,
> >  static int ftrace_set_clr_event(struct trace_array *tr, char *buf, int set)
> >  {
> >  	char *event = NULL, *sub = NULL, *match;
> > +	int ret;
> >  
> >  	/*
> >  	 * The buf format can be <subsystem>:<event-name>
> > @@ -590,7 +591,11 @@ static int ftrace_set_clr_event(struct trace_array *tr, char *buf, int set)
> >  			event = NULL;
> >  	}
> >  
> > -	return __ftrace_set_clr_event(tr, match, sub, event, set);
> > +	ret = __ftrace_set_clr_event(tr, match, sub, event, set);
> > +
> > +	/* Put back the colon to allow this to be called again */
> > +	if (buf)
> > +		*(buf - 1) = ':';
> 
> You forgot to add:
> 
> 	return ret;
> 

Ah... my bad... :)
thanks for fixing it.

Thanks.

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2015-04-17  5:09 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-04-16  4:44 [PATCH] tracing: fix incorrect enabling of trace events by boot cmdline Joonsoo Kim
2015-04-16 13:39 ` Steven Rostedt
2015-04-17  5:10   ` Joonsoo Kim

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.