aboutsummaryrefslogtreecommitdiffstats
path: root/kernel/trace/trace.c
diff options
context:
space:
mode:
authorSteven Rostedt <srostedt@redhat.com>2009-04-29 18:03:45 -0400
committerSteven Rostedt <rostedt@goodmis.org>2009-05-05 13:52:02 -0400
commitc8d771835e18c938dae8690611d65fe98ad30f58 (patch)
tree6c8ba52ab340e574c21418866bd985d55ab771e9 /kernel/trace/trace.c
parentf0d2c681ac0a85142fc8abe65fc33fcad35cb9b7 (diff)
tracing: export stats of ring buffers to userspace
This patch adds stats to the ftrace ring buffers: # cat /debugfs/tracing/per_cpu/cpu0/stats entries: 42360 overrun: 30509326 commit overrun: 0 nmi dropped: 0 Where entries are the total number of data entries in the buffer. overrun is the number of entries not consumed and were overwritten by the writer. commit overrun is the number of entries dropped due to nested writers wrapping the buffer before the initial writer finished the commit. nmi dropped is the number of entries dropped due to the ring buffer lock being held when an nmi was going to write to the ring buffer. Note, this field will be meaningless and will go away when the ring buffer becomes lockless. [ Impact: let userspace know what is happening in the ring buffers ] Signed-off-by: Steven Rostedt <rostedt@goodmis.org>
Diffstat (limited to 'kernel/trace/trace.c')
-rw-r--r--kernel/trace/trace.c42
1 files changed, 42 insertions, 0 deletions
diff --git a/kernel/trace/trace.c b/kernel/trace/trace.c
index f5427e0fc982..74df029056b0 100644
--- a/kernel/trace/trace.c
+++ b/kernel/trace/trace.c
@@ -3595,6 +3595,45 @@ static const struct file_operations tracing_buffers_fops = {
3595 .llseek = no_llseek, 3595 .llseek = no_llseek,
3596}; 3596};
3597 3597
3598static ssize_t
3599tracing_stats_read(struct file *filp, char __user *ubuf,
3600 size_t count, loff_t *ppos)
3601{
3602 unsigned long cpu = (unsigned long)filp->private_data;
3603 struct trace_array *tr = &global_trace;
3604 struct trace_seq *s;
3605 unsigned long cnt;
3606
3607 s = kmalloc(sizeof(*s), GFP_ATOMIC);
3608 if (!s)
3609 return ENOMEM;
3610
3611 trace_seq_init(s);
3612
3613 cnt = ring_buffer_entries_cpu(tr->buffer, cpu);
3614 trace_seq_printf(s, "entries: %ld\n", cnt);
3615
3616 cnt = ring_buffer_overrun_cpu(tr->buffer, cpu);
3617 trace_seq_printf(s, "overrun: %ld\n", cnt);
3618
3619 cnt = ring_buffer_commit_overrun_cpu(tr->buffer, cpu);
3620 trace_seq_printf(s, "commit overrun: %ld\n", cnt);
3621
3622 cnt = ring_buffer_nmi_dropped_cpu(tr->buffer, cpu);
3623 trace_seq_printf(s, "nmi dropped: %ld\n", cnt);
3624
3625 count = simple_read_from_buffer(ubuf, count, ppos, s->buffer, s->len);
3626
3627 kfree(s);
3628
3629 return count;
3630}
3631
3632static const struct file_operations tracing_stats_fops = {
3633 .open = tracing_open_generic,
3634 .read = tracing_stats_read,
3635};
3636
3598#ifdef CONFIG_DYNAMIC_FTRACE 3637#ifdef CONFIG_DYNAMIC_FTRACE
3599 3638
3600int __weak ftrace_arch_read_dyn_info(char *buf, int size) 3639int __weak ftrace_arch_read_dyn_info(char *buf, int size)
@@ -3708,6 +3747,9 @@ static void tracing_init_debugfs_percpu(long cpu)
3708 3747
3709 trace_create_file("trace_pipe_raw", 0444, d_cpu, 3748 trace_create_file("trace_pipe_raw", 0444, d_cpu,
3710 (void *) cpu, &tracing_buffers_fops); 3749 (void *) cpu, &tracing_buffers_fops);
3750
3751 trace_create_file("stats", 0444, d_cpu,
3752 (void *) cpu, &tracing_stats_fops);
3711} 3753}
3712 3754
3713#ifdef CONFIG_FTRACE_SELFTEST 3755#ifdef CONFIG_FTRACE_SELFTEST