tracing: Be more clever when dumping hex in __print_hex()
PATCH v2 1/1 tracing: Be more clever when dumping hex in __print_hex()
Hex dump as many as 16 bytes at once in trace_print_hex_seq() instead of byte-by-byte approach.
---
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(-)
kernel/trace/trace_output.c +3 -3
@@ -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;
Signature · 1 line
2.20.1
Steven Rostedt
maintainerQuoted 14 lines · On Tue, 6 Aug 2019 18:15:43 +0300 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 <[email protected]>---
v2: fix length calculation, so, when buf_len=16 it won't indefinitely loopkernel/trace/trace_output.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)kernel/trace/trace_output.c +0
-0
kernel/trace/trace_output.c trace_print_hex_seq(struct trace_seq *p, const unsigned char *buf, int buf_len, · line 225
Quoted 10 lines
kernel/trace/trace_output.c +3
-3@@ -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
Quoted 3 lines
kernel/trace/trace_output.c +0
-0trace_seq_putc (p,0 );return ret;
Quoted 6 lines · Steven Rostedt
Quoted 2 lines · On Tue, 6 Aug 2019 18:15:43 +0300 Andy Shevchenko…
Hex dump as many as 16 bytes at once in
trace_print_hex_seq()instead of byte-by-byte approach.
Quoted 8 lines
kernel/trace/trace_output.c trace_print_hex_seq(struct trace_seq *p, const unsigned char *buf, int buf_len, · line 225
Quoted 4 lines
kernel/trace/trace_output.c +3
-0+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?
Signature · 2 lines
With Best Regards, Andy Shevchenko
Steven Rostedt
maintainerQuoted 9 lines · On Fri, 13 Sep 2019 15:28:26 +0300 Andy Shevchenko…
Quoted 8 lines · Steven Rostedt
Quoted 5 lines · On Tue, 6 Aug 2019 18:15:43 +0300 Andy Shevchenko…
Hex dump as many as 16 bytes at once in
trace_print_hex_seq()instead of byte-by-byte approach.kernel/trace/trace_output.c +1
-0+const char *fmt = concatenate ?"%*phN" :"%*ph" ;
Quoted 9 lines
Quoted 6 lines
kernel/trace/trace_output.c trace_print_hex_seq(struct trace_seq *p, const unsigned char *buf, int buf_len, · line 225
Quoted 2 lines
kernel/trace/trace_output.c +2
-0+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