mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH] tracing: make ftrace_print_array_seq compute buf_len
@ 2015-04-27 12:17 Alex Bennée
  2015-04-27 14:22 ` Dave P Martin
  0 siblings, 1 reply; 4+ messages in thread
From: Alex Bennée @ 2015-04-27 12:17 UTC (permalink / raw)
  To: rostedt, mingo
  Cc: linux-kernel, Alex Bennée, Oleg Nesterov,
	Peter Zijlstra (Intel),
	Dave Martin, Petr Mladek

The only caller to this function was getting it wrong. I favoured
pushing the calculation to as close to the need as possible rather than
fixing the one caller.

Signed-off-by: Alex Bennée <alex.bennee@linaro.org>
---
 include/linux/ftrace_event.h | 2 +-
 kernel/trace/trace_output.c  | 3 ++-
 2 files changed, 3 insertions(+), 2 deletions(-)

diff --git a/include/linux/ftrace_event.h b/include/linux/ftrace_event.h
index c674ee8..e6b0262 100644
--- a/include/linux/ftrace_event.h
+++ b/include/linux/ftrace_event.h
@@ -45,7 +45,7 @@ const char *ftrace_print_hex_seq(struct trace_seq *p,
 				 const unsigned char *buf, int len);
 
 const char *ftrace_print_array_seq(struct trace_seq *p,
-				   const void *buf, int buf_len,
+				   const void *buf, int len,
 				   size_t el_size);
 
 struct trace_iterator;
diff --git a/kernel/trace/trace_output.c b/kernel/trace/trace_output.c
index 692bf71..a42703d 100644
--- a/kernel/trace/trace_output.c
+++ b/kernel/trace/trace_output.c
@@ -178,12 +178,13 @@ ftrace_print_hex_seq(struct trace_seq *p, const unsigned char *buf, int buf_len)
 EXPORT_SYMBOL(ftrace_print_hex_seq);
 
 const char *
-ftrace_print_array_seq(struct trace_seq *p, const void *buf, int buf_len,
+ftrace_print_array_seq(struct trace_seq *p, const void *buf, int len,
 		       size_t el_size)
 {
 	const char *ret = trace_seq_buffer_ptr(p);
 	const char *prefix = "";
 	void *ptr = (void *)buf;
+	size_t buf_len = len * el_size;
 
 	trace_seq_putc(p, '{');
 
-- 
2.3.5


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

* Re: [PATCH] tracing: make ftrace_print_array_seq compute buf_len
  2015-04-27 12:17 [PATCH] tracing: make ftrace_print_array_seq compute buf_len Alex Bennée
@ 2015-04-27 14:22 ` Dave P Martin
  2015-04-27 18:00   ` Steven Rostedt
  0 siblings, 1 reply; 4+ messages in thread
From: Dave P Martin @ 2015-04-27 14:22 UTC (permalink / raw)
  To: Alex Bennée
  Cc: rostedt, mingo, linux-kernel, Oleg Nesterov,
	Peter Zijlstra (Intel),
	Petr Mladek

On Mon, Apr 27, 2015 at 01:17:48PM +0100, Alex Bennée wrote:
> The only caller to this function was getting it wrong. I favoured

What caller?

Wrong in what way?

> pushing the calculation to as close to the need as possible rather than
> fixing the one caller.

This seems reasonable, but...

> 
> Signed-off-by: Alex Bennée <alex.bennee@linaro.org>
> ---
>  include/linux/ftrace_event.h | 2 +-
>  kernel/trace/trace_output.c  | 3 ++-
>  2 files changed, 3 insertions(+), 2 deletions(-)
> 
> diff --git a/include/linux/ftrace_event.h b/include/linux/ftrace_event.h
> index c674ee8..e6b0262 100644
> --- a/include/linux/ftrace_event.h
> +++ b/include/linux/ftrace_event.h
> @@ -45,7 +45,7 @@ const char *ftrace_print_hex_seq(struct trace_seq *p,
>  				 const unsigned char *buf, int len);
>  
>  const char *ftrace_print_array_seq(struct trace_seq *p,
> -				   const void *buf, int buf_len,
> +				   const void *buf, int len,

How is the name "len" less confusing than "buf_len"?

I suggest matching the name to the equivalent argument of the
__print_array macro -- i.e., "count".

Cheers
---Dave

[...]


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

* Re: [PATCH] tracing: make ftrace_print_array_seq compute buf_len
  2015-04-27 14:22 ` Dave P Martin
@ 2015-04-27 18:00   ` Steven Rostedt
  2015-04-28 14:40     ` Alex Bennée
  0 siblings, 1 reply; 4+ messages in thread
From: Steven Rostedt @ 2015-04-27 18:00 UTC (permalink / raw)
  To: Dave P Martin
  Cc: Alex Bennée, mingo, linux-kernel, Oleg Nesterov,
	Peter Zijlstra (Intel),
	Petr Mladek

On Mon, 27 Apr 2015 15:22:02 +0100
Dave P Martin <Dave.Martin@arm.com> wrote:

> On Mon, Apr 27, 2015 at 01:17:48PM +0100, Alex Bennée wrote:
> > The only caller to this function was getting it wrong. I favoured
> 
> What caller?
> 
> Wrong in what way?

Yes, please add that info to the change log.

> 
> > pushing the calculation to as close to the need as possible rather than
> > fixing the one caller.
> 
> This seems reasonable, but...
> 
> > 
> > Signed-off-by: Alex Bennée <alex.bennee@linaro.org>
> > ---
> >  include/linux/ftrace_event.h | 2 +-
> >  kernel/trace/trace_output.c  | 3 ++-
> >  2 files changed, 3 insertions(+), 2 deletions(-)
> > 
> > diff --git a/include/linux/ftrace_event.h b/include/linux/ftrace_event.h
> > index c674ee8..e6b0262 100644
> > --- a/include/linux/ftrace_event.h
> > +++ b/include/linux/ftrace_event.h
> > @@ -45,7 +45,7 @@ const char *ftrace_print_hex_seq(struct trace_seq *p,
> >  				 const unsigned char *buf, int len);
> >  
> >  const char *ftrace_print_array_seq(struct trace_seq *p,
> > -				   const void *buf, int buf_len,
> > +				   const void *buf, int len,
> 
> How is the name "len" less confusing than "buf_len"?
> 
> I suggest matching the name to the equivalent argument of the
> __print_array macro -- i.e., "count".

I agree, please change the variable name to "count", that will make more
sense.

Thanks,

-- Steve


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

* Re: [PATCH] tracing: make ftrace_print_array_seq compute buf_len
  2015-04-27 18:00   ` Steven Rostedt
@ 2015-04-28 14:40     ` Alex Bennée
  0 siblings, 0 replies; 4+ messages in thread
From: Alex Bennée @ 2015-04-28 14:40 UTC (permalink / raw)
  To: Steven Rostedt
  Cc: Dave P Martin, mingo, linux-kernel, Oleg Nesterov,
	Peter Zijlstra (Intel),
	Petr Mladek


Steven Rostedt <rostedt@goodmis.org> writes:

> On Mon, 27 Apr 2015 15:22:02 +0100
> Dave P Martin <Dave.Martin@arm.com> wrote:
>
>> On Mon, Apr 27, 2015 at 01:17:48PM +0100, Alex Bennée wrote:
>> > The only caller to this function was getting it wrong. I favoured
>> 
>> What caller?
>> 
>> Wrong in what way?
>
> Yes, please add that info to the change log.

It was ftrace's own __print_array, I'll add the info to v2.

>
>> 
>> > pushing the calculation to as close to the need as possible rather than
>> > fixing the one caller.
>> 
>> This seems reasonable, but...
>> 
>> > 
>> > Signed-off-by: Alex Bennée <alex.bennee@linaro.org>
>> > ---
>> >  include/linux/ftrace_event.h | 2 +-
>> >  kernel/trace/trace_output.c  | 3 ++-
>> >  2 files changed, 3 insertions(+), 2 deletions(-)
>> > 
>> > diff --git a/include/linux/ftrace_event.h b/include/linux/ftrace_event.h
>> > index c674ee8..e6b0262 100644
>> > --- a/include/linux/ftrace_event.h
>> > +++ b/include/linux/ftrace_event.h
>> > @@ -45,7 +45,7 @@ const char *ftrace_print_hex_seq(struct trace_seq *p,
>> >  				 const unsigned char *buf, int len);
>> >  
>> >  const char *ftrace_print_array_seq(struct trace_seq *p,
>> > -				   const void *buf, int buf_len,
>> > +				   const void *buf, int len,
>> 
>> How is the name "len" less confusing than "buf_len"?
>> 
>> I suggest matching the name to the equivalent argument of the
>> __print_array macro -- i.e., "count".
>
> I agree, please change the variable name to "count", that will make more
> sense.

OK I'll re-spin today.

>
> Thanks,
>
> -- Steve

-- 
Alex Bennée

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

end of thread, other threads:[~2015-04-28 14:40 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-04-27 12:17 [PATCH] tracing: make ftrace_print_array_seq compute buf_len Alex Bennée
2015-04-27 14:22 ` Dave P Martin
2015-04-27 18:00   ` Steven Rostedt
2015-04-28 14:40     ` Alex Bennée

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®