aboutsummaryrefslogtreecommitdiffstats
path: root/include
diff options
context:
space:
mode:
authorLai Jiangshan <laijs@cn.fujitsu.com>2009-03-06 11:21:48 -0500
committerIngo Molnar <mingo@elte.hu>2009-03-06 11:59:11 -0500
commit1ba28e02a18cbdbea123836f6c98efb09cbf59ec (patch)
tree41df06a06c702152902ffd7250f284a6efe9b0da /include
parent1427cdf0592368bdec57276edaf714040ee8744f (diff)
tracing: add trace_bprintk()
Impact: add a generic printk() for tracing, like trace_printk() trace_bprintk() uses the infrastructure to record events on ring_buffer. [ fweisbec@gmail.com: ported to latest -tip, made it work if !CONFIG_MODULES, never free the format strings from modules because we can't keep track of them and conditionnaly create the ftrace format strings section (reported by Steven Rostedt) ] Signed-off-by: Lai Jiangshan <laijs@cn.fujitsu.com> Signed-off-by: Frederic Weisbecker <fweisbec@gmail.com> Acked-by: Steven Rostedt <rostedt@goodmis.org> LKML-Reference: <1236356510-8381-4-git-send-email-fweisbec@gmail.com> Signed-off-by: Ingo Molnar <mingo@elte.hu>
Diffstat (limited to 'include')
-rw-r--r--include/asm-generic/vmlinux.lds.h9
-rw-r--r--include/linux/ftrace.h21
-rw-r--r--include/linux/module.h5
3 files changed, 35 insertions, 0 deletions
diff --git a/include/asm-generic/vmlinux.lds.h b/include/asm-generic/vmlinux.lds.h
index 0add6b28c366..48ade3168b13 100644
--- a/include/asm-generic/vmlinux.lds.h
+++ b/include/asm-generic/vmlinux.lds.h
@@ -69,6 +69,14 @@
69#define FTRACE_EVENTS() 69#define FTRACE_EVENTS()
70#endif 70#endif
71 71
72#ifdef CONFIG_TRACING
73#define TRACE_PRINTKS() VMLINUX_SYMBOL(__start___trace_bprintk_fmt) = .; \
74 *(__trace_printk_fmt) /* Trace_printk fmt' pointer */ \
75 VMLINUX_SYMBOL(__stop___trace_bprintk_fmt) = .;
76#else
77#define TRACE_PRINTKS()
78#endif
79
72/* .data section */ 80/* .data section */
73#define DATA_DATA \ 81#define DATA_DATA \
74 *(.data) \ 82 *(.data) \
@@ -100,6 +108,7 @@
100 *(__vermagic) /* Kernel version magic */ \ 108 *(__vermagic) /* Kernel version magic */ \
101 *(__markers_strings) /* Markers: strings */ \ 109 *(__markers_strings) /* Markers: strings */ \
102 *(__tracepoints_strings)/* Tracepoints: strings */ \ 110 *(__tracepoints_strings)/* Tracepoints: strings */ \
111 TRACE_PRINTKS() \
103 } \ 112 } \
104 \ 113 \
105 .rodata1 : AT(ADDR(.rodata1) - LOAD_OFFSET) { \ 114 .rodata1 : AT(ADDR(.rodata1) - LOAD_OFFSET) { \
diff --git a/include/linux/ftrace.h b/include/linux/ftrace.h
index 1c9cdca02580..1cc8ca453a9b 100644
--- a/include/linux/ftrace.h
+++ b/include/linux/ftrace.h
@@ -225,6 +225,27 @@ extern int ftrace_make_call(struct dyn_ftrace *rec, unsigned long addr);
225 225
226#ifdef CONFIG_TRACE_BPRINTK 226#ifdef CONFIG_TRACE_BPRINTK
227extern int trace_vbprintk(unsigned long ip, const char *fmt, va_list args); 227extern int trace_vbprintk(unsigned long ip, const char *fmt, va_list args);
228extern int __trace_bprintk(unsigned long ip, const char *fmt, ...)
229 __attribute__ ((format (printf, 2, 3)));
230
231static inline void ____trace_bprintk_check_format(const char *fmt, ...)
232 __attribute__ ((format (printf, 1, 2)));
233static inline void ____trace_bprintk_check_format(const char *fmt, ...) {}
234#define __trace_bprintk_check_format(fmt, args...) \
235do { \
236 if (0) \
237 ____trace_bprintk_check_format(fmt, ##args); \
238} while (0)
239
240#define trace_bprintk(fmt, args...) \
241do { \
242 static char *__attribute__((section("__trace_bprintk_fmt"))) \
243 trace_bprintk_fmt = fmt; \
244 __trace_bprintk_check_format(fmt, ##args); \
245 __trace_bprintk(_THIS_IP_, trace_bprintk_fmt, ##args); \
246} while (0)
247#else
248#define trace_bprintk trace_printk
228#endif 249#endif
229 250
230/* May be defined in arch */ 251/* May be defined in arch */
diff --git a/include/linux/module.h b/include/linux/module.h
index 145a75528cc1..8cbec972d8e7 100644
--- a/include/linux/module.h
+++ b/include/linux/module.h
@@ -329,6 +329,11 @@ struct module
329 unsigned int num_tracepoints; 329 unsigned int num_tracepoints;
330#endif 330#endif
331 331
332#ifdef CONFIG_TRACE_BPRINTK
333 const char **trace_bprintk_fmt_start;
334 unsigned int num_trace_bprintk_fmt;
335#endif
336
332#ifdef CONFIG_MODULE_UNLOAD 337#ifdef CONFIG_MODULE_UNLOAD
333 /* What modules depend on me? */ 338 /* What modules depend on me? */
334 struct list_head modules_which_use_me; 339 struct list_head modules_which_use_me;