diff options
author | Vaibhav Nagarnaik <vnagarnaik@google.com> | 2011-08-16 17:46:15 -0400 |
---|---|---|
committer | Steven Rostedt <rostedt@goodmis.org> | 2011-08-30 12:27:44 -0400 |
commit | f81ab074c30234b07c8309c542cafd07bed721f7 (patch) | |
tree | 58ec049e4f63d0f8a0b696195cf77da2b6d04b01 /kernel/trace | |
parent | 86b6ef21b80ac6565d172cdab4384404de007eea (diff) |
trace: Add a new readonly entry to report total buffer size
The current file "buffer_size_kb" reports the size of per-cpu buffer and
not the overall memory allocated which could be misleading. A new file
"buffer_total_size_kb" adds up all the enabled CPU buffer sizes and
reports it. This is only a readonly entry.
Signed-off-by: Vaibhav Nagarnaik <vnagarnaik@google.com>
Cc: Michael Rubin <mrubin@google.com>
Cc: David Sharp <dhsharp@google.com>
Link: http://lkml.kernel.org/r/1313531179-9323-2-git-send-email-vnagarnaik@google.com
Signed-off-by: Steven Rostedt <rostedt@goodmis.org>
Diffstat (limited to 'kernel/trace')
-rw-r--r-- | kernel/trace/trace.c | 33 |
1 files changed, 33 insertions, 0 deletions
diff --git a/kernel/trace/trace.c b/kernel/trace/trace.c index e5df02c69b1d..01176788c387 100644 --- a/kernel/trace/trace.c +++ b/kernel/trace/trace.c | |||
@@ -3569,6 +3569,30 @@ tracing_entries_write(struct file *filp, const char __user *ubuf, | |||
3569 | } | 3569 | } |
3570 | 3570 | ||
3571 | static ssize_t | 3571 | static ssize_t |
3572 | tracing_total_entries_read(struct file *filp, char __user *ubuf, | ||
3573 | size_t cnt, loff_t *ppos) | ||
3574 | { | ||
3575 | struct trace_array *tr = filp->private_data; | ||
3576 | char buf[64]; | ||
3577 | int r, cpu; | ||
3578 | unsigned long size = 0, expanded_size = 0; | ||
3579 | |||
3580 | mutex_lock(&trace_types_lock); | ||
3581 | for_each_tracing_cpu(cpu) { | ||
3582 | size += tr->entries >> 10; | ||
3583 | if (!ring_buffer_expanded) | ||
3584 | expanded_size += trace_buf_size >> 10; | ||
3585 | } | ||
3586 | if (ring_buffer_expanded) | ||
3587 | r = sprintf(buf, "%lu\n", size); | ||
3588 | else | ||
3589 | r = sprintf(buf, "%lu (expanded: %lu)\n", size, expanded_size); | ||
3590 | mutex_unlock(&trace_types_lock); | ||
3591 | |||
3592 | return simple_read_from_buffer(ubuf, cnt, ppos, buf, r); | ||
3593 | } | ||
3594 | |||
3595 | static ssize_t | ||
3572 | tracing_free_buffer_write(struct file *filp, const char __user *ubuf, | 3596 | tracing_free_buffer_write(struct file *filp, const char __user *ubuf, |
3573 | size_t cnt, loff_t *ppos) | 3597 | size_t cnt, loff_t *ppos) |
3574 | { | 3598 | { |
@@ -3739,6 +3763,12 @@ static const struct file_operations tracing_entries_fops = { | |||
3739 | .llseek = generic_file_llseek, | 3763 | .llseek = generic_file_llseek, |
3740 | }; | 3764 | }; |
3741 | 3765 | ||
3766 | static const struct file_operations tracing_total_entries_fops = { | ||
3767 | .open = tracing_open_generic, | ||
3768 | .read = tracing_total_entries_read, | ||
3769 | .llseek = generic_file_llseek, | ||
3770 | }; | ||
3771 | |||
3742 | static const struct file_operations tracing_free_buffer_fops = { | 3772 | static const struct file_operations tracing_free_buffer_fops = { |
3743 | .write = tracing_free_buffer_write, | 3773 | .write = tracing_free_buffer_write, |
3744 | .release = tracing_free_buffer_release, | 3774 | .release = tracing_free_buffer_release, |
@@ -4450,6 +4480,9 @@ static __init int tracer_init_debugfs(void) | |||
4450 | trace_create_file("buffer_size_kb", 0644, d_tracer, | 4480 | trace_create_file("buffer_size_kb", 0644, d_tracer, |
4451 | &global_trace, &tracing_entries_fops); | 4481 | &global_trace, &tracing_entries_fops); |
4452 | 4482 | ||
4483 | trace_create_file("buffer_total_size_kb", 0444, d_tracer, | ||
4484 | &global_trace, &tracing_total_entries_fops); | ||
4485 | |||
4453 | trace_create_file("free_buffer", 0644, d_tracer, | 4486 | trace_create_file("free_buffer", 0644, d_tracer, |
4454 | &global_trace, &tracing_free_buffer_fops); | 4487 | &global_trace, &tracing_free_buffer_fops); |
4455 | 4488 | ||