aboutsummaryrefslogtreecommitdiffstats
path: root/include/linux/kernel.h
diff options
context:
space:
mode:
authorFrederic Weisbecker <fweisbec@gmail.com>2009-03-12 13:24:49 -0400
committerSteven Rostedt <srostedt@redhat.com>2009-03-12 21:15:00 -0400
commit48ead02030f849d011259244bb4ea9b985479006 (patch)
tree4500f27dc7eb6567ca79dd03fa94fe9e56fbc316 /include/linux/kernel.h
parentdb526ca329f855510e8ce672332eba3304aed590 (diff)
tracing/core: bring back raw trace_printk for dynamic formats strings
Impact: fix callsites with dynamic format strings Since its new binary implementation, trace_printk() internally uses static containers for the format strings on each callsites. But the value is assigned once at build time, which means that it can't take dynamic formats. So this patch unearthes the raw trace_printk implementation for the callers that will need trace_printk to be able to carry these dynamic format strings. The trace_printk() macro will use the appropriate implementation for each callsite. Most of the time however, the binary implementation will still be used. The other impact of this patch is that mmiotrace_printk() will use the old implementation because it calls the low level trace_vprintk and we can't guess here whether the format passed in it is dynamic or not. Some parts of this patch have been written by Steven Rostedt (most notably the part that chooses the appropriate implementation for each callsites). Signed-off-by: Frederic Weisbecker <fweisbec@gmail.com> Signed-off-by: Steven Rostedt <srostedt@redhat.com>
Diffstat (limited to 'include/linux/kernel.h')
-rw-r--r--include/linux/kernel.h40
1 files changed, 27 insertions, 13 deletions
diff --git a/include/linux/kernel.h b/include/linux/kernel.h
index 7742798c9208..1daca3b062bb 100644
--- a/include/linux/kernel.h
+++ b/include/linux/kernel.h
@@ -452,32 +452,46 @@ do { \
452 452
453#define trace_printk(fmt, args...) \ 453#define trace_printk(fmt, args...) \
454do { \ 454do { \
455 static const char *trace_printk_fmt \
456 __attribute__((section("__trace_printk_fmt"))); \
457 \
458 if (!trace_printk_fmt) \
459 trace_printk_fmt = fmt; \
460 \
461 __trace_printk_check_format(fmt, ##args); \ 455 __trace_printk_check_format(fmt, ##args); \
462 __trace_printk(_THIS_IP_, trace_printk_fmt, ##args); \ 456 if (__builtin_constant_p(fmt)) { \
457 static const char *trace_printk_fmt \
458 __attribute__((section("__trace_printk_fmt"))) = \
459 __builtin_constant_p(fmt) ? fmt : NULL; \
460 \
461 __trace_bprintk(_THIS_IP_, trace_printk_fmt, ##args); \
462 } else \
463 __trace_printk(_THIS_IP_, fmt, ##args); \
463} while (0) 464} while (0)
464 465
465extern int 466extern int
467__trace_bprintk(unsigned long ip, const char *fmt, ...)
468 __attribute__ ((format (printf, 2, 3)));
469
470extern int
466__trace_printk(unsigned long ip, const char *fmt, ...) 471__trace_printk(unsigned long ip, const char *fmt, ...)
467 __attribute__ ((format (printf, 2, 3))); 472 __attribute__ ((format (printf, 2, 3)));
468 473
474/*
475 * The double __builtin_constant_p is because gcc will give us an error
476 * if we try to allocate the static variable to fmt if it is not a
477 * constant. Even with the outer if statement.
478 */
469#define ftrace_vprintk(fmt, vargs) \ 479#define ftrace_vprintk(fmt, vargs) \
470do { \ 480do { \
471 static const char *trace_printk_fmt \ 481 if (__builtin_constant_p(fmt)) { \
472 __attribute__((section("__trace_printk_fmt"))); \ 482 static const char *trace_printk_fmt \
473 \ 483 __attribute__((section("__trace_printk_fmt"))) = \
474 if (!trace_printk_fmt) \ 484 __builtin_constant_p(fmt) ? fmt : NULL; \
475 trace_printk_fmt = fmt; \
476 \ 485 \
477 __ftrace_vprintk(_THIS_IP_, trace_printk_fmt, vargs); \ 486 __ftrace_vbprintk(_THIS_IP_, trace_printk_fmt, vargs); \
487 } else \
488 __ftrace_vprintk(_THIS_IP_, fmt, vargs); \
478} while (0) 489} while (0)
479 490
480extern int 491extern int
492__ftrace_vbprintk(unsigned long ip, const char *fmt, va_list ap);
493
494extern int
481__ftrace_vprintk(unsigned long ip, const char *fmt, va_list ap); 495__ftrace_vprintk(unsigned long ip, const char *fmt, va_list ap);
482 496
483extern void ftrace_dump(void); 497extern void ftrace_dump(void);