tracing: Updates for 4.3
Subsystems (9)
Steven Rostedt
maintainerLinus,
Mostly this is just clean ups and micro optimizations.
The changes with more meat are:
o Allowing the trace event filters to filter on CPU number and process ids
o Two new markers for trace output latency were added
(10 and 100 msec latencies)
o Have tracing_thresh filter function profiling time
I also worked on modifying the ring buffer code for some future work, and moved the adding of the timestamp around. One of my changes caused a regression, and since other changes were built on top of it and already tested, I had to operate a revert of that change. Instead of rebasing, this change set has the code that caused a regression as well as the code to revert that change without touching the other changes that were made on top of it.
Please pull the latest trace-v4.3 tree, which can be found at:
git://git.kernel.org/pub/scm/linux/kernel/git/rostedt/linux-trace.git
trace-v4.3
Tag SHA1: 55d8a4ef18a4afd78ab84536576c785b5712adfe Head SHA1: b7dc42fd79390c074e2bff3b172b585d5c2d80c2
Daniel Wagner (1):
tracing: Allow triggers to filter for CPU ids and process names
Gil Fruchter (2):
tracing: Prefer kcalloc over kzalloc with multiply
tracing: Fix for non-continuous cpu ids
Jungseok Lee (1):
tracing: Introduce two additional marks for delay
Minfei Huang (1):
ftrace: Format MCOUNT_ADDR address as type unsigned long
Sasha Levin (1):
tracing: Don't make assumptions about length of string on task rename
Steven Rostedt (Red Hat) (8):
ring-buffer: Add event descriptor to simplify passing data
ring-buffer: Move the adding of the extended timestamp out of line
ring-buffer: Get timestamp after event is allocated
ring-buffer: Make sure event has enough room for extend and padding
ring-buffer: Reorganize function locations
tracing: Clean up stack tracing and fix fentry updates
ftrace: Fix function_graph duration spacing with 7-digits
ring-buffer: Revert "ring-buffer: Get timestamp after event is allocated"
Umesh Tiwari (2):
ftrace: correct the counter increment for trace_buffer data
ftrace: add tracing_thresh to function profile
----
Documentation/trace/ftrace.txt | 51 ++- arch/metag/include/asm/ftrace.h | 2 +- arch/microblaze/include/asm/ftrace.h | 2 +- arch/powerpc/include/asm/ftrace.h | 2 +- arch/sh/include/asm/ftrace.h | 2 +- arch/sparc/include/asm/ftrace.h | 2 +- arch/x86/include/asm/ftrace.h | 4 +- include/trace/events/task.h | 2 +- kernel/trace/ftrace.c | 9 +- kernel/trace/ring_buffer.c | 790 ++++++++++++++++++----------------- kernel/trace/trace.c | 4 +- kernel/trace/trace_events.c | 25 ++ kernel/trace/trace_events_filter.c | 54 ++- kernel/trace/trace_functions_graph.c | 4 +- kernel/trace/trace_output.c | 4 +- kernel/trace/trace_stack.c | 68 +-- 16 files changed, 575 insertions(+), 450 deletions(-)
---------------------------
Documentation/trace/ftrace.txt +38 -13
@@ -686,6 +686,8 @@ The above is mostly meaningful for kernel developers. The marks are determined by the difference between this current trace and the next trace. '$' - greater than 1 second + '@' - greater than 100 milisecond + '*' - greater than 10 milisecond '#' - greater than 1000 microsecond '!' - greater than 100 microsecond '+' - greater than 10 microsecond
@@ -1939,26 +1941,49 @@ want, depending on your needs. ie: - 0) | up_write() { - 0) 0.646 us | _spin_lock_irqsave(); - 0) 0.684 us | _spin_unlock_irqrestore(); - 0) 3.123 us | } - 0) 0.548 us | fput(); - 0) + 58.628 us | } + 3) # 1837.709 us | } /* __switch_to */ + 3) | finish_task_switch() { + 3) 0.313 us | _raw_spin_unlock_irq(); + 3) 3.177 us | } + 3) # 1889.063 us | } /* __schedule */ + 3) ! 140.417 us | } /* __schedule */ + 3) # 2034.948 us | } /* schedule */ + 3) * 33998.59 us | } /* schedule_preempt_disabled */ [...] - 0) | putname() { - 0) | kmem_cache_free() { - 0) 0.518 us | __phys_addr(); - 0) 1.757 us | } - 0) 2.861 us | } - 0) ! 115.305 us | } - 0) ! 116.402 us | } + 1) 0.260 us | msecs_to_jiffies(); + 1) 0.313 us | __rcu_read_unlock(); + 1) + 61.770 us | } + 1) + 64.479 us | } + 1) 0.313 us | rcu_bh_qs(); + 1) 0.313 us | __local_bh_enable(); + 1) ! 217.240 us | } + 1) 0.365 us | idle_cpu(); + 1) | rcu_irq_exit() { + 1) 0.417 us | rcu_eqs_enter_common.isra.47(); + 1) 3.125 us | } + 1) ! 227.812 us | } + 1) ! 457.395 us | } + 1) @ 119760.2 us | } + + [...] + + 2) | handle_IPI() { + 1) 6.979 us | } + 2) 0.417 us | scheduler_ipi(); + 1) 9.791 us | } + 1) + 12.917 us | } + 2) 3.490 us | } + 1) + 15.729 us | } + 1) + 18.542 us | } + 2) $ 3594274 us | } + means that the function exceeded 10 usecs. ! means that the function exceeded 100 usecs. # means that the function exceeded 1000 usecs. + * means that the function exceeded 10 msecs. + @ means that the function exceeded 100 msecs. $ means that the function exceeded 1 sec.
arch/metag/include/asm/ftrace.h +1 -1
@@ -6,7 +6,7 @@#ifndef __ASSEMBLY__extern void mcount_wrapper (void ); -#define MCOUNT_ADDR ((long)(mcount_wrapper)) +#define MCOUNT_ADDR ((unsigned long)(mcount_wrapper))static inline unsigned long ftrace_call_adjust (unsigned long addr) {
arch/microblaze/include/asm/ftrace.h +1 -1
@@ -3,7 +3,7 @@#ifdef CONFIG_FUNCTION_TRACER -#define MCOUNT_ADDR ((long)(_mcount)) +#define MCOUNT_ADDR ((unsigned long)(_mcount))#define MCOUNT_INSN_SIZE 8/* sizeof mcount call */ #ifndef __ASSEMBLY__
arch/powerpc/include/asm/ftrace.h +1 -1
@@ -2,7 +2,7 @@#define _ASM_POWERPC_FTRACE#ifdef CONFIG_FUNCTION_TRACER -#define MCOUNT_ADDR ((long)(_mcount)) +#define MCOUNT_ADDR ((unsigned long)(_mcount))#define MCOUNT_INSN_SIZE 4/* sizeof mcount call */ #ifdef __ASSEMBLY__
arch/sh/include/asm/ftrace.h +1 -1
@@ -9,7 +9,7 @@#ifndef __ASSEMBLY__extern void mcount (void ); -#define MCOUNT_ADDR ((long)(mcount)) +#define MCOUNT_ADDR ((unsigned long)(mcount))#ifdef CONFIG_DYNAMIC_FTRACE #define CALL_ADDR ((long)(ftrace_call))
arch/sparc/include/asm/ftrace.h +1 -1
@@ -2,7 +2,7 @@#define _ASM_SPARC64_FTRACE#ifdef CONFIG_MCOUNT -#define MCOUNT_ADDR ((long)(_mcount)) +#define MCOUNT_ADDR ((unsigned long)(_mcount))#define MCOUNT_INSN_SIZE 4/* sizeof mcount call */ #ifndef __ASSEMBLY__
arch/x86/include/asm/ftrace.h +2 -2
@@ -3,9 +3,9 @@#ifdef CONFIG_FUNCTION_TRACER #ifdef CC_USING_FENTRY -# define MCOUNT_ADDR ((long)(__fentry__)) +# define MCOUNT_ADDR ((unsigned long)(__fentry__))#else -# define MCOUNT_ADDR ((long)(mcount)) +# define MCOUNT_ADDR ((unsigned long)(mcount))#endif #define MCOUNT_INSN_SIZE 5/* sizeof mcount call */
include/trace/events/task.h +1 -1
@@ -46,7 +46,7 @@ TRACE_EVENT(task_rename,TP_fast_assign ( __entry->pid = task->pid;memcpy (entry->oldcomm, task->comm,TASK_COMM_LEN ); -memcpy (entry->newcomm, comm,TASK_COMM_LEN ); +strlcpy (entry->newcomm, comm,TASK_COMM_LEN ); __entry->oom_score_adj = task->signal->oom_score_adj; ),
kernel/trace/ftrace.c +7 -2
@@ -613,13 +613,18 @@ static int function_stat_show(struct seq_file *m, void *v) goto out; } +#ifdef CONFIG_FUNCTION_GRAPH_TRACER + avg = rec->time; +do_div (avg, rec->counter); +if (tracing_thresh && (avg < tracing_thresh)) + goto out; +#endif +kallsyms_lookup (rec->ip,NULL ,NULL ,NULL , str);seq_printf (m," %-30.30s %10lu" , str, rec->counter);#ifdef CONFIG_FUNCTION_GRAPH_TRACER seq_puts (m," " ); - avg = rec->time; -do_div (avg, rec->counter);/* Sample standard deviation (s^2) */ if (rec->counter <=1 )
kernel/trace/ring_buffer.c +415 -375
904 lines not on this page · raw message
kernel/trace/trace.c +2 -2
@@ -3035,7 +3035,7 @@ __tracing_open(struct inode *inode, struct file *file, bool snapshot)if (!iter)return ERR_PTR (-ENOMEM ); - iter->buffer_iter =kzalloc (sizeof (*iter->buffer_iter) *num_possible_cpus (), + iter->buffer_iter =kcalloc (nr_cpu_ids,sizeof (*iter->buffer_iter),GFP_KERNEL );if (!iter->buffer_iter) goto release;
@@ -6990,7 +6990,7 @@ void ftrace_dump(enum ftrace_dump_mode oops_dump_mode)trace_init_global_iter (&iter);for_each_tracing_cpu (cpu) { -atomic_inc (&per_cpu_ptr (iter.tr->trace_buffer.data, cpu)->disabled); +atomic_inc (&per_cpu_ptr (iter.trace_buffer->data, cpu)->disabled); } old_userobj = trace_flags &TRACE_ITER_SYM_USEROBJ ;
kernel/trace/trace_events.c +25 -0
@@ -30,6 +30,7 @@DEFINE_MUTEX (event_mutex);LIST_HEAD (ftrace_events); +static LIST_HEAD (ftrace_generic_fields);static LIST_HEAD (ftrace_common_fields);#define GFP_TRACE (GFP_KERNEL | __GFP_ZERO)
@@ -94,6 +95,10 @@ trace_find_event_field(struct trace_event_call *call, char *name)struct ftrace_event_field *field;struct list_head *head; + field =__find_event_field (&ftrace_generic_fields, name); +if (field) +return field; + field =__find_event_field (&ftrace_common_fields, name);if (field)return field;
@@ -144,6 +149,13 @@ int trace_define_field(struct trace_event_call *call, const char *type, }EXPORT_SYMBOL_GPL (trace_define_field); +#define __generic_field (type, item, filter_type) \ + ret = __trace_define_field(&ftrace_generic_fields, #type, \ + #item, 0, 0, is_signed_type(type), \ + filter_type); \ + if (ret) \ + return ret; +#define __common_field (type, item) \ ret = __trace_define_field(&ftrace_common_fields, #type, \ "common_" #item, \
@@ -153,6 +165,16 @@ EXPORT_SYMBOL_GPL(trace_define_field);if (ret) \return ret; +static int trace_define_generic_fields (void ) +{ +int ret; + +__generic_field (int, cpu,FILTER_OTHER ); + __generic_field(char *, comm, FILTER_PTR_STRING); + +return ret; +} +static int trace_define_common_fields (void ) {int ret;
@@ -2671,6 +2693,9 @@ static __init int event_trace_init(void)if (!entry)pr_warn ("Could not create tracefs 'available_events' entry\n" ); +if (trace_define_generic_fields ()) +pr_warn ("tracing: Failed to allocated generic fields" ); +if (trace_define_common_fields ())pr_warn ("tracing: Failed to allocate common fields" );
kernel/trace/trace_events_filter.c +52 -2
72 lines not on this page · raw message
kernel/trace/trace_functions_graph.c +2 -2
@@ -715,13 +715,13 @@ trace_print_graph_duration(unsigned long long duration, struct trace_seq *s)snprintf (nsecs_str, slen,"%03lu" , nsecs_rem);trace_seq_printf (s,".%s" , nsecs_str); - len +=strlen (nsecs_str); + len +=strlen (nsecs_str) +1 ; }trace_seq_puts (s," us " );/* Print remaining spaces to fit the row's width */ -for (i = len; i <7 ; i++) +for (i = len; i <8 ; i++)trace_seq_putc (s,' ' ); }
kernel/trace/trace_output.c +3 -1
@@ -496,6 +496,8 @@ static const struct trace_mark {char sym; } mark[] = {MARK (1000000000ULL ,'$' ),/* 1 sec */ +MARK (100000000ULL ,'@' ),/* 100 msec */ +MARK (10000000ULL ,'*' ),/* 10 msec */ MARK (1000000ULL ,'#' ),/* 1000 usecs */ MARK (100000ULL ,'!' ),/* 100 usecs */ MARK(10000ULL , '+'), /* 10 usecs */
@@ -508,7 +510,7 @@ char trace_find_mark(unsigned long long d)int size =ARRAY_SIZE (mark);for (i =0 ; i < size; i++) { -if (d >= mark[i].val) +if (d > mark[i].val)break ; }
kernel/trace/trace_stack.c +23 -45
145 lines not on this page · raw message