[PATCH v1 06/12] trace: use TP_printk_no_nl in dyndbg:prdbg,devdbg

Łukasz Bartosik posted 12 patches 2 years, 1 month ago
There is a newer version of this series
[PATCH v1 06/12] trace: use TP_printk_no_nl in dyndbg:prdbg,devdbg
Posted by Łukasz Bartosik 2 years, 1 month ago
From: Jim Cromie <jim.cromie@gmail.com>

Recently added dyndbg events: prdbg, devdbg have code to strip the
trailing newline, if its there.  Drop that trimming (minimally), and
use the new TP_printk_no_nl macro instead.  Also converting to a
vstring is deferred for now.

This use is slightly premature/overkill, since some pr_debugs do not
have the expected trailing newline.  While those lacks are arguably
bugs, this doesn't fix them.

Signed-off-by: Jim Cromie <jim.cromie@gmail.com>
---
 include/trace/events/dyndbg.h | 24 ++----------------------
 1 file changed, 2 insertions(+), 22 deletions(-)

diff --git a/include/trace/events/dyndbg.h b/include/trace/events/dyndbg.h
index ccc5bcb070f9..91dcdbe059c0 100644
--- a/include/trace/events/dyndbg.h
+++ b/include/trace/events/dyndbg.h
@@ -20,20 +20,10 @@ TRACE_EVENT(prdbg,
 
 	    TP_fast_assign(
 			__entry->desc = desc;
-			/*
-			 * Each trace entry is printed in a new line.
-			 * If the msg finishes with '\n', cut it off
-			 * to avoid blank lines in the trace.
-			 */
-			if (len > 0 && (text[len - 1] == '\n'))
-				len -= 1;
-
 			memcpy(__get_str(msg), text, len);
-			__get_str(msg)[len] = 0;
 		    ),
 
-	    TP_printk("%s.%s %s", __entry->desc->modname,
-		      __entry->desc->function, __get_str(msg))
+	    TP_printk_no_nl("%s", __get_str(msg))
 );
 
 /* capture dev_dbg() callsite descriptor, device, and message */
@@ -52,20 +42,10 @@ TRACE_EVENT(devdbg,
 	    TP_fast_assign(
 			__entry->desc = desc;
 			__entry->dev = (struct device *) dev;
-			/*
-			 * Each trace entry is printed in a new line.
-			 * If the msg finishes with '\n', cut it off
-			 * to avoid blank lines in the trace.
-			 */
-			if (len > 0 && (text[len - 1] == '\n'))
-				len -= 1;
-
 			memcpy(__get_str(msg), text, len);
-			__get_str(msg)[len] = 0;
 		    ),
 
-	    TP_printk("%s.%s %s", __entry->desc->modname,
-		      __entry->desc->function, __get_str(msg))
+	    TP_printk_no_nl("%s", __get_str(msg))
 );
 
 #endif /* _TRACE_DYNDBG_H */
-- 
2.42.0.869.gea05f2083d-goog
Re: [PATCH v1 06/12] trace: use TP_printk_no_nl in dyndbg:prdbg,devdbg
Posted by Steven Rostedt 2 years, 1 month ago
On Fri,  3 Nov 2023 14:10:05 +0100
Łukasz Bartosik <lb@semihalf.com> wrote:

> index ccc5bcb070f9..91dcdbe059c0 100644
> --- a/include/trace/events/dyndbg.h
> +++ b/include/trace/events/dyndbg.h
> @@ -20,20 +20,10 @@ TRACE_EVENT(prdbg,
>  
>  	    TP_fast_assign(
>  			__entry->desc = desc;
> -			/*
> -			 * Each trace entry is printed in a new line.
> -			 * If the msg finishes with '\n', cut it off
> -			 * to avoid blank lines in the trace.
> -			 */
> -			if (len > 0 && (text[len - 1] == '\n'))
> -				len -= 1;
> -
>  			memcpy(__get_str(msg), text, len);
> -			__get_str(msg)[len] = 0;
>  		    ),
>  
> -	    TP_printk("%s.%s %s", __entry->desc->modname,
> -		      __entry->desc->function, __get_str(msg))
> +	    TP_printk_no_nl("%s", __get_str(msg))
>  );
>  

Instead of adding the TP_printk_no_nl() (Which I still do not like), we
could add a:

	__get_str_strip_nl(msg)

That will do the above loop. Which will move the processing to read side
(slow path).

And then we could update libtraceevent to handle that too.

-- Steve
Re: [PATCH v1 06/12] trace: use TP_printk_no_nl in dyndbg:prdbg,devdbg
Posted by Łukasz Bartosik 2 years, 1 month ago
wt., 7 lis 2023 o 01:45 Steven Rostedt <rostedt@goodmis.org> napisał(a):
>
> On Fri,  3 Nov 2023 14:10:05 +0100
> Łukasz Bartosik <lb@semihalf.com> wrote:
>
> > index ccc5bcb070f9..91dcdbe059c0 100644
> > --- a/include/trace/events/dyndbg.h
> > +++ b/include/trace/events/dyndbg.h
> > @@ -20,20 +20,10 @@ TRACE_EVENT(prdbg,
> >
> >           TP_fast_assign(
> >                       __entry->desc = desc;
> > -                     /*
> > -                      * Each trace entry is printed in a new line.
> > -                      * If the msg finishes with '\n', cut it off
> > -                      * to avoid blank lines in the trace.
> > -                      */
> > -                     if (len > 0 && (text[len - 1] == '\n'))
> > -                             len -= 1;
> > -
> >                       memcpy(__get_str(msg), text, len);
> > -                     __get_str(msg)[len] = 0;
> >                   ),
> >
> > -         TP_printk("%s.%s %s", __entry->desc->modname,
> > -                   __entry->desc->function, __get_str(msg))
> > +         TP_printk_no_nl("%s", __get_str(msg))
> >  );
> >
>
> Instead of adding the TP_printk_no_nl() (Which I still do not like), we
> could add a:
>
>         __get_str_strip_nl(msg)
>
> That will do the above loop. Which will move the processing to read side
> (slow path).
>
> And then we could update libtraceevent to handle that too.
>

Thanks Steve.

Jim, if you don't mind I will make the suggested changes ?

> -- Steve
Re: [PATCH v1 06/12] trace: use TP_printk_no_nl in dyndbg:prdbg,devdbg
Posted by jim.cromie@gmail.com 2 years, 1 month ago
On Fri, Nov 10, 2023 at 7:51 AM Łukasz Bartosik <lb@semihalf.com> wrote:
>
> wt., 7 lis 2023 o 01:45 Steven Rostedt <rostedt@goodmis.org> napisał(a):
> >
> > On Fri,  3 Nov 2023 14:10:05 +0100
> > Łukasz Bartosik <lb@semihalf.com> wrote:
> >
> > > index ccc5bcb070f9..91dcdbe059c0 100644
> > > --- a/include/trace/events/dyndbg.h
> > > +++ b/include/trace/events/dyndbg.h
> > > @@ -20,20 +20,10 @@ TRACE_EVENT(prdbg,
> > >
> > >           TP_fast_assign(
> > >                       __entry->desc = desc;
> > > -                     /*
> > > -                      * Each trace entry is printed in a new line.
> > > -                      * If the msg finishes with '\n', cut it off
> > > -                      * to avoid blank lines in the trace.
> > > -                      */
> > > -                     if (len > 0 && (text[len - 1] == '\n'))
> > > -                             len -= 1;
> > > -
> > >                       memcpy(__get_str(msg), text, len);
> > > -                     __get_str(msg)[len] = 0;
> > >                   ),
> > >
> > > -         TP_printk("%s.%s %s", __entry->desc->modname,
> > > -                   __entry->desc->function, __get_str(msg))
> > > +         TP_printk_no_nl("%s", __get_str(msg))
> > >  );
> > >
> >
> > Instead of adding the TP_printk_no_nl() (Which I still do not like), we
> > could add a:
> >
> >         __get_str_strip_nl(msg)
> >
> > That will do the above loop. Which will move the processing to read side
> > (slow path).
> >
> > And then we could update libtraceevent to handle that too.
> >
>
> Thanks Steve.
>
> Jim, if you don't mind I will make the suggested changes ?
>

if Steve likes it, Im happy.

> > -- Steve