tracing/core: drop the old ftrace_printk implementation in favour of ftrace_bprintk
Subsystems (4)
PATCH 2/2 tracing/core: drop the old ftrace_printk implementation in favour of ftrace_bprintk
Impact: faster and lighter tracing
Now that we have ftrace_bprintk() which is faster and consume lesser memory than ftrace_printk() and has the same purpose, we can now drop the old implementation in favour of the binary one from ftrace_bprintk(), which means we move all the implementation of ftrace_bprintk() to ftrace_printk(), so the Api doesn't change except that we must now use trace_seq_bprintk() to print the TRACE_PRINT entries.
Some changes result of this:
- Previously, ftrace_bprintk depended of a single tracer and couldn't work without. This tracer has been dropped and the whole implementation of ftrace_printk() (like the module formats management) is now integrated in the tracing core (comes with CONFIG_TRACING), though we keep the file trace_bprintk (previously trace_bprintk.c) where we can find the module management. Thus we don't overflow trace.c
- changes some parts to use trace_seq_bprintk() to print TRACE_PRINT entries.
- change a bit ftrace_printk/ftrace_vprintk macros to support non-builtin formats constants, and fix 'const' qualifiers warnings. But this is all transparent for developers.
- etc...
---
include/linux/ftrace.h | 68 ++++----
include/linux/module.h | 2 +-
kernel/trace/Kconfig | 7 +-
kernel/trace/Makefile | 2 +-
kernel/trace/trace.c | 211 +++++++---------------
kernel/trace/trace.h | 14 +--
kernel/trace/trace_functions_graph.c | 6 +-
kernel/trace/trace_mmiotrace.c | 9 +-
kernel/trace/trace_output.c | 69 +------
kernel/trace/trace_output.h | 2 +
kernel/trace/{trace_bprintk.c => trace_printk.c} | 113 ++++--------
11 files changed, 162 insertions(+), 341 deletions(-)
rename kernel/trace/{trace_bprintk.c => trace_printk.c} (65%)include/linux/ftrace.h +34 -34
@@ -222,31 +222,6 @@ extern int ftrace_make_nop(struct module *mod,*/ 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 */ extern int ftrace_arch_read_dyn_info (char *buf,int size);
@@ -367,15 +342,40 @@ ftrace_special(unsigned long arg1, unsigned long arg2, unsigned long arg3);* Please refrain from leaving ftrace_printks scattered around in * your code. */ -# define ftrace_printk(fmt...) __ftrace_printk(_THIS_IP_, fmt) -extern int -__ftrace_printk (unsigned long ip,const char *fmt, ...) - __attribute__ ((format (printf,2 ,3 ))); -# define ftrace_vprintk (fmt, ap) __ftrace_printk(_THIS_IP_, fmt, ap) -extern int -__ftrace_vprintk (unsigned long ip,const char *fmt,va_list ap); +extern int __ftrace_vprintk (unsigned long ip,const char *fmt,va_list args); +extern int __ftrace_printk (unsigned long ip,const char *fmt, ...) + __attribute__ ((format (printf,2 ,3 ))); + +static inline void ____ftrace_printk_check_format (const char *fmt, ...) + __attribute__ ((format (printf,1 ,2 ))); +static inline void ____ftrace_printk_check_format (const char *fmt, ...) {} +#define __ftrace_printk_check_format(fmt, args...) \ +do { \ + if (0) \ + ____ftrace_printk_check_format(fmt, ##args); \ +} while (0) + +#define ftrace_vprintk (fmt, vargs) \ +do { \ + static const char *ftrace_printk_fmt \ + __attribute__((section("__trace_bprintk_fmt"))); \ + ftrace_printk_fmt = fmt; \ + __ftrace_vprintk(_THIS_IP_, ftrace_printk_fmt, vargs); \ +} while (0) + +#define ftrace_printk(fmt, args...) \ +do { \ + static const char *ftrace_printk_fmt \ + __attribute__((section("__trace_bprintk_fmt"))); \ + ftrace_printk_fmt = fmt; \ + __ftrace_printk_check_format(fmt, ##args); \ + __ftrace_printk(_THIS_IP_, ftrace_printk_fmt, ##args); \ +} while (0) +extern void ftrace_dump (void ); -#else + +#else /* !CONFIG_TRACING */ +static inline void ftrace_special (unsigned long arg1,unsigned long arg2,unsigned long arg3) { } static inline int
@@ -395,7 +395,7 @@ ftrace_vprintk(const char *fmt, va_list ap) return 0; }static inline void ftrace_dump (void ) { } -#endif +#endif /* CONFIG_TRACING */ #ifdef CONFIG_FTRACE_MCOUNT_RECORD extern void ftrace_init (void );
include/linux/module.h +1 -1
@@ -347,7 +347,7 @@ struct moduleunsigned int num_tracepoints;#endif -#ifdef CONFIG_TRACE_BPRINTK +#ifdef CONFIG_TRACING const char **trace_bprintk_fmt_start;unsigned int num_trace_bprintk_fmt;#endif
kernel/trace/Kconfig +1 -6
@@ -52,6 +52,7 @@ config TRACING select STACKTRACE if STACKTRACE_SUPPORT select TRACEPOINTS select NOP_TRACER + select BINARY_PRINTF menu "Tracers"
@@ -86,12 +87,6 @@ config FUNCTION_GRAPH_TRACER This is done by setting the current return address on the current task structure into a stack of calls. -config TRACE_BPRINTK - bool "Binary printk for tracing" - default y - depends on TRACING - select BINARY_PRINTF - config IRQSOFF_TRACER bool "Interrupts-off Latency Tracer" default n
kernel/trace/Makefile +1 -1
@@ -21,7 +21,7 @@ obj-$(CONFIG_RING_BUFFER) += ring_buffer.o obj-$(CONFIG_TRACING) += trace.o obj-$(CONFIG_TRACING) += trace_output.o obj-$(CONFIG_TRACING) += trace_stat.o -obj-$(CONFIG_TRACE_BPRINTK) += trace_bprintk.o +obj-$(CONFIG_TRACING) += trace_printk.o obj-$(CONFIG_CONTEXT_SWITCH_TRACER) += trace_sched_switch.o obj-$(CONFIG_SYSPROF_TRACER) += trace_sysprof.o obj-$(CONFIG_FUNCTION_TRACER) += trace_functions.o
kernel/trace/trace.c +62 -149
229 lines not on this page · raw message
kernel/trace/trace.h +3 -11
@@ -20,7 +20,6 @@ enum trace_type {TRACE_WAKE ,TRACE_STACK ,TRACE_PRINT , -TRACE_BPRINTK ,TRACE_SPECIAL ,TRACE_MMIO_RW , TRACE_MMIO_MAP,
@@ -120,16 +119,10 @@ struct userstack_entry {*/ struct print_entry {struct trace_entry ent; -unsigned long ip; +unsigned long ip;int depth; -char buf[]; -}; - -struct bprintk_entry { -struct trace_entry ent; -unsigned long ip; -const char *fmt; -u32 buf[]; +const char *fmt; +u32 buf[]; };#ifdef CONFIG_TRACE_BPRINTK extern int trace_bprintk_enable;
@@ -295,7 +288,6 @@ extern void __ftrace_bad_type(void); IF_ASSIGN(var, ent, struct stack_entry, TRACE_STACK); \ IF_ASSIGN(var, ent, struct userstack_entry, TRACE_USER_STACK);\ IF_ASSIGN(var, ent, struct print_entry, TRACE_PRINT); \ - IF_ASSIGN(var, ent, struct bprintk_entry, TRACE_BPRINTK);\ IF_ASSIGN(var, ent, struct special_entry, 0); \ IF_ASSIGN(var, ent, struct trace_mmiotrace_rw, \TRACE_MMIO_RW ); \
kernel/trace/trace_functions_graph.c +5 -1
@@ -742,7 +742,11 @@ print_graph_comment(struct print_entry *trace, struct trace_seq *s, }/* The comment */ - ret =trace_seq_printf (s,"/* %s" , trace->buf); + ret =trace_seq_printf (s,"/* " ); +if (!ret) +return TRACE_TYPE_PARTIAL_LINE ; + + ret =trace_seq_bprintf (s, trace->fmt, trace->buf);if (!ret)return TRACE_TYPE_PARTIAL_LINE ;
kernel/trace/trace_mmiotrace.c +6 -3
@@ -254,15 +254,18 @@ static enum print_line_t mmio_print_mark(struct trace_iterator *iter) {struct trace_entry *entry = iter->ent;struct print_entry *print = (struct print_entry *)entry; -const char *msg = print->buf;struct trace_seq *s = &iter->seq;unsigned long long t =ns2usecs (iter->ts); -unsigned long usec_rem =do_div (t,1000000ULL ); +unsigned long usec_rem =do_div (t,USEC_PER_SEC );unsigned secs = (unsigned long )t;int ret;/* The trailing newline must be in the message. */ - ret =trace_seq_printf (s,"MARK %u.%06lu %s" , secs, usec_rem, msg); + ret =trace_seq_printf (s,"MARK %u.%06lu " , secs, usec_rem); +if (!ret) +return TRACE_TYPE_PARTIAL_LINE ; + + ret =trace_seq_bprintf (s, print->fmt, print->buf);if (!ret)return TRACE_TYPE_PARTIAL_LINE ;
kernel/trace/trace_output.c +10 -59
102 lines not on this page · raw message
kernel/trace/trace_output.h +2 -0
@@ -19,6 +19,8 @@ struct trace_event {extern int trace_seq_printf (struct trace_seq *s,const char *fmt, ...) __attribute__ ((format (printf,2 ,3 )));extern int +trace_seq_bprintf (struct trace_seq *s,const char *fmt,const u32 *binary); +extern int seq_print_ip_sym (struct trace_seq *s,unsigned long ip,unsigned long sym_flags); extern ssize_t trace_seq_to_user(struct trace_seq *s, char __user *ubuf,
kernel/trace/trace_printk.c renamed from kernel/trace/trace_bprintk.c +37 -76
183 lines not on this page · raw message
Signature · 1 line
1.6.1