Skip to contentSkip to conversation

tracing: Be more clever when dumping hex in __print_hex()

PATCH Superseded Andy Shevchenko 1 participant 1 message Aug 6, 2019 Tracing

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore
#0 lore raw

PATCH 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.

---
 kernel/trace/trace_output.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)
kernel/trace/trace_output.c +3 -3
index cab4a5398f1d..ef52807473b7 100644
@@ -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 % 16, 16), &buf[i]);
 	trace_seq_putc(p, 0);
 
 	return ret;
Signature · 1 line
2.20.1