From: Steven Rostedt <rostedt@goodmis.org>
To: LKML <linux-kernel@vger.kernel.org>
Cc: Peter Zijlstra <peterz@infradead.org>,
"Theodore Ts'o" <tytso@mit.edu>, Ingo Molnar <mingo@kernel.org>,
Thomas Gleixner <tglx@linutronix.de>,
Andrew Morton <akpm@linux-foundation.org>,
Benjamin Herrenschmidt <benh@kernel.crashing.org>,
Peter Hurley <peter@hurleysoftware.com>
Subject: [RFC][PATCH] tracing: Print nasty banner when trace_printk() is in use
Date: Wed, 28 May 2014 13:14:40 -0400 [thread overview]
Message-ID: <20140528131440.2283213c@gandalf.local.home> (raw)
trace_printk() is used to debug fast paths within the kernel. Places
that gets called in any context (interrupt or NMI) or thousands of
times a second. Something you do not want to do with a printk().
In order to make it completely lockless as it needs a temporary buffer
to handle some of the string formatting, a page is created per cpu for
every context (four per cpu; normal, softirq, irq, NMI).
Since trace_printk() should only be used for debugging purposes,
there's no reason to waste memory on these buffers on a production
system. That means, trace_printk() should never be used unless a
developer is debugging their kernel. There's macro magic to allocate
the buffers if trace_printk() is used anywhere in the kernel.
To help enforce that trace_printk() isn't used outside of development,
when it is used, a nasty banner is displayed on bootup (or when a module
is loaded that uses trace_printk() and the kernel core does not).
Here's the banner:
****************************************
** NOTICE NOTICE NOTICE NOTICE NOTICE **
** trace_printk() being used. **
** Allocating extra memory for it **
****************************************
Hmm, maybe I should add "Not for production use" to scare people even
more?
Not-yet-signed-off-by: Steven Rostedt <rostedt@goodmis.org>
---
Ted,
I noticed that in fs/ext4/inline.c you use trace_printk() if
INLINE_DIR_DEBUG is defined. I'm assuming that this is not a production
setting and this banner should not affect you at all. Am I correct?
There's some other places that use it, but those are obviously debug
only.
diff --git a/kernel/trace/trace.c b/kernel/trace/trace.c
index 0543169..068f453 100644
--- a/kernel/trace/trace.c
+++ b/kernel/trace/trace.c
@@ -1975,7 +1975,11 @@ void trace_printk_init_buffers(void)
if (alloc_percpu_trace_buffer())
return;
- pr_info("ftrace: Allocated trace_printk buffers\n");
+ pr_warning("****************************************\n");
+ pr_warning("** NOTICE NOTICE NOTICE NOTICE NOTICE **\n");
+ pr_warning("** trace_printk() being used. **\n");
+ pr_warning("** Allocating extra memory for it **\n");
+ pr_warning("****************************************\n");
/* Expand the buffers to set size */
tracing_update_buffers();
next reply other threads:[~2014-05-28 17:14 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-05-28 17:14 Steven Rostedt [this message]
2014-05-28 17:22 ` Peter Zijlstra
2014-05-28 17:37 ` Steven Rostedt
2014-05-28 17:26 ` Borislav Petkov
2014-05-28 17:41 ` Steven Rostedt
2014-05-30 6:07 ` Olaf Titz
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=20140528131440.2283213c@gandalf.local.home \
--to=rostedt@goodmis.org \
--cc=akpm@linux-foundation.org \
--cc=benh@kernel.crashing.org \
--cc=linux-kernel@vger.kernel.org \
--cc=mingo@kernel.org \
--cc=peter@hurleysoftware.com \
--cc=peterz@infradead.org \
--cc=tglx@linutronix.de \
--cc=tytso@mit.edu \
/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
all inboxes | Powered by JetHome®