ftrace: add ftrace_bprintk()
Subsystems (4)
PATCH 3/3 ftrace: add ftrace_bprintk()
From: Lai Jiangshan <[email protected]>
Impact: Add a generic printk() for ftrace, like ftrace_printk()
ftrace_bprintk() use the infrastructure to record events on ring_buffer.
[[email protected]: ported to latest -tip and make it work if !CONFIG_MODULES]
Signed-off-by Lai Jiangshan <[email protected]>
Signed-off-by Frederic Weisbecker <[email protected]>
Cc Steven Rostedt <[email protected]>
--- include/asm-generic/vmlinux.lds.h | 3 + include/linux/ftrace.h | 21 ++++++ include/linux/module.h | 5 ++ kernel/module.c | 6 ++ kernel/trace/trace.c | 15 ++++ kernel/trace/trace_bprintk.c | 132 ++++++++++++++++++++++++++++++++++++- 6 files changed, 181 insertions(+), 1 deletions(-)
include/asm-generic/vmlinux.lds.h +3 -0
@@ -91,6 +91,9 @@ *(__vermagic )/* Kernel version magic */ \ *(__markers_strings )/* Markers: strings */ \ *(__tracepoints_strings )/* Tracepoints: strings */ \ + VMLINUX_SYMBOL(__start___trace_bprintk_fmt) = .; \ + *(__trace_printk_fmt )/* Trace_printk fmt' pointer */ \ + VMLINUX_SYMBOL(__stop___trace_bprintk_fmt) = .; \ } \ \ .rodata1 : AT(ADDR(.rodata1) - LOAD_OFFSET) { \
include/linux/ftrace.h +21 -0
@@ -224,6 +224,27 @@ extern int ftrace_make_call(struct dyn_ftrace *rec, unsigned long addr);#ifdef CONFIG_TRACE_BPRINTK extern int trace_vbprintk (unsigned long ip,const char *fmt,va_list args); +extern int __ftrace_bprintk (unsigned long ip,const char *fmt, ...) + __attribute__ ((format (printf,2 ,3 ))); + +static inline void ____ftrace_bprintk_check_format (const char *fmt, ...) + __attribute__ ((format (printf,1 ,2 ))); +static inline void ____ftrace_bprintk_check_format (const char *fmt, ...) {} +#define __ftrace_bprintk_check_format(fmt, args...) \ +do { \ + if (0) \ + ____ftrace_bprintk_check_format(fmt, ##args); \ +} while (0) + +#define ftrace_bprintk(fmt, args...) \ +do { \ + static char *__attribute__((section("__trace_bprintk_fmt"))) \ + ftrace_bprintk_fmt = fmt; \ + __ftrace_bprintk_check_format(fmt, ##args); \ + __ftrace_bprintk(_THIS_IP_, ftrace_bprintk_fmt, ##args); \ +} while (0) +#else +#define ftrace_bprintk ftrace_printk#endif /* May be defined in arch */
include/linux/module.h +5 -0
@@ -347,6 +347,11 @@ struct moduleunsigned int num_tracepoints;#endif +#ifdef CONFIG_TRACE_BPRINTK +const char **trace_bprintk_fmt_start; +unsigned int num_trace_bprintk_fmt; +#endif +#ifdef CONFIG_MODULE_UNLOAD /* What modules depend on me? */ struct list_head modules_which_use_me;
kernel/module.c +6 -0
@@ -2158,6 +2158,12 @@ static noinline struct module *load_module(void __user *umod, &mod->num_tracepoints);#endif +#ifdef CONFIG_TRACE_BPRINTK + mod->trace_bprintk_fmt_start =section_objs (hdr, sechdrs, secstrings, +"__trace_bprintk_fmt" ,sizeof (char *), + &mod->num_trace_bprintk_fmt); +#endif +#ifdef CONFIG_MODVERSIONS if ((mod->num_syms && !mod->crcs) || (mod->num_gpl_syms && !mod->gpl_crcs)
kernel/trace/trace.c +15 -0
@@ -3140,6 +3140,21 @@ out: }EXPORT_SYMBOL_GPL (trace_vbprintk); +int __ftrace_bprintk (unsigned long ip,const char *fmt, ...) +{ +int ret; +va_list ap; + +if (!fmt) +return 0 ; + +va_start (ap, fmt); + ret =trace_vbprintk (ip, fmt, ap); +va_end (ap); +return ret; +} +EXPORT_SYMBOL_GPL (__ftrace_bprintk); +static int trace_panic_handler (struct notifier_block *this,unsigned long event,void *unused) {
kernel/trace/trace_bprintk.c +131 -1
162 lines not on this page · raw message
Signature · 1 line
1.6.1