1
0
Fork 0

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>
hifive-unleashed-5.1
Rasmus Villemoes 2018-10-29 23:35:42 +01:00 committed by Steven Rostedt (VMware)
parent cc9f59fb3b
commit bea6957d5c
1 changed files with 3 additions and 4 deletions

View File

@ -341,8 +341,8 @@ static inline const char *kretprobed(const char *name)
static void
seq_print_sym(struct trace_seq *s, unsigned long address, bool offset)
{
char str[KSYM_SYMBOL_LEN];
#ifdef CONFIG_KALLSYMS
char str[KSYM_SYMBOL_LEN];
const char *name;
if (offset)
@ -352,12 +352,11 @@ seq_print_sym(struct trace_seq *s, unsigned long address, bool offset)
name = kretprobed(str);
if (name && strlen(name)) {
trace_seq_printf(s, "%s", name);
trace_seq_puts(s, name);
return;
}
#endif
snprintf(str, KSYM_SYMBOL_LEN, "0x%08lx", address);
trace_seq_printf(s, "%s", str);
trace_seq_printf(s, "0x%08lx", address);
}
#ifndef CONFIG_64BIT