public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Ingo Molnar <mingo@elte.hu>
To: linux-tip-commits@vger.kernel.org
Cc: linux-kernel@vger.kernel.org, hpa@zytor.com, mingo@redhat.com,
	peterz@infradead.org, fweisbec@gmail.com, rostedt@goodmis.org,
	tglx@linutronix.de, mingo@elte.hu
Subject: [tip:tracing/printk] tracing: optimize trace_printk()
Date: Mon, 9 Mar 2009 09:12:34 GMT	[thread overview]
Message-ID: <tip-7bffc23e56e92c14b787bf4d95249a32085bfed5@git.kernel.org> (raw)
In-Reply-To: <1236356510-8381-5-git-send-email-fweisbec@gmail.com>

Commit-ID:  7bffc23e56e92c14b787bf4d95249a32085bfed5
Gitweb:     http://git.kernel.org/tip/7bffc23e56e92c14b787bf4d95249a32085bfed5
Author:     "Ingo Molnar" <mingo@elte.hu>
AuthorDate: Mon, 9 Mar 2009 10:11:36 +0100
Commit:     Ingo Molnar <mingo@elte.hu>
CommitDate: Mon, 9 Mar 2009 10:11:36 +0100

tracing: optimize trace_printk()

Impact: micro-optimization

trace_printk() does this unconditionally:

	trace_printk_fmt = fmt;

Where trace_printk_fmt is an entry into a global array. This is
very SMP-unfriendly.

So only write it once per bootup.

Cc: Frederic Weisbecker <fweisbec@gmail.com>
Cc: Steven Rostedt <rostedt@goodmis.org>
Cc: Peter Zijlstra <peterz@infradead.org>
LKML-Reference: <1236356510-8381-5-git-send-email-fweisbec@gmail.com>
Signed-off-by: Ingo Molnar <mingo@elte.hu>


---
 include/linux/kernel.h |   10 ++++++++--
 1 files changed, 8 insertions(+), 2 deletions(-)

diff --git a/include/linux/kernel.h b/include/linux/kernel.h
index 4e726b9..7742798 100644
--- a/include/linux/kernel.h
+++ b/include/linux/kernel.h
@@ -454,7 +454,10 @@ do {									\
 do {									\
 	static const char *trace_printk_fmt				\
 	__attribute__((section("__trace_printk_fmt")));			\
-	trace_printk_fmt = fmt;					\
+									\
+	if (!trace_printk_fmt)						\
+		trace_printk_fmt = fmt;					\
+									\
 	__trace_printk_check_format(fmt, ##args);			\
 	__trace_printk(_THIS_IP_, trace_printk_fmt, ##args);		\
 } while (0)
@@ -467,7 +470,10 @@ __trace_printk(unsigned long ip, const char *fmt, ...)
 do {									\
 	static const char *trace_printk_fmt				\
 	__attribute__((section("__trace_printk_fmt")));			\
-	trace_printk_fmt = fmt;					\
+									\
+	if (!trace_printk_fmt)						\
+		trace_printk_fmt = fmt;					\
+									\
 	__ftrace_vprintk(_THIS_IP_, trace_printk_fmt, vargs);		\
 } while (0)
 

  parent reply	other threads:[~2009-03-09  9:13 UTC|newest]

Thread overview: 26+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-03-06 16:21 [PATCH 0/5 v3] Binary ftrace_printk Frederic Weisbecker
2009-03-06 16:21 ` [PATCH 1/5 v2] add binary printf Frederic Weisbecker
2009-03-06 16:50   ` Steven Rostedt
2009-03-06 17:00   ` [tip:core/printk] vsprintf: " Lai Jiangshan
2009-03-06 16:21 ` [PATCH 2/5 v3] ftrace: infrastructure for supporting binary record Frederic Weisbecker
2009-03-06 17:00   ` [tip:tracing/printk] tracing: " Lai Jiangshan
2009-03-06 16:21 ` [PATCH 3/5 v3] ftrace: add ftrace_bprintk() Frederic Weisbecker
2009-03-06 17:00   ` [tip:tracing/printk] tracing: add trace_bprintk() Lai Jiangshan
2009-03-06 16:21 ` [PATCH 4/5 v3] tracing/core: drop the old ftrace_printk implementation in favour of ftrace_bprintk Frederic Weisbecker
2009-03-06 16:49   ` Steven Rostedt
2009-03-06 17:02     ` Ingo Molnar
2009-03-06 17:14       ` Ingo Molnar
2009-03-06 18:04         ` Steven Rostedt
2009-03-06 18:49           ` Ingo Molnar
2009-03-06 19:09             ` Frederic Weisbecker
2009-03-06 19:17             ` Ingo Molnar
2009-03-06 17:14     ` Frederic Weisbecker
2009-03-06 17:01   ` [tip:tracing/printk] tracing/core: drop the old trace_printk() implementation in favour of trace_bprintk() Frederic Weisbecker
2009-03-06 17:01   ` [tip:tracing/printk] tracing: trace_bprintk() cleanups Ingo Molnar
2009-03-09  9:12   ` [tip:tracing/printk] tracing: trace_printk() fix, move format array to data section Ingo Molnar
2009-03-09  9:12   ` Ingo Molnar [this message]
2009-03-09 17:23     ` [tip:tracing/printk] tracing: optimize trace_printk() Steven Rostedt
2009-03-09 17:24       ` Steven Rostedt
2009-03-09 17:38         ` Frederic Weisbecker
2009-03-06 16:21 ` [PATCH 5/5 v3] vsprintf: unify the format decoding layer for its 3 users Frederic Weisbecker
2009-03-06 17:00   ` [tip:core/printk] " Frederic Weisbecker

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=tip-7bffc23e56e92c14b787bf4d95249a32085bfed5@git.kernel.org \
    --to=mingo@elte.hu \
    --cc=fweisbec@gmail.com \
    --cc=hpa@zytor.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-tip-commits@vger.kernel.org \
    --cc=mingo@redhat.com \
    --cc=peterz@infradead.org \
    --cc=rostedt@goodmis.org \
    --cc=tglx@linutronix.de \
    /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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox