tracing: Updates for v3.20
Subsystems (4)
Steven Rostedt
maintainerLinus,
The updates included in this pull request for ftrace are:
o Several clean ups to the code
One such clean up was to convert to 64 bit time keeping, in the ring buffer benchmark code.
o Adding of __print_array() helper macro for TRACE_EVENT()
o Updating the sample/trace_events/ to add samples of different ways to make trace events. Lots of features have been added since the sample code was made, and these features are mostly unknown. Developers have been making their own hacks to do things that are already available.
o Performance improvements. Most notably, I found a performance bug where a waiter that is waiting for a full page from the ring buffer will see that a full page is not available, and go to sleep. The sched event caused by it going to sleep would cause it to wake up again. It would see that there was still not a full page, and go back to sleep again, and that would wake it up again, until finally it would see a full page. This change has been marked for stable.
Other improvements include removing global locks from fast paths.
Please pull the latest trace-v3.20 tree, which can be found at:
git://git.kernel.org/pub/scm/linux/kernel/git/rostedt/linux-trace.git
trace-v3.20
Tag SHA1: 56e66bdd5fddd1855565449266b5eb1646afed7f Head SHA1: 1e0d6714aceb770b04161fbedd7765d0e1fc27bd
Borislav Petkov (1):
tracing: Remove newline from trace_printk warning banner
Dave Martin (1):
tracing: Add array printing helper
Steven Rostedt (Red Hat) (11):
tracing: Add ref count to tracer for when they are being read by pipe
tracing: Remove taking of trace_types_lock in pipe files
tracing: Remove unneeded includes of debugfs.h and fs.h
tracing: Use IS_ERR() check for return value of tracing_init_dentry()
tracing: Make tracing_init_dentry_tr() static
tracing: Separate out initializing top level dir from instances
tracing: Update the TRACE_EVENT fields available in the sample code
tracing: Add TRACE_EVENT_CONDITION sample
tracing: Add TRACE_EVENT_FN example
tracing: Add samples of DECLARE_EVENT_CLASS() and DEFINE_EVENT()
ring-buffer: Do not wake up a splice waiter when page is not full
Tina Ruchandani (1):
trace: Use 64-bit timekeeping
Vikram Mulukutla (1):
tracing: Fix unmapping loop in tracing_mark_write
----
include/linux/ftrace_event.h | 4 + include/trace/ftrace.h | 9 + kernel/trace/ftrace.c | 2 +- kernel/trace/ring_buffer.c | 42 +++- kernel/trace/ring_buffer_benchmark.c | 18 +- kernel/trace/trace.c | 188 +++++++---------- kernel/trace/trace.h | 2 +- kernel/trace/trace_branch.c | 1 - kernel/trace/trace_events.c | 2 +- kernel/trace/trace_export.c | 2 - kernel/trace/trace_functions_graph.c | 2 +- kernel/trace/trace_irqsoff.c | 2 - kernel/trace/trace_kprobe.c | 2 +- kernel/trace/trace_nop.c | 2 - kernel/trace/trace_output.c | 44 ++++ kernel/trace/trace_printk.c | 4 +- kernel/trace/trace_sched_switch.c | 2 - kernel/trace/trace_sched_wakeup.c | 2 - kernel/trace/trace_stack.c | 4 +- kernel/trace/trace_stat.c | 2 +- kernel/trace/trace_uprobe.c | 2 +- samples/trace_events/trace-events-sample.c | 80 ++++++- samples/trace_events/trace-events-sample.h | 328 +++++++++++++++++++++++++++-- 23 files changed, 582 insertions(+), 164 deletions(-)
---------------------------
include/linux/ftrace_event.h +4 -0
@@ -44,6 +44,10 @@ const char *ftrace_print_bitmask_seq(struct trace_seq *p, void *bitmask_ptr,const char *ftrace_print_hex_seq (struct trace_seq *p,const unsigned char *buf,int len); +const char *ftrace_print_array_seq (struct trace_seq *p, +const void *buf,int buf_len, +size_t el_size); +struct trace_iterator ;struct trace_event ;
include/trace/ftrace.h +9 -0
@@ -263,6 +263,14 @@#undef __print_hex#define __print_hex (buf, buf_len) ftrace_print_hex_seq(p, buf, buf_len) +#undef __print_array +#define __print_array (array, count, el_size) \ + ({ \ + BUILD_BUG_ON(el_size != 1 && el_size != 2 && \ + el_size != 4 && el_size != 8); \ + ftrace_print_array_seq(p, array, count, el_size); \ + }) +#undef DECLARE_EVENT_CLASS#define DECLARE_EVENT_CLASS (call, proto, args, tstruct, assign, print) \ static notrace enum print_line_t \
@@ -674,6 +682,7 @@ static inline void ftrace_test_probe_##call(void) \#undef __get_dynamic_array_len#undef __get_str#undef __get_bitmask +#undef __print_array#undef TP_printk #define TP_printk(fmt, args...) "\"" fmt "\", " __stringify(args)
kernel/trace/ftrace.c +1 -1
@@ -5419,7 +5419,7 @@ static __init int ftrace_init_debugfs(void)struct dentry *d_tracer; d_tracer =tracing_init_dentry (); -if (!d_tracer) +if (IS_ERR (d_tracer))return 0 ;ftrace_init_dyn_debugfs (d_tracer);
kernel/trace/ring_buffer.c +35 -7
110 lines not on this page · raw message
kernel/trace/ring_buffer_benchmark.c +8 -10
@@ -7,7 +7,7 @@#include <linux/completion.h> #include <linux/kthread.h> #include <linux/module.h> -#include <linux/time.h> +#include <linux/ktime.h> #include <asm/local.h> struct rb_page {
@@ -17,7 +17,7 @@ struct rb_page { };/* run time and sleep time in seconds */ -#define RUN_TIME 10 +#define RUN_TIME 10ULL#define SLEEP_TIME 10/* number of events for writer to wake up the reader */
@@ -212,8 +212,7 @@ static void ring_buffer_consumer(void)static void ring_buffer_producer (void ) { -struct timeval start_tv; -struct timeval end_tv; +ktime_t start_time, end_time, timeout;unsigned long long time;unsigned long long entries;unsigned long long overruns;
@@ -227,7 +226,8 @@ static void ring_buffer_producer(void)* make the system stall) */ trace_printk ("Starting ring buffer hammer\n" ); -do_gettimeofday (&start_tv); + start_time =ktime_get (); + timeout =ktime_add_ns (start_time,RUN_TIME *NSEC_PER_SEC ); do { struct ring_buffer_event *event; int *entry;
@@ -244,7 +244,7 @@ static void ring_buffer_producer(void)ring_buffer_unlock_commit (buffer, event); } } -do_gettimeofday (&end_tv); + end_time =ktime_get (); cnt++;if (consumer && !(cnt % wakeup_interval))
@@ -264,7 +264,7 @@ static void ring_buffer_producer(void)cond_resched ();#endif - }while (end_tv.tv_sec < (start_tv.tv_sec +RUN_TIME ) && !kill_test); + }while (ktime_before (end_time, timeout) && !kill_test);trace_printk ("End ring buffer hammer\n" );if (consumer) {
@@ -280,9 +280,7 @@ static void ring_buffer_producer(void)wait_for_completion (&read_done); } - time = end_tv.tv_sec - start_tv.tv_sec; - time *=USEC_PER_SEC ; - time += (long long )((long )end_tv.tv_usec - (long )start_tv.tv_usec); + time =ktime_us_delta (end_time, start_time); entries =ring_buffer_entries (buffer); overruns =ring_buffer_overruns (buffer);
kernel/trace/trace.c +79 -109
378 lines not on this page · raw message
kernel/trace/trace.h +1 -1
@@ -388,6 +388,7 @@ struct tracer {struct tracer *next;struct tracer_flags *flags;int enabled; +int ref;bool print_max;bool allow_instances;#ifdef CONFIG_TRACER_MAX_TRACE
@@ -541,7 +542,6 @@ struct dentry *trace_create_file(const char *name,void *data, const struct file_operations *fops); -struct dentry *tracing_init_dentry_tr (struct trace_array *tr);struct dentry *tracing_init_dentry (void );struct ring_buffer_event ;
kernel/trace/trace_branch.c +0 -1
@@ -7,7 +7,6 @@#include <linux/seq_file.h> #include <linux/spinlock.h> #include <linux/irqflags.h> -#include <linux/debugfs.h> #include <linux/uaccess.h> #include <linux/module.h> #include <linux/ftrace.h>
kernel/trace/trace_events.c +1 -1
@@ -2490,7 +2490,7 @@ static __init int event_trace_init(void)return -ENODEV ; d_tracer =tracing_init_dentry (); -if (!d_tracer) +if (IS_ERR (d_tracer))return 0 ; entry = debugfs_create_file("available_events", 0444, d_tracer,
kernel/trace/trace_export.c +0 -2
@@ -6,12 +6,10 @@#include <linux/stringify.h> #include <linux/kallsyms.h> #include <linux/seq_file.h> -#include <linux/debugfs.h> #include <linux/uaccess.h> #include <linux/ftrace.h> #include <linux/module.h> #include <linux/init.h> -#include <linux/fs.h> #include "trace_output.h"
kernel/trace/trace_functions_graph.c +1 -1
@@ -1437,7 +1437,7 @@ static __init int init_graph_debugfs(void)struct dentry *d_tracer; d_tracer =tracing_init_dentry (); -if (!d_tracer) +if (IS_ERR (d_tracer))return 0 ; trace_create_file("max_graph_depth", 0644, d_tracer,
kernel/trace/trace_irqsoff.c +0 -2
@@ -10,11 +10,9 @@* Copyright (C) 2004 Nadia Yvette Chambers */ #include <linux/kallsyms.h> -#include <linux/debugfs.h> #include <linux/uaccess.h> #include <linux/module.h> #include <linux/ftrace.h> -#include <linux/fs.h> #include "trace.h"
kernel/trace/trace_kprobe.c +1 -1
@@ -1320,7 +1320,7 @@ static __init int init_kprobe_trace(void)return -EINVAL ; d_tracer =tracing_init_dentry (); -if (!d_tracer) +if (IS_ERR (d_tracer))return 0 ; entry = debugfs_create_file("kprobe_events", 0644, d_tracer,
kernel/trace/trace_nop.c +0 -2
@@ -6,8 +6,6 @@*/ #include <linux/module.h> -#include <linux/fs.h> -#include <linux/debugfs.h> #include <linux/ftrace.h> #include "trace.h"
kernel/trace/trace_output.c +44 -0
50 lines not on this page · raw message
kernel/trace/trace_printk.c +1 -3
@@ -5,7 +5,6 @@* */ #include <linux/seq_file.h> -#include <linux/debugfs.h> #include <linux/uaccess.h> #include <linux/kernel.h> #include <linux/ftrace.h>
@@ -15,7 +14,6 @@#include <linux/ctype.h> #include <linux/list.h> #include <linux/slab.h> -#include <linux/fs.h> #include "trace.h"
@@ -349,7 +347,7 @@ static __init int init_trace_printk_function_export(void)struct dentry *d_tracer; d_tracer =tracing_init_dentry (); -if (!d_tracer) +if (IS_ERR (d_tracer))return 0 ; trace_create_file("printk_formats", 0444, d_tracer,
kernel/trace/trace_sched_switch.c +0 -2
@@ -5,8 +5,6 @@* */ #include <linux/module.h> -#include <linux/fs.h> -#include <linux/debugfs.h> #include <linux/kallsyms.h> #include <linux/uaccess.h> #include <linux/ftrace.h>
kernel/trace/trace_sched_wakeup.c +0 -2
@@ -10,8 +10,6 @@* Copyright (C) 2004 Nadia Yvette Chambers */ #include <linux/module.h> -#include <linux/fs.h> -#include <linux/debugfs.h> #include <linux/kallsyms.h> #include <linux/uaccess.h> #include <linux/ftrace.h>
kernel/trace/trace_stack.c +1 -3
@@ -7,12 +7,10 @@#include <linux/seq_file.h> #include <linux/spinlock.h> #include <linux/uaccess.h> -#include <linux/debugfs.h> #include <linux/ftrace.h> #include <linux/module.h> #include <linux/sysctl.h> #include <linux/init.h> -#include <linux/fs.h> #include <asm/setup.h>
@@ -462,7 +460,7 @@ static __init int stack_trace_init(void)struct dentry *d_tracer; d_tracer =tracing_init_dentry (); -if (!d_tracer) +if (IS_ERR (d_tracer))return 0 ; trace_create_file("stack_max_size", 0644, d_tracer,
kernel/trace/trace_stat.c +1 -1
@@ -276,7 +276,7 @@ static int tracing_stat_init(void)struct dentry *d_tracing; d_tracing =tracing_init_dentry (); -if (!d_tracing) +if (IS_ERR (d_tracing))return 0 ; stat_dir =debugfs_create_dir ("trace_stat" , d_tracing);
kernel/trace/trace_uprobe.c +1 -1
@@ -1321,7 +1321,7 @@ static __init int init_uprobe_trace(void)struct dentry *d_tracer; d_tracer =tracing_init_dentry (); -if (!d_tracer) +if (IS_ERR (d_tracer))return 0 ; trace_create_file("uprobe_events", 0644, d_tracer,
samples/trace_events/trace-events-sample.c +79 -1
103 lines not on this page · raw message
samples/trace_events/trace-events-sample.h +315 -13
366 lines not on this page · raw message