diff options
Diffstat (limited to 'kernel/trace/trace.c')
-rw-r--r-- | kernel/trace/trace.c | 42 |
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 | ||
3598 | static ssize_t | ||
3599 | tracing_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 | |||
3632 | static 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 | ||
3600 | int __weak ftrace_arch_read_dyn_info(char *buf, int size) | 3639 | int __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 |