diff options
author | Steven Rostedt <rostedt@goodmis.org> | 2014-05-28 13:14:40 -0400 |
---|---|---|
committer | Steven Rostedt <rostedt@goodmis.org> | 2014-05-29 20:13:59 -0400 |
commit | 2184db46e425c2b84a783eeead0e2b24ce67cd7f (patch) | |
tree | 729fe482333786cd109018786de122873d6e634d /kernel | |
parent | 607e3a29203633eaec7334f2f58f9653df788a06 (diff) |
tracing: Print nasty banner when trace_printk() is in use
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 NOTICE NOTICE **
** **
** trace_printk() being used. Allocating extra memory. **
** **
** This means that this is a DEBUG kernel and it is **
** unsafe for produciton use. **
** **
** If you see this message and you are not debugging **
** the kernel, report this immediately to your vendor! **
** **
** NOTICE NOTICE NOTICE NOTICE NOTICE NOTICE NOTICE **
**********************************************************
That should hopefully keep developers from trying to sneak in a
trace_printk() or two.
Link: http://lkml.kernel.org/p/20140528131440.2283213c@gandalf.local.home
Signed-off-by: Steven Rostedt <rostedt@goodmis.org>
Diffstat (limited to 'kernel')
-rw-r--r-- | kernel/trace/trace.c | 16 |
1 files changed, 15 insertions, 1 deletions
diff --git a/kernel/trace/trace.c b/kernel/trace/trace.c index 05431696b10c..eb228b9de170 100644 --- a/kernel/trace/trace.c +++ b/kernel/trace/trace.c | |||
@@ -1975,7 +1975,21 @@ void trace_printk_init_buffers(void) | |||
1975 | if (alloc_percpu_trace_buffer()) | 1975 | if (alloc_percpu_trace_buffer()) |
1976 | return; | 1976 | return; |
1977 | 1977 | ||
1978 | pr_info("ftrace: Allocated trace_printk buffers\n"); | 1978 | /* trace_printk() is for debug use only. Don't use it in production. */ |
1979 | |||
1980 | pr_warning("\n**********************************************************\n"); | ||
1981 | pr_warning("** NOTICE NOTICE NOTICE NOTICE NOTICE NOTICE NOTICE **\n"); | ||
1982 | pr_warning("** **\n"); | ||
1983 | pr_warning("** trace_printk() being used. Allocating extra memory. **\n"); | ||
1984 | pr_warning("** **\n"); | ||
1985 | pr_warning("** This means that this is a DEBUG kernel and it is **\n"); | ||
1986 | pr_warning("** unsafe for produciton use. **\n"); | ||
1987 | pr_warning("** **\n"); | ||
1988 | pr_warning("** If you see this message and you are not debugging **\n"); | ||
1989 | pr_warning("** the kernel, report this immediately to your vendor! **\n"); | ||
1990 | pr_warning("** **\n"); | ||
1991 | pr_warning("** NOTICE NOTICE NOTICE NOTICE NOTICE NOTICE NOTICE **\n"); | ||
1992 | pr_warning("**********************************************************\n"); | ||
1979 | 1993 | ||
1980 | /* Expand the buffers to set size */ | 1994 | /* Expand the buffers to set size */ |
1981 | tracing_update_buffers(); | 1995 | tracing_update_buffers(); |