All of lore.kernel.org
 help / color / mirror / Atom feed
From: Rasmus Villemoes <linux@rasmusvillemoes.dk>
To: Steven Rostedt <rostedt@goodmis.org>, Ingo Molnar <mingo@redhat.com>
Cc: Rasmus Villemoes <linux@rasmusvillemoes.dk>,
	linux-kernel@vger.kernel.org
Subject: [PATCH v2 3/3] tracing: simplify printf'ing in seq_print_sym
Date: Mon, 29 Oct 2018 23:35:42 +0100	[thread overview]
Message-ID: <20181029223542.26175-4-linux@rasmusvillemoes.dk> (raw)
In-Reply-To: <20181029223542.26175-1-linux@rasmusvillemoes.dk>

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

Signed-off-by: Rasmus Villemoes <linux@rasmusvillemoes.dk>
---
 kernel/trace/trace_output.c | 7 +++----
 1 file 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)
 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
-- 
2.19.1.6.gbde171bbf5


  parent reply	other threads:[~2018-10-29 22:35 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-10-26 21:13 [PATCH 1/3] tracing: merge seq_print_sym_short() and seq_print_sym_offset() Rasmus Villemoes
2018-10-26 21:13 ` [PATCH 2/3] tracing: avoid -Wformat-nonliteral warning Rasmus Villemoes
2018-10-26 21:13 ` [PATCH 3/3] tracing: simplify printf'ing in seq_print_sym Rasmus Villemoes
2018-10-26 21:41 ` [PATCH 1/3] tracing: merge seq_print_sym_short() and seq_print_sym_offset() Steven Rostedt
2018-10-29 22:35 ` [PATCH v2 0/3] tracing: a few simplifying patches Rasmus Villemoes
2018-10-29 22:35   ` [PATCH v2 1/3] tracing: merge seq_print_sym_short() and seq_print_sym_offset() Rasmus Villemoes
2018-10-29 22:35   ` [PATCH v2 2/3] tracing: avoid -Wformat-nonliteral warning Rasmus Villemoes
2018-10-29 22:35   ` Rasmus Villemoes [this message]
2018-10-31 11:45   ` [PATCH v2 0/3] tracing: a few simplifying patches Steven Rostedt

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20181029223542.26175-4-linux@rasmusvillemoes.dk \
    --to=linux@rasmusvillemoes.dk \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mingo@redhat.com \
    --cc=rostedt@goodmis.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.