* [PATCH v2] tracing: Be more clever when dumping hex in __print_hex()
@ 2019-08-06 15:15 Andy Shevchenko
2019-08-06 15:33 ` Steven Rostedt
0 siblings, 1 reply; 4+ messages in thread
From: Andy Shevchenko @ 2019-08-06 15:15 UTC (permalink / raw)
To: Steven Rostedt, Ingo Molnar, linux-kernel, Rasmus Villemoes
Cc: Andy Shevchenko
Hex dump as many as 16 bytes at once in trace_print_hex_seq()
instead of byte-by-byte approach.
Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
---
v2: fix length calculation, so, when buf_len=16 it won't indefinitely loop
kernel/trace/trace_output.c | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/kernel/trace/trace_output.c b/kernel/trace/trace_output.c
index cab4a5398f1d..d54ce252b05a 100644
--- a/kernel/trace/trace_output.c
+++ b/kernel/trace/trace_output.c
@@ -219,10 +219,10 @@ trace_print_hex_seq(struct trace_seq *p, const unsigned char *buf, int buf_len,
{
int i;
const char *ret = trace_seq_buffer_ptr(p);
+ const char *fmt = concatenate ? "%*phN" : "%*ph";
- for (i = 0; i < buf_len; i++)
- trace_seq_printf(p, "%s%2.2x", concatenate || i == 0 ? "" : " ",
- buf[i]);
+ for (i = 0; i < buf_len; i += 16)
+ trace_seq_printf(p, fmt, min(buf_len - i, 16), &buf[i]);
trace_seq_putc(p, 0);
return ret;
--
2.20.1
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [PATCH v2] tracing: Be more clever when dumping hex in __print_hex()
2019-08-06 15:15 [PATCH v2] tracing: Be more clever when dumping hex in __print_hex() Andy Shevchenko
@ 2019-08-06 15:33 ` Steven Rostedt
2019-09-13 12:28 ` Andy Shevchenko
0 siblings, 1 reply; 4+ messages in thread
From: Steven Rostedt @ 2019-08-06 15:33 UTC (permalink / raw)
To: Andy Shevchenko; +Cc: Ingo Molnar, linux-kernel, Rasmus Villemoes
On Tue, 6 Aug 2019 18:15:43 +0300
Andy Shevchenko <andriy.shevchenko@linux.intel.com> wrote:
> Hex dump as many as 16 bytes at once in trace_print_hex_seq()
> instead of byte-by-byte approach.
>
> Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
> ---
> v2: fix length calculation, so, when buf_len=16 it won't indefinitely loop
> kernel/trace/trace_output.c | 6 +++---
> 1 file changed, 3 insertions(+), 3 deletions(-)
>
> diff --git a/kernel/trace/trace_output.c b/kernel/trace/trace_output.c
> index cab4a5398f1d..d54ce252b05a 100644
> --- a/kernel/trace/trace_output.c
> +++ b/kernel/trace/trace_output.c
> @@ -219,10 +219,10 @@ trace_print_hex_seq(struct trace_seq *p, const unsigned char *buf, int buf_len,
> {
> int i;
> const char *ret = trace_seq_buffer_ptr(p);
> + const char *fmt = concatenate ? "%*phN" : "%*ph";
>
> - for (i = 0; i < buf_len; i++)
> - trace_seq_printf(p, "%s%2.2x", concatenate || i == 0 ? "" : " ",
> - buf[i]);
> + for (i = 0; i < buf_len; i += 16)
> + trace_seq_printf(p, fmt, min(buf_len - i, 16), &buf[i]);
Cute.
I'll have to wrap my head around it a bit to make sure it's correct.
Thanks for sending this.
-- Steve
> trace_seq_putc(p, 0);
>
> return ret;
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH v2] tracing: Be more clever when dumping hex in __print_hex()
2019-08-06 15:33 ` Steven Rostedt
@ 2019-09-13 12:28 ` Andy Shevchenko
2019-09-14 23:50 ` Steven Rostedt
0 siblings, 1 reply; 4+ messages in thread
From: Andy Shevchenko @ 2019-09-13 12:28 UTC (permalink / raw)
To: Steven Rostedt; +Cc: Ingo Molnar, linux-kernel, Rasmus Villemoes
On Tue, Aug 06, 2019 at 11:33:52AM -0400, Steven Rostedt wrote:
> On Tue, 6 Aug 2019 18:15:43 +0300
> Andy Shevchenko <andriy.shevchenko@linux.intel.com> wrote:
>
> > Hex dump as many as 16 bytes at once in trace_print_hex_seq()
> > instead of byte-by-byte approach.
> > + const char *fmt = concatenate ? "%*phN" : "%*ph";
> >
> > + for (i = 0; i < buf_len; i += 16)
> > + trace_seq_printf(p, fmt, min(buf_len - i, 16), &buf[i]);
>
> Cute.
>
> I'll have to wrap my head around it a bit to make sure it's correct.
Anything I need to update here?
--
With Best Regards,
Andy Shevchenko
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH v2] tracing: Be more clever when dumping hex in __print_hex()
2019-09-13 12:28 ` Andy Shevchenko
@ 2019-09-14 23:50 ` Steven Rostedt
0 siblings, 0 replies; 4+ messages in thread
From: Steven Rostedt @ 2019-09-14 23:50 UTC (permalink / raw)
To: Andy Shevchenko; +Cc: Ingo Molnar, linux-kernel, Rasmus Villemoes
On Fri, 13 Sep 2019 15:28:26 +0300
Andy Shevchenko <andriy.shevchenko@linux.intel.com> wrote:
> On Tue, Aug 06, 2019 at 11:33:52AM -0400, Steven Rostedt wrote:
> > On Tue, 6 Aug 2019 18:15:43 +0300
> > Andy Shevchenko <andriy.shevchenko@linux.intel.com> wrote:
> >
> > > Hex dump as many as 16 bytes at once in trace_print_hex_seq()
> > > instead of byte-by-byte approach.
>
> > > + const char *fmt = concatenate ? "%*phN" : "%*ph";
> > >
> > > + for (i = 0; i < buf_len; i += 16)
> > > + trace_seq_printf(p, fmt, min(buf_len - i, 16), &buf[i]);
> >
> > Cute.
> >
> > I'll have to wrap my head around it a bit to make sure it's correct.
>
> Anything I need to update here?
>
Nope, thanks for the ping, I've been traveling quite crazy lately. I'll
try to add this to the next merge window coming up shortly.
-- Steve
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2019-09-14 23:50 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-08-06 15:15 [PATCH v2] tracing: Be more clever when dumping hex in __print_hex() Andy Shevchenko
2019-08-06 15:33 ` Steven Rostedt
2019-09-13 12:28 ` Andy Shevchenko
2019-09-14 23:50 ` Steven Rostedt
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).