tracing fixes
Subsystems (5)
Linus,
Please pull the latest tracing-fixes-for-linus git tree from:
git://git.kernel.org/pub/scm/linux/kernel/git/tip/linux-2.6-tip.git tracing-fixes-for-linus
Thanks,
Ingo
------------------>
Joe Perches (1):
ftrace.h: Use common pr_info fmt string
Li Zefan (13):
tracing: Extract duplicate ftrace_raw_init_event_foo()
tracing: Pull up calls to trace_define_common_fields()
tracing: Move a printk out of ftrace_raw_reg_event_foo()
ftrace: Return EINVAL when writing invalid val to set_ftrace_filter
ftrace: Call trace_parser_clear() properly
function-graph: Allow writing the same val to set_graph_function
tracing: Use seq file for trace_options
tracing: Use seq file for trace_clock
tracing: Remove useless trace option
tracing: Simplify trace_option_write()
tracing: Change event->profile_count to be int type tracing/power: Remove two exports
ksym_tracer: Fix bad cast
Steven Rostedt (5):
ring-buffer: Use sync sched protection on ring buffer resizing
ring-buffer: Move resize integrity check under reader lock
tracing: Add trace_dump_stack()
tracing: Add stack trace to irqsoff tracer
tracing: Fix return of trace_dump_stack()
Thomas Gleixner (1):
tracing: Fix wrong usage of strstrip in trace_ksyms
include/linux/ftrace_event.h | 4 +- include/linux/kernel.h | 3 + include/linux/syscalls.h | 6 +- include/trace/ftrace.h | 56 +---------- kernel/trace/ftrace.c | 30 ++++-- kernel/trace/power-traces.c | 2 - kernel/trace/ring_buffer.c | 29 ++---- kernel/trace/trace.c | 182 +++++++++++++++--------------------- kernel/trace/trace.h | 23 ++--- kernel/trace/trace_event_profile.c | 6 +- kernel/trace/trace_events.c | 41 +++++++-- kernel/trace/trace_export.c | 4 - kernel/trace/trace_irqsoff.c | 2 + kernel/trace/trace_kprobe.c | 9 -- kernel/trace/trace_ksym.c | 56 +++++------ kernel/trace/trace_syscalls.c | 18 +--- 16 files changed, 196 insertions(+), 275 deletions(-)
include/linux/ftrace_event.h +2 -2
@@ -131,7 +131,7 @@ struct ftrace_event_call {void *mod;void *data; -atomic_t profile_count; +int profile_count;int (*profile_enable)(struct ftrace_event_call *);void (*profile_disable)(struct ftrace_event_call *); };
@@ -158,7 +158,7 @@ enum { FILTER_PTR_STRING, }; -extern int trace_define_common_fields (struct ftrace_event_call *call); +extern int trace_event_raw_init (struct ftrace_event_call *call);extern int trace_define_field (struct ftrace_event_call *call,const char *type,const char *name,int offset,int size,int is_signed,int filter_type);
include/linux/kernel.h +3 -0
@@ -492,6 +492,8 @@ extern int __trace_printk(unsigned long ip, const char *fmt, ...) __attribute__ ((format (printf, 2, 3))); +extern void trace_dump_stack (void ); +/* * The double __builtin_constant_p is because gcc will give us an error * if we try to allocate the static variable to fmt if it is not a
@@ -525,6 +527,7 @@ trace_printk(const char *fmt, ...) __attribute__ ((format (printf, 1, 2)));static inline void tracing_start (void ) { }static inline void tracing_stop (void ) { }static inline void ftrace_off_permanent (void ) { } +static inline void trace_dump_stack (void ) { }static inline int trace_printk (const char *fmt, ...) {
include/linux/syscalls.h +2 -4
@@ -102,12 +102,10 @@ struct perf_event_attr;#ifdef CONFIG_EVENT_PROFILE #define TRACE_SYS_ENTER_PROFILE_INIT (sname) \ - .profile_count = ATOMIC_INIT(-1), \ .profile_enable = prof_sysenter_enable, \ .profile_disable = prof_sysenter_disable,#define TRACE_SYS_EXIT_PROFILE_INIT (sname) \ - .profile_count = ATOMIC_INIT(-1), \ .profile_enable = prof_sysexit_enable, \ .profile_disable = prof_sysexit_disable,#else
@@ -145,7 +143,7 @@ struct perf_event_attr; .name = "sys_enter"#sname, \ .system = "syscalls", \ .event = &enter_syscall_print_##sname, \ - .raw_init = init_syscall_trace, \ + .raw_init = trace_event_raw_init, \ .show_format = syscall_enter_format, \ .define_fields = syscall_enter_define_fields, \ .regfunc = reg_event_syscall_enter, \
@@ -167,7 +165,7 @@ struct perf_event_attr; .name = "sys_exit"#sname, \ .system = "syscalls", \ .event = &exit_syscall_print_##sname, \ - .raw_init = init_syscall_trace, \ + .raw_init = trace_event_raw_init, \ .show_format = syscall_exit_format, \ .define_fields = syscall_exit_define_fields, \ .regfunc = reg_event_syscall_exit, \
include/trace/ftrace.h +6 -50
118 lines not on this page · raw message
kernel/trace/ftrace.c +19 -11
@@ -1724,7 +1724,7 @@ ftrace_match_record(struct dyn_ftrace *rec, char *regex, int len, int type)return ftrace_match (str, regex, len, type); } -static void ftrace_match_records (char *buff,int len,int enable) +static int ftrace_match_records (char *buff,int len,int enable) {unsigned int search_len;struct ftrace_page *pg;
@@ -1733,6 +1733,7 @@ static void ftrace_match_records(char *buff, int len, int enable)char *search;int type;int not; +int found =0 ; flag = enable ?FTRACE_FL_FILTER :FTRACE_FL_NOTRACE ; type =filter_parse_regex (buff, len, &search, ¬);
@@ -1750,6 +1751,7 @@ static void ftrace_match_records(char *buff, int len, int enable) rec->flags &= ~flag; else rec->flags |= flag; + found =1 ; }/* * Only enable filtering if we have a function that
@@ -1759,6 +1761,8 @@ static void ftrace_match_records(char *buff, int len, int enable) ftrace_filtered =1 ; }while_for_each_ftrace_rec ();mutex_unlock (&ftrace_lock); + +return found; } static int
@@ -1780,7 +1784,7 @@ ftrace_match_module_record(struct dyn_ftrace *rec, char *mod,return 1 ; } -static void ftrace_match_module_records (char *buff,char *mod,int enable) +static int ftrace_match_module_records (char *buff,char *mod,int enable) {unsigned search_len =0 ;struct ftrace_page *pg;
@@ -1789,6 +1793,7 @@ static void ftrace_match_module_records(char *buff, char *mod, int enable)char *search = buff;unsigned long flag;int not =0 ; +int found =0 ; flag = enable ?FTRACE_FL_FILTER :FTRACE_FL_NOTRACE ;
@@ -1819,12 +1824,15 @@ static void ftrace_match_module_records(char *buff, char *mod, int enable) rec->flags &= ~flag; else rec->flags |= flag; + found =1 ; }if (enable && (rec->flags &FTRACE_FL_FILTER )) ftrace_filtered =1 ; }while_for_each_ftrace_rec ();mutex_unlock (&ftrace_lock); + +return found; }/*
@@ -1853,8 +1861,9 @@ ftrace_mod_callback(char *func, char *cmd, char *param, int enable)if (!strlen (mod))return -EINVAL ; -ftrace_match_module_records (func, mod, enable); -return 0 ; +if (ftrace_match_module_records (func, mod, enable)) +return 0 ; +return -EINVAL ; }static struct ftrace_func_command ftrace_mod_cmd = {
@@ -2151,8 +2160,9 @@ static int ftrace_process_regex(char *buff, int len, int enable) func =strsep (&next,":" );if (!next) { -ftrace_match_records (func, len, enable); -return 0 ; +if (ftrace_match_records (func, len, enable)) +return 0 ; +return ret; }/* command found */
@@ -2198,10 +2208,9 @@ ftrace_regex_write(struct file *file, const char __user *ubuf, !trace_parser_cont(parser)) { ret =ftrace_process_regex (parser->buffer, parser->idx, enable); +trace_parser_clear (parser);if (ret) goto out_unlock; - -trace_parser_clear (parser); } ret = read;
@@ -2543,10 +2552,9 @@ ftrace_set_func(unsigned long *array, int *idx, char *buffer) exists = true;break ; } -if (!exists) { +if (!exists) array[(*idx)++] = rec->ip; - found =1 ; - } + found =1 ; } }while_for_each_ftrace_rec ();
kernel/trace/power-traces.c +0 -2
@@ -14,7 +14,5 @@#define CREATE_TRACE_POINTS #include <trace/events/power.h> -EXPORT_TRACEPOINT_SYMBOL_GPL (power_start); -EXPORT_TRACEPOINT_SYMBOL_GPL (power_end);EXPORT_TRACEPOINT_SYMBOL_GPL (power_frequency);
kernel/trace/ring_buffer.c +11 -18
@@ -1193,9 +1193,6 @@ rb_remove_pages(struct ring_buffer_per_cpu *cpu_buffer, unsigned nr_pages)struct list_head *p;unsigned i; -atomic_inc (&cpu_buffer->record_disabled); -synchronize_sched (); -spin_lock_irq (&cpu_buffer->reader_lock);rb_head_page_deactivate (cpu_buffer);
@@ -1211,12 +1208,9 @@ rb_remove_pages(struct ring_buffer_per_cpu *cpu_buffer, unsigned nr_pages)return ;rb_reset_cpu (cpu_buffer); -spin_unlock_irq (&cpu_buffer->reader_lock); -rb_check_pages (cpu_buffer); -atomic_dec (&cpu_buffer->record_disabled); - +spin_unlock_irq (&cpu_buffer->reader_lock); } static void
@@ -1227,9 +1221,6 @@ rb_insert_pages(struct ring_buffer_per_cpu *cpu_buffer,struct list_head *p;unsigned i; -atomic_inc (&cpu_buffer->record_disabled); -synchronize_sched (); -spin_lock_irq (&cpu_buffer->reader_lock);rb_head_page_deactivate (cpu_buffer);
@@ -1242,11 +1233,9 @@ rb_insert_pages(struct ring_buffer_per_cpu *cpu_buffer,list_add_tail (&bpage->list, cpu_buffer->pages); }rb_reset_cpu (cpu_buffer); -spin_unlock_irq (&cpu_buffer->reader_lock); -rb_check_pages (cpu_buffer); -atomic_dec (&cpu_buffer->record_disabled); +spin_unlock_irq (&cpu_buffer->reader_lock); }/**
@@ -1254,11 +1243,6 @@ rb_insert_pages(struct ring_buffer_per_cpu *cpu_buffer,* @buffer: the buffer to resize. * @size: the new size. * -* The tracer is responsible for making sure that the buffer is -* not being used while changing the size. -* Note: We may be able to change the above requirement by using -* RCU synchronizations. -* * Minimum size is 2 * BUF_PAGE_SIZE. * * Returns -1 on failure.
@@ -1290,6 +1274,11 @@ int ring_buffer_resize(struct ring_buffer *buffer, unsigned long size)if (size == buffer_size)return size; +atomic_inc (&buffer->record_disabled); + +/* Make sure all writers are done with this buffer. */ +synchronize_sched (); +mutex_lock (&buffer->mutex);get_online_cpus ();
@@ -1352,6 +1341,8 @@ int ring_buffer_resize(struct ring_buffer *buffer, unsigned long size)put_online_cpus ();mutex_unlock (&buffer->mutex); +atomic_dec (&buffer->record_disabled); +return size; free_pages:
@@ -1361,6 +1352,7 @@ int ring_buffer_resize(struct ring_buffer *buffer, unsigned long size) }put_online_cpus ();mutex_unlock (&buffer->mutex); +atomic_dec (&buffer->record_disabled);return -ENOMEM ;/*
@@ -1370,6 +1362,7 @@ int ring_buffer_resize(struct ring_buffer *buffer, unsigned long size) out_fail:put_online_cpus ();mutex_unlock (&buffer->mutex); +atomic_dec (&buffer->record_disabled);return -1 ; }EXPORT_SYMBOL_GPL (ring_buffer_resize);
kernel/trace/trace.c +77 -105
296 lines not on this page · raw message
kernel/trace/trace.h +11 -12
@@ -597,18 +597,17 @@ enum trace_iterator_flags {TRACE_ITER_BIN =0x40 ,TRACE_ITER_BLOCK =0x80 ,TRACE_ITER_STACKTRACE =0x100 , -TRACE_ITER_SCHED_TREE =0x200 , -TRACE_ITER_PRINTK =0x400 , -TRACE_ITER_PREEMPTONLY =0x800 , -TRACE_ITER_BRANCH =0x1000 , -TRACE_ITER_ANNOTATE =0x2000 , -TRACE_ITER_USERSTACKTRACE =0x4000 , -TRACE_ITER_SYM_USEROBJ =0x8000 , -TRACE_ITER_PRINTK_MSGONLY =0x10000 , -TRACE_ITER_CONTEXT_INFO =0x20000 ,/* Print pid/cpu/time */ -TRACE_ITER_LATENCY_FMT =0x40000 , -TRACE_ITER_SLEEP_TIME =0x80000 , - TRACE_ITER_GRAPH_TIME = 0x100000, +TRACE_ITER_PRINTK =0x200 , +TRACE_ITER_PREEMPTONLY =0x400 , +TRACE_ITER_BRANCH =0x800 , +TRACE_ITER_ANNOTATE =0x1000 , +TRACE_ITER_USERSTACKTRACE =0x2000 , +TRACE_ITER_SYM_USEROBJ =0x4000 , +TRACE_ITER_PRINTK_MSGONLY =0x8000 , +TRACE_ITER_CONTEXT_INFO =0x10000 ,/* Print pid/cpu/time */ +TRACE_ITER_LATENCY_FMT =0x20000 , +TRACE_ITER_SLEEP_TIME =0x40000 , + TRACE_ITER_GRAPH_TIME = 0x80000, };/*
kernel/trace/trace_event_profile.c +3 -3
@@ -25,7 +25,7 @@ static int ftrace_profile_enable_event(struct ftrace_event_call *event)char *buf;int ret = -ENOMEM ; -if (atomic_inc_return (&event->profile_count)) +if (event->profile_count++ >0 )return 0 ;if (!total_profile_count) {
@@ -56,7 +56,7 @@ fail_buf_nmi: perf_trace_buf =NULL ; } fail_buf: -atomic_dec (&event->profile_count); + event->profile_count--;return ret; }
@@ -83,7 +83,7 @@ static void ftrace_profile_disable_event(struct ftrace_event_call *event) {char *buf, *nmi_buf; -if (!atomic_add_negative (-1 , &event->profile_count)) +if (--event->profile_count >0 )return ; event->profile_disable (event);
kernel/trace/trace_events.c +33 -8
89 lines not on this page · raw message
kernel/trace/trace_export.c +0 -4
@@ -184,10 +184,6 @@ ftrace_define_fields_##name(struct ftrace_event_call *event_call) \struct struct_name field; \int ret; \ \ - ret =trace_define_common_fields (event_call); \ -if (ret) \ -return ret; \ - \ tstruct; \ \return ret; \
kernel/trace/trace_irqsoff.c +2 -0
@@ -151,6 +151,8 @@ check_critical_timing(struct trace_array *tr, goto out_unlock;trace_function (tr,CALLER_ADDR0 , parent_ip, flags, pc); +/* Skip 5 functions to get to the irq/preempt enable function */ +__trace_stack (tr, flags,5 , pc);if (data->critical_sequence != max_sequence) goto out_unlock;
kernel/trace/trace_kprobe.c +0 -9
@@ -1132,10 +1132,6 @@ static int kprobe_event_define_fields(struct ftrace_event_call *event_call)struct kprobe_trace_entry field;struct trace_probe *tp = (struct trace_probe *)event_call->data; - ret =trace_define_common_fields (event_call); -if (ret) -return ret; - DEFINE_FIELD(unsigned long, ip, FIELD_STRING_IP, 0);DEFINE_FIELD (int, nargs,FIELD_STRING_NARGS ,1 );/* Set argument names as fields */
@@ -1150,10 +1146,6 @@ static int kretprobe_event_define_fields(struct ftrace_event_call *event_call)struct kretprobe_trace_entry field;struct trace_probe *tp = (struct trace_probe *)event_call->data; - ret =trace_define_common_fields (event_call); -if (ret) -return ret; - DEFINE_FIELD(unsigned long, func, FIELD_STRING_FUNC, 0); DEFINE_FIELD(unsigned long, ret_ip, FIELD_STRING_RETIP, 0);DEFINE_FIELD (int, nargs,FIELD_STRING_NARGS ,1 );
@@ -1453,7 +1445,6 @@ static int register_probe_event(struct trace_probe *tp) call->unregfunc = probe_event_disable;#ifdef CONFIG_EVENT_PROFILE -atomic_set (&call->profile_count,-1 ); call->profile_enable = probe_profile_enable; call->profile_disable = probe_profile_disable;#endif
kernel/trace/trace_ksym.c +25 -31
106 lines not on this page · raw message
kernel/trace/trace_syscalls.c +2 -16
@@ -217,10 +217,6 @@ int syscall_enter_define_fields(struct ftrace_event_call *call)int i;int offset = offsetof(typeof (trace ), args); - ret =trace_define_common_fields (call); -if (ret) -return ret; - ret =trace_define_field (call,SYSCALL_FIELD (int, nr),FILTER_OTHER );if (ret)return ret;
@@ -241,10 +237,6 @@ int syscall_exit_define_fields(struct ftrace_event_call *call)struct syscall_trace_exit trace;int ret; - ret =trace_define_common_fields (call); -if (ret) -return ret; - ret =trace_define_field (call,SYSCALL_FIELD (int, nr),FILTER_OTHER );if (ret)return ret;
@@ -333,10 +325,7 @@ int reg_event_syscall_enter(struct ftrace_event_call *call)mutex_lock (&syscall_trace_lock);if (!sys_refcount_enter) ret =register_trace_sys_enter (ftrace_syscall_enter); -if (ret) { -pr_info ("event trace: Could not activate" -"syscall entry trace point" ); - }else { +if (!ret) {set_bit (num, enabled_enter_syscalls); sys_refcount_enter++; }
@@ -370,10 +359,7 @@ int reg_event_syscall_exit(struct ftrace_event_call *call)mutex_lock (&syscall_trace_lock);if (!sys_refcount_exit) ret =register_trace_sys_exit (ftrace_syscall_exit); -if (ret) { -pr_info ("event trace: Could not activate" -"syscall exit trace point" ); - }else { +if (!ret) {set_bit (num, enabled_exit_syscalls); sys_refcount_exit++; }