diff options
author | Rasmus Villemoes <linux@rasmusvillemoes.dk> | 2018-10-29 18:35:42 -0400 |
---|---|---|
committer | Steven Rostedt (VMware) <rostedt@goodmis.org> | 2018-12-22 08:21:06 -0500 |
commit | bea6957d5cd7cbb327083d3bcf080133ee63ef65 (patch) | |
tree | 459cde1b613bb3f0263a74b405e70ba2361b78a5 /kernel/trace/trace_output.c | |
parent | cc9f59fb3bc455984404dbab8be16f156a47d023 (diff) |
tracing: Simplify printf'ing in seq_print_sym
trace_seq_printf(..., "%s", ...) can be done with trace_seq_puts()
instead, avoiding printf overhead. In the second instance, the string
we're copying was just created from an snprintf() to a stack buffer, so
we might as well do that printf directly. This naturally leads to moving
the declaration of the str buffer inside the CONFIG_KALLSYMS guard,
which in turn will make gcc inline the function for !CONFIG_KALLSYMS (it
only has a single caller, but the huge stack frame seems to make gcc not
inline it for CONFIG_KALLSYMS).
Link: http://lkml.kernel.org/r/20181029223542.26175-4-linux@rasmusvillemoes.dk
Signed-off-by: Rasmus Villemoes <linux@rasmusvillemoes.dk>
Signed-off-by: Steven Rostedt (VMware) <rostedt@goodmis.org>
Diffstat (limited to 'kernel/trace/trace_output.c')
-rw-r--r-- | kernel/trace/trace_output.c | 7 |
1 files changed, 3 insertions, 4 deletions
diff --git a/kernel/trace/trace_output.c b/kernel/trace/trace_output.c index f06fb899b746..54373d93e251 100644 --- a/kernel/trace/trace_output.c +++ b/kernel/trace/trace_output.c | |||
@@ -341,8 +341,8 @@ static inline const char *kretprobed(const char *name) | |||
341 | static void | 341 | static void |
342 | seq_print_sym(struct trace_seq *s, unsigned long address, bool offset) | 342 | seq_print_sym(struct trace_seq *s, unsigned long address, bool offset) |
343 | { | 343 | { |
344 | char str[KSYM_SYMBOL_LEN]; | ||
345 | #ifdef CONFIG_KALLSYMS | 344 | #ifdef CONFIG_KALLSYMS |
345 | char str[KSYM_SYMBOL_LEN]; | ||
346 | const char *name; | 346 | const char *name; |
347 | 347 | ||
348 | if (offset) | 348 | if (offset) |
@@ -352,12 +352,11 @@ seq_print_sym(struct trace_seq *s, unsigned long address, bool offset) | |||
352 | name = kretprobed(str); | 352 | name = kretprobed(str); |
353 | 353 | ||
354 | if (name && strlen(name)) { | 354 | if (name && strlen(name)) { |
355 | trace_seq_printf(s, "%s", name); | 355 | trace_seq_puts(s, name); |
356 | return; | 356 | return; |
357 | } | 357 | } |
358 | #endif | 358 | #endif |
359 | snprintf(str, KSYM_SYMBOL_LEN, "0x%08lx", address); | 359 | trace_seq_printf(s, "0x%08lx", address); |
360 | trace_seq_printf(s, "%s", str); | ||
361 | } | 360 | } |
362 | 361 | ||
363 | #ifndef CONFIG_64BIT | 362 | #ifndef CONFIG_64BIT |