tracing/core: drop the old ftrace_printk implementation in favour of ftrace_bprintk
Subsystems (4)
PATCH v2 4/5 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_printk (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...
V2:
- Rebase against last changes
- Fix mispell on the changelog
--- include/linux/ftrace.h | 68 ++++++------ include/linux/module.h | 2 +- kernel/trace/Kconfig | 7 +- kernel/trace/Makefile | 2 +- kernel/trace/trace.c | 212 ++++++++++------------------------ kernel/trace/trace.h | 14 +-- kernel/trace/trace_bprintk.c | 154 ------------------------ 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_printk.c | 138 ++++++++++++++++++++++ 12 files changed, 263 insertions(+), 420 deletions(-) delete mode 100644 kernel/trace/trace_bprintk.c create mode 100644 kernel/trace/trace_printk.c
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);
@@ -368,15 +343,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
@@ -396,7 +396,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
@@ -22,7 +22,7 @@ obj-$(CONFIG_TRACING) += trace.o obj-$(CONFIG_TRACING) += trace_clock.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 -150
230 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;
@@ -296,7 +289,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_bprintk.c deleted +0 -154
154 lines not on this page · raw message
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 new file +138 -0
138 lines not on this page · raw message
Signature · 1 line
1.6.1