tracing/core changes for v2.6.35
Subsystems (7)
Linus,
Please pull the latest tracing-core-for-linus git tree from:
git://git.kernel.org/pub/scm/linux/kernel/git/tip/linux-2.6-tip.git tracing-core-for-linus
Thanks,
Ingo
------------------>
Borislav Petkov (1):
ring-buffer: Wrap open-coded WARN_ONCE
Chase Douglas (2):
tracing: Add documentation for trace commands mod, traceon/traceoff
tracing: Show sample std dev in function profiling
David Miller (1):
ring-buffer: Make non-consuming read less expensive with lots of cpus.
Frederic Weisbecker (1):
tracing: Dump either the oops's cpu source or all cpus buffers
Jiri Olsa (3):
tracing: Add ftrace events for graph tracer
tracing: Have graph flags passed in to ouput functions
tracing: Add graph output support for irqsoff tracer
Lai Jiangshan (1):
tracing: Fix uninitialized variable of tracing/trace output
Li Zefan (4):
tracing: Convert some signal events to DEFINE_TRACE
tracing: Update comments
tracing: Remove side effect from module tracepoints that caused a GPF
tracing: Make the documentation clear on trace_event boot option
Steven Rostedt (8):
tracing: Fix compile error in module tracepoints when MODULE_UNLOAD not set
ring-buffer: Add place holder recording of dropped events
tracing: Show the lost events in the trace_pipe output
ring-buffer: Add lost event count to end of sub buffer
ring-buffer: Make benchmark handle missed events
tracing: Fix sleep time function profiling
tracing: Convert nop macros to static inlines
tracing: Fix tracepoint.h DECLARE_TRACE() to allow more than one header
Thiago Farina (1):
tracing: Fix "integer as NULL pointer" warning.
Documentation/kernel-parameters.txt | 6 +- Documentation/trace/events.txt | 3 +- Documentation/trace/ftrace.txt | 50 ++++++- drivers/char/sysrq.c | 2 +- drivers/oprofile/cpu_buffer.c | 4 +- include/linux/ftrace.h | 49 ++++-- include/linux/ftrace_event.h | 1 + include/linux/kernel.h | 11 +- include/linux/module.h | 6 +- include/linux/ring_buffer.h | 10 +- include/linux/tracepoint.h | 114 ++++++++------- include/trace/define_trace.h | 5 + include/trace/events/module.h | 18 ++- include/trace/events/napi.h | 10 +- include/trace/events/signal.h | 52 +++---- include/trace/ftrace.h | 33 +++-- kernel/module.c | 8 +- kernel/trace/ftrace.c | 30 ++++- kernel/trace/ring_buffer.c | 179 +++++++++++++++++++--- kernel/trace/ring_buffer_benchmark.c | 5 +- kernel/trace/trace.c | 127 ++++++++++++----- kernel/trace/trace.h | 27 +++- kernel/trace/trace_functions_graph.c | 169 ++++++++++++++-------- kernel/trace/trace_irqsoff.c | 271 ++++++++++++++++++++++++++++++++-- kernel/trace/trace_output.c | 2 +- kernel/trace/trace_selftest.c | 7 +- 26 files changed, 909 insertions(+), 290 deletions(-)
Documentation/kernel-parameters.txt +5 -1
@@ -784,8 +784,12 @@ and is between 256 and 4096 characters. It is defined in the file as early as possible in order to facilitate early boot debugging. - ftrace_dump_on_oops + ftrace_dump_on_oops[=orig_cpu] [FTRACE] will dump the trace buffers on oops. + If no parameter is passed, ftrace will dump + buffers of all CPUs, but if you pass orig_cpu, it will + dump only the buffer of the CPU that triggered the + oops. ftrace_filter=[function-list] [FTRACE] Limit the functions traced by the function
Documentation/trace/events.txt +2 -1
@@ -90,7 +90,8 @@ In order to facilitate early boot debugging, use boot option: trace_event=[event-list] -The format of this boot option is the same as described in section 2.1. +event-list is a comma separated list of events. See section 2.1 for event +format. 3. Defining an event-enabled tracepoint =======================================
Documentation/trace/ftrace.txt +48 -2
72 lines not on this page · raw message
drivers/char/sysrq.c +1 -1
@@ -289,7 +289,7 @@ static struct sysrq_key_op sysrq_showstate_blocked_op = {static void sysrq_ftrace_dump (int key,struct tty_struct *tty) { -ftrace_dump (); +ftrace_dump (DUMP_ALL ); }static struct sysrq_key_op sysrq_ftrace_dump_op = { .handler = sysrq_ftrace_dump,
drivers/oprofile/cpu_buffer.c +2 -2
@@ -186,14 +186,14 @@ int op_cpu_buffer_write_commit(struct op_entry *entry)struct op_sample *op_cpu_buffer_read_entry (struct op_entry *entry,int cpu) {struct ring_buffer_event *e; - e =ring_buffer_consume (op_ring_buffer_read, cpu,NULL ); + e =ring_buffer_consume (op_ring_buffer_read, cpu,NULL ,NULL );if (e) goto event;if (ring_buffer_swap_cpu (op_ring_buffer_read, op_ring_buffer_write, cpu))return NULL ; - e =ring_buffer_consume (op_ring_buffer_read, cpu,NULL ); + e =ring_buffer_consume (op_ring_buffer_read, cpu,NULL ,NULL );if (e) goto event;return NULL ;
include/linux/ftrace.h +32 -17
97 lines not on this page · raw message
include/linux/ftrace_event.h +1 -0
@@ -58,6 +58,7 @@ struct trace_iterator {/* The below is zeroed out in pipe_read */ struct trace_seq seq;struct trace_entry *ent; +unsigned long lost_events;int leftover;int cpu;u64 ts;
include/linux/kernel.h +9 -2
@@ -490,6 +490,13 @@ static inline void tracing_off(void) { }static inline void tracing_off_permanent (void ) { }static inline int tracing_is_on (void ) {return 0 ; }#endif + +enum ftrace_dump_mode { +DUMP_NONE , +DUMP_ALL , +DUMP_ORIG , +}; +#ifdef CONFIG_TRACING extern void tracing_start (void );extern void tracing_stop (void );
@@ -571,7 +578,7 @@ __ftrace_vbprintk(unsigned long ip, const char *fmt, va_list ap);extern int __ftrace_vprintk (unsigned long ip,const char *fmt,va_list ap); -extern void ftrace_dump (void ); +extern void ftrace_dump (enum ftrace_dump_mode oops_dump_mode);#else static inline void ftrace_special (unsigned long arg1,unsigned long arg2,unsigned long arg3) { }
@@ -592,7 +599,7 @@ ftrace_vprintk(const char *fmt, va_list ap) {return 0 ; } -static inline void ftrace_dump (void ) { } +static inline void ftrace_dump (enum ftrace_dump_mode oops_dump_mode) { }#endif /* CONFIG_TRACING */ /*
include/linux/module.h +2 -4
@@ -465,8 +465,7 @@ static inline void __module_get(struct module *module)if (module) {preempt_disable ();__this_cpu_inc (module->refptr->incs); -trace_module_get (module, _THIS_IP_, -__this_cpu_read (module->refptr->incs)); +trace_module_get (module, _THIS_IP_);preempt_enable (); } }
@@ -480,8 +479,7 @@ static inline int try_module_get(struct module *module)if (likely (module_is_live (module))) {__this_cpu_inc (module->refptr->incs); -trace_module_get (module, _THIS_IP_, -__this_cpu_read (module->refptr->incs)); +trace_module_get (module, _THIS_IP_); }else ret =0 ;
include/linux/ring_buffer.h +7 -3
@@ -120,12 +120,16 @@ int ring_buffer_write(struct ring_buffer *buffer, unsigned long length, void *data);struct ring_buffer_event * -ring_buffer_peek (struct ring_buffer *buffer,int cpu,u64 *ts); +ring_buffer_peek (struct ring_buffer *buffer,int cpu,u64 *ts, +unsigned long *lost_events);struct ring_buffer_event * -ring_buffer_consume (struct ring_buffer *buffer,int cpu,u64 *ts); +ring_buffer_consume (struct ring_buffer *buffer,int cpu,u64 *ts, +unsigned long *lost_events);struct ring_buffer_iter * -ring_buffer_read_start (struct ring_buffer *buffer,int cpu); +ring_buffer_read_prepare (struct ring_buffer *buffer,int cpu); +void ring_buffer_read_prepare_sync (void ); +void ring_buffer_read_start (struct ring_buffer_iter *iter);void ring_buffer_read_finish (struct ring_buffer_iter *iter); struct ring_buffer_event *
include/linux/tracepoint.h +59 -55
135 lines not on this page · raw message
include/trace/define_trace.h +5 -0
@@ -65,6 +65,10 @@#include TRACE_INCLUDE (TRACE_INCLUDE_FILE ) +/* Make all open coded DECLARE_TRACE nops */ +#undef DECLARE_TRACE +#define DECLARE_TRACE (name, proto, args) +#ifdef CONFIG_EVENT_TRACING #include <trace/ftrace.h> #endif
@@ -75,6 +79,7 @@#undef DEFINE_EVENT#undef DEFINE_EVENT_PRINT#undef TRACE_HEADER_MULTI_READ +#undef DECLARE_TRACE/* Only undef what we defined in this file */ #ifdef UNDEF_TRACE_INCLUDE_FILE
include/trace/events/module.h +11 -7
@@ -51,11 +51,14 @@ TRACE_EVENT(module_free,TP_printk ("%s" ,__get_str (name)) ); +#ifdef CONFIG_MODULE_UNLOAD +/* trace_module_get/put are only used if CONFIG_MODULE_UNLOAD is defined */ + DECLARE_EVENT_CLASS(module_refcnt, - TP_PROTO(struct module *mod, unsigned long ip, int refcnt), + TP_PROTO(struct module *mod, unsigned long ip), - TP_ARGS(mod, ip, refcnt), + TP_ARGS(mod, ip), TP_STRUCT__entry( __field( unsigned long, ip )
@@ -65,7 +68,7 @@ DECLARE_EVENT_CLASS(module_refcnt,TP_fast_assign ( __entry->ip = ip; - __entry->refcnt = refcnt; + __entry->refcnt =__this_cpu_read (mod->refptr->incs) +__this_cpu_read (mod->refptr->decs);__assign_str (name, mod->name); ),
@@ -75,17 +78,18 @@ DECLARE_EVENT_CLASS(module_refcnt,DEFINE_EVENT (module_refcnt, module_get, - TP_PROTO(struct module *mod, unsigned long ip, int refcnt), + TP_PROTO(struct module *mod, unsigned long ip), -TP_ARGS (mod, ip, refcnt) +TP_ARGS (mod, ip) );DEFINE_EVENT (module_refcnt, module_put, - TP_PROTO(struct module *mod, unsigned long ip, int refcnt), + TP_PROTO(struct module *mod, unsigned long ip), -TP_ARGS (mod, ip, refcnt) +TP_ARGS (mod, ip) ); +#endif /* CONFIG_MODULE_UNLOAD */ TRACE_EVENT(module_request,
include/trace/events/napi.h +8 -2
@@ -1,4 +1,7 @@ -#ifndef _TRACE_NAPI_H_ +#undef TRACE_SYSTEM +#define TRACE_SYSTEM napi + +#if !defined(_TRACE_NAPI_H) || defined(TRACE_HEADER_MULTI_READ )#define _TRACE_NAPI_H_#include <linux/netdevice.h>
@@ -8,4 +11,7 @@ DECLARE_TRACE(napi_poll, TP_PROTO(struct napi_struct *napi), TP_ARGS(napi)); -#endif +#endif /* _TRACE_NAPI_H_ */ + +/* This part must be outside protection */ +#include <trace/define_trace.h>
include/trace/events/signal.h +22 -30
74 lines not on this page · raw message
include/trace/ftrace.h +19 -14
@@ -154,9 +154,11 @@* * field = (typeof(field))entry; * -* p = get_cpu_var(ftrace_event_seq); +* p = &get_cpu_var(ftrace_event_seq); * trace_seq_init(p); -* ret = trace_seq_printf(s, <TP_printk> "\n"); +* ret = trace_seq_printf(s, "%s: ", <call>); +* if (ret) +* ret = trace_seq_printf(s, <TP_printk> "\n"); * put_cpu(); * if (!ret) * return TRACE_TYPE_PARTIAL_LINE;
@@ -450,38 +452,38 @@ perf_trace_disable_##name(struct ftrace_event_call *unused) \* * static void ftrace_raw_event_<call>(proto) * { +* struct ftrace_data_offsets_<call> __maybe_unused __data_offsets; * struct ring_buffer_event *event; * struct ftrace_raw_<call> *entry; <-- defined in stage 1 * struct ring_buffer *buffer; * unsigned long irq_flags; +* int __data_size; * int pc; * * local_save_flags(irq_flags); * pc = preempt_count(); * +* __data_size = ftrace_get_offsets_<call>(&__data_offsets, args); +* * event = trace_current_buffer_lock_reserve(&buffer, * event_<call>.id, -* sizeof(struct ftrace_raw_<call>), +* sizeof(*entry) + __data_size, * irq_flags, pc); * if (!event) * return; * entry = ring_buffer_event_data(event); * -* <assign>; <-- Here we assign the entries by the __field and -* __array macros. +* { <assign>; } <-- Here we assign the entries by the __field and +* __array macros. * -* trace_current_buffer_unlock_commit(buffer, event, irq_flags, pc); +* if (!filter_current_check_discard(buffer, event_call, entry, event)) +* trace_current_buffer_unlock_commit(buffer, +* event, irq_flags, pc); * } * * static int ftrace_raw_reg_event_<call>(struct ftrace_event_call *unused) * { -* int ret; -* -* ret = register_trace_<call>(ftrace_raw_event_<call>); -* if (!ret) -* pr_info("event trace: Could not activate trace point " -* "probe to <call>"); -* return ret; +* return register_trace_<call>(ftrace_raw_event_<call>); * } * * static void ftrace_unreg_event_<call>(struct ftrace_event_call *unused)
@@ -493,6 +495,8 @@ perf_trace_disable_##name(struct ftrace_event_call *unused) \* .trace = ftrace_raw_output_<call>, <-- stage 2 * }; * +* static const char print_fmt_<call>[] = <TP_printk>; +* * static struct ftrace_event_call __used * __attribute__((__aligned__(4))) * __attribute__((section("_ftrace_events"))) event_<call> = {
@@ -501,6 +505,8 @@ perf_trace_disable_##name(struct ftrace_event_call *unused) \* .raw_init = trace_event_raw_init, * .regfunc = ftrace_reg_event_<call>, * .unregfunc = ftrace_unreg_event_<call>, +* .print_fmt = print_fmt_<call>, +* .define_fields = ftrace_define_fields_<call>, * } * */
@@ -569,7 +575,6 @@ ftrace_raw_event_id_##call(struct ftrace_event_call *event_call, \return ; \ entry =ring_buffer_event_data (event); \ \ - \ tstruct \ \ { assign; } \
kernel/module.c +4 -4
@@ -59,8 +59,6 @@#define CREATE_TRACE_POINTS #include <trace/events/module.h> -EXPORT_TRACEPOINT_SYMBOL (module_get); -#if 0 #define DEBUGP printk#else
@@ -515,6 +513,9 @@ MODINFO_ATTR(srcversion);static char last_unloaded_module[MODULE_NAME_LEN +1 ];#ifdef CONFIG_MODULE_UNLOAD + +EXPORT_TRACEPOINT_SYMBOL (module_get); +/* Init the unload section of the module. */ static void module_unload_init (struct module *mod) {
@@ -867,8 +868,7 @@ void module_put(struct module *module)smp_wmb ();/* see comment in module_refcount */ __this_cpu_inc (module->refptr->decs); -trace_module_put (module, _RET_IP_, -__this_cpu_read (module->refptr->decs)); +trace_module_put (module, _RET_IP_);/* Maybe they're waiting for us to drop reference? */ if (unlikely (!module_is_live (module)))wake_up_process (module->waiter);
kernel/trace/ftrace.c +26 -4
@@ -264,6 +264,7 @@ struct ftrace_profile {unsigned long counter;#ifdef CONFIG_FUNCTION_GRAPH_TRACER unsigned long long time; +unsigned long long time_squared;#endif };
@@ -366,9 +367,9 @@ static int function_stat_headers(struct seq_file *m) {#ifdef CONFIG_FUNCTION_GRAPH_TRACER seq_printf (m," Function " -"Hit Time Avg\n" +"Hit Time Avg s^2\n" " -------- " -"--- ---- ---\n" ); +"--- ---- --- ---\n" );#else seq_printf (m," Function Hit\n" " -------- ---\n" );
@@ -384,6 +385,7 @@ static int function_stat_show(struct seq_file *m, void *v)static DEFINE_MUTEX (mutex);static struct trace_seq s;unsigned long long avg; +unsigned long long stddev;#endif kallsyms_lookup (rec->ip,NULL ,NULL ,NULL , str);
@@ -394,11 +396,25 @@ static int function_stat_show(struct seq_file *m, void *v) avg = rec->time;do_div (avg, rec->counter); +/* Sample standard deviation (s^2) */ +if (rec->counter <=1 ) + stddev =0 ; +else { + stddev = rec->time_squared - rec->counter * avg * avg; +/* +* Divide only 1000 for ns^2 -> us^2 conversion. +* trace_print_graph_duration will divide 1000 again. +*/ +do_div (stddev, (rec->counter -1 ) *1000 ); + } +mutex_lock (&mutex);trace_seq_init (&s);trace_print_graph_duration (rec->time, &s);trace_seq_puts (&s," " );trace_print_graph_duration (avg, &s); +trace_seq_puts (&s," " ); +trace_print_graph_duration (stddev, &s);trace_print_seq (m, &s);mutex_unlock (&mutex);#endif
@@ -650,6 +666,10 @@ static void profile_graph_return(struct ftrace_graph_ret *trace)if (!stat->hash || !ftrace_profile_enabled) goto out; +/* If the calltime was zero'd ignore it */ +if (!trace->calltime) + goto out; + calltime = trace->rettime - trace->calltime;if (!(trace_flags &TRACE_ITER_GRAPH_TIME )) {
@@ -668,8 +688,10 @@ static void profile_graph_return(struct ftrace_graph_ret *trace) } rec =ftrace_find_profiled_func (stat, trace->func); -if (rec) +if (rec) { rec->time += calltime; + rec->time_squared += calltime * calltime; + } out:local_irq_restore (flags);
@@ -3339,11 +3361,11 @@ void unregister_ftrace_graph(void) goto out; ftrace_graph_active--; -unregister_trace_sched_switch (ftrace_graph_probe_sched_switch); ftrace_graph_return = (trace_func_graph_ret_t )ftrace_stub; ftrace_graph_entry = ftrace_graph_entry_stub;ftrace_shutdown (FTRACE_STOP_FUNC_RET );unregister_pm_notifier (&ftrace_suspend_notifier); +unregister_trace_sched_switch (ftrace_graph_probe_sched_switch); out:mutex_unlock (&ftrace_lock);
kernel/trace/ring_buffer.c +154 -25
345 lines not on this page · raw message
kernel/trace/ring_buffer_benchmark.c +3 -2
@@ -81,7 +81,7 @@ static enum event_status read_event(int cpu)int *entry;u64 ts; - event =ring_buffer_consume (buffer, cpu, &ts); + event =ring_buffer_consume (buffer, cpu, &ts,NULL );if (!event)return EVENT_DROPPED ;
@@ -113,7 +113,8 @@ static enum event_status read_page(int cpu) ret =ring_buffer_read_page (buffer, &bpage,PAGE_SIZE , cpu,1 );if (ret >=0 ) { rpage = bpage; - commit =local_read (&rpage->commit); +/* The commit may have missed event flags set, clear them */ + commit =local_read (&rpage->commit) &0xfffff ;for (i =0 ; i < commit && !kill_test; i += inc) {if (i >= (PAGE_SIZE - offsetof(struct rb_page , data))) {
kernel/trace/trace.c +91 -36
284 lines not on this page · raw message
kernel/trace/trace.h +25 -2
@@ -378,6 +378,9 @@ void trace_function(struct trace_array *tr,unsigned long ip, unsigned long parent_ip, unsigned long flags, int pc); +void trace_default_header (struct seq_file *m); +void print_trace_header (struct seq_file *m,struct trace_iterator *iter); +int trace_empty (struct trace_iterator *iter);void trace_graph_return (struct ftrace_graph_ret *trace);int trace_graph_entry (struct ftrace_graph_ent *trace);
@@ -491,9 +494,29 @@ extern int trace_clock_id;/* Standard output formatting function used for function return traces */ #ifdef CONFIG_FUNCTION_GRAPH_TRACER -extern enum print_line_t print_graph_function (struct trace_iterator *iter); + +/* Flag options */ +#define TRACE_GRAPH_PRINT_OVERRUN 0x1 +#define TRACE_GRAPH_PRINT_CPU 0x2 +#define TRACE_GRAPH_PRINT_OVERHEAD 0x4 +#define TRACE_GRAPH_PRINT_PROC 0x8 +#define TRACE_GRAPH_PRINT_DURATION 0x10 +#define TRACE_GRAPH_PRINT_ABS_TIME 0x20 + +extern enum print_line_t +print_graph_function_flags (struct trace_iterator *iter,u32 flags); +extern void print_graph_headers_flags (struct seq_file *s,u32 flags);extern enum print_line_t trace_print_graph_duration (unsigned long long duration,struct trace_seq *s); +extern void graph_trace_open (struct trace_iterator *iter); +extern void graph_trace_close (struct trace_iterator *iter); +extern int __trace_graph_entry (struct trace_array *tr, +struct ftrace_graph_ent *trace, +unsigned long flags,int pc); +extern void __trace_graph_return (struct trace_array *tr, +struct ftrace_graph_ret *trace, +unsigned long flags,int pc); +#ifdef CONFIG_DYNAMIC_FTRACE /* TODO: make this variable */
@@ -524,7 +547,7 @@ static inline int ftrace_graph_addr(unsigned long addr)#endif /* CONFIG_DYNAMIC_FTRACE */ #else /* CONFIG_FUNCTION_GRAPH_TRACER */ static inline enum print_line_t -print_graph_function (struct trace_iterator *iter) +print_graph_function_flags (struct trace_iterator *iter,u32 flags) {return TRACE_TYPE_UNHANDLED ; }
kernel/trace/trace_functions_graph.c +108 -61
459 lines not on this page · raw message
kernel/trace/trace_irqsoff.c +260 -11
364 lines not on this page · raw message
kernel/trace/trace_output.c +1 -1
@@ -253,7 +253,7 @@ void *trace_seq_reserve(struct trace_seq *s, size_t len)void *ret;if (s->full) -return 0 ; +return NULL ;if (len > ((PAGE_SIZE -1 ) - s->len)) { s->full =1 ;
kernel/trace/trace_selftest.c +4 -3
@@ -30,7 +30,7 @@ static int trace_test_buffer_cpu(struct trace_array *tr, int cpu)struct trace_entry *entry;unsigned int loops =0 ; -while ((event =ring_buffer_consume (tr->buffer, cpu,NULL ))) { +while ((event =ring_buffer_consume (tr->buffer, cpu,NULL ,NULL ))) { entry =ring_buffer_event_data (event);/*
@@ -256,7 +256,8 @@ trace_selftest_startup_function(struct tracer *trace, struct trace_array *tr)/* Maximum number of functions to trace before diagnosing a hang */ #define GRAPH_MAX_FUNC_TEST 100000000 -static void __ftrace_dump (bool disable_tracing); +static void +__ftrace_dump (bool disable_tracing,enum ftrace_dump_mode oops_dump_mode);static unsigned int graph_hang_thresh;/* Wrap the real function entry probe to avoid possible hanging */
@@ -267,7 +268,7 @@ static int trace_graph_entry_watchdog(struct ftrace_graph_ent *trace)ftrace_graph_stop ();printk (KERN_WARNING "BUG: Function graph tracer hang!\n" );if (ftrace_dump_on_oops) -__ftrace_dump (false); +__ftrace_dump (false,DUMP_ALL );return 0 ; }