aboutsummaryrefslogtreecommitdiffstats
path: root/include/linux/kernel.h
diff options
context:
space:
mode:
authorSteven Rostedt (Red Hat) <rostedt@goodmis.org>2013-03-08 21:02:34 -0500
committerSteven Rostedt <rostedt@goodmis.org>2013-03-15 00:35:55 -0400
commit09ae72348eccb60e304cf8ce94653f4a78fcd407 (patch)
tree28c48644f71df4752556d9f5b15efb889e57af56 /include/linux/kernel.h
parent153e8ed913b022d2003866a848af9fadc041403f (diff)
tracing: Add trace_puts() for even faster trace_printk() tracing
The trace_printk() is extremely fast and is very handy as it can be used in any context (including NMIs!). But it still requires scanning the fmt string for parsing the args. Even the trace_bprintk() requires a scan to know what args will be saved, although it doesn't copy the format string itself. Several times trace_printk() has no args, and wastes cpu cycles scanning the fmt string. Adding trace_puts() allows the developer to use an even faster tracing method that only saves the pointer to the string in the ring buffer without doing any format parsing at all. This will help remove even more of the "Heisenbug" effect, when debugging. Also fixed up the F_printk()s for the ftrace internal bprint and print events. Cc: Thomas Gleixner <tglx@linutronix.de> Cc: Peter Zijlstra <a.p.zijlstra@chello.nl> Cc: Frederic Weisbecker <fweisbec@gmail.com> Signed-off-by: Steven Rostedt <rostedt@goodmis.org>
Diffstat (limited to 'include/linux/kernel.h')
-rw-r--r--include/linux/kernel.h41
1 files changed, 40 insertions, 1 deletions
diff --git a/include/linux/kernel.h b/include/linux/kernel.h
index bc5392a326ab..a3a5574a61fc 100644
--- a/include/linux/kernel.h
+++ b/include/linux/kernel.h
@@ -514,7 +514,8 @@ do { \
514 * 514 *
515 * This is intended as a debugging tool for the developer only. 515 * This is intended as a debugging tool for the developer only.
516 * Please refrain from leaving trace_printks scattered around in 516 * Please refrain from leaving trace_printks scattered around in
517 * your code. 517 * your code. (Extra memory is used for special buffers that are
518 * allocated when trace_printk() is used)
518 */ 519 */
519 520
520#define trace_printk(fmt, args...) \ 521#define trace_printk(fmt, args...) \
@@ -537,6 +538,44 @@ int __trace_bprintk(unsigned long ip, const char *fmt, ...);
537extern __printf(2, 3) 538extern __printf(2, 3)
538int __trace_printk(unsigned long ip, const char *fmt, ...); 539int __trace_printk(unsigned long ip, const char *fmt, ...);
539 540
541/**
542 * trace_puts - write a string into the ftrace buffer
543 * @str: the string to record
544 *
545 * Note: __trace_bputs is an internal function for trace_puts and
546 * the @ip is passed in via the trace_puts macro.
547 *
548 * This is similar to trace_printk() but is made for those really fast
549 * paths that a developer wants the least amount of "Heisenbug" affects,
550 * where the processing of the print format is still too much.
551 *
552 * This function allows a kernel developer to debug fast path sections
553 * that printk is not appropriate for. By scattering in various
554 * printk like tracing in the code, a developer can quickly see
555 * where problems are occurring.
556 *
557 * This is intended as a debugging tool for the developer only.
558 * Please refrain from leaving trace_puts scattered around in
559 * your code. (Extra memory is used for special buffers that are
560 * allocated when trace_puts() is used)
561 *
562 * Returns: 0 if nothing was written, positive # if string was.
563 * (1 when __trace_bputs is used, strlen(str) when __trace_puts is used)
564 */
565
566extern int __trace_bputs(unsigned long ip, const char *str);
567extern int __trace_puts(unsigned long ip, const char *str, int size);
568#define trace_puts(str) ({ \
569 static const char *trace_printk_fmt \
570 __attribute__((section("__trace_printk_fmt"))) = \
571 __builtin_constant_p(str) ? str : NULL; \
572 \
573 if (__builtin_constant_p(str)) \
574 __trace_bputs(_THIS_IP_, trace_printk_fmt); \
575 else \
576 __trace_puts(_THIS_IP_, str, strlen(str)); \
577})
578
540extern void trace_dump_stack(void); 579extern void trace_dump_stack(void);
541 580
542/* 581/*