public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Steven Rostedt <rostedt@goodmis.org>
To: linux-kernel@vger.kernel.org
Cc: Ingo Molnar <mingo@elte.hu>,
	Andrew Morton <akpm@linux-foundation.org>,
	Thomas Gleixner <tglx@linutronix.de>,
	Frederic Weisbecker <fweisbec@gmail.com>,
	Vaibhav Nagarnaik <vnagarnaik@google.com>,
	Michael Rubin <mrubin@google.com>,
	David Sharp <dhsharp@google.com>
Subject: [PATCH 15/20] trace: Add a new readonly entry to report total buffer size
Date: Mon, 10 Oct 2011 09:39:07 -0400	[thread overview]
Message-ID: <20111010134144.310010179@goodmis.org> (raw)
In-Reply-To: 20111010133852.829771373@goodmis.org

[-- Attachment #1: Type: text/plain, Size: 2619 bytes --]

From: Vaibhav Nagarnaik <vnagarnaik@google.com>

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>
---
 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 e5df02c..0117678 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,
 }
 
 static ssize_t
+tracing_total_entries_read(struct file *filp, char __user *ubuf,
+				size_t cnt, loff_t *ppos)
+{
+	struct trace_array *tr = filp->private_data;
+	char buf[64];
+	int r, cpu;
+	unsigned long size = 0, expanded_size = 0;
+
+	mutex_lock(&trace_types_lock);
+	for_each_tracing_cpu(cpu) {
+		size += tr->entries >> 10;
+		if (!ring_buffer_expanded)
+			expanded_size += trace_buf_size >> 10;
+	}
+	if (ring_buffer_expanded)
+		r = sprintf(buf, "%lu\n", size);
+	else
+		r = sprintf(buf, "%lu (expanded: %lu)\n", size, expanded_size);
+	mutex_unlock(&trace_types_lock);
+
+	return simple_read_from_buffer(ubuf, cnt, ppos, buf, r);
+}
+
+static ssize_t
 tracing_free_buffer_write(struct file *filp, const char __user *ubuf,
 			  size_t cnt, loff_t *ppos)
 {
@@ -3739,6 +3763,12 @@ static const struct file_operations tracing_entries_fops = {
 	.llseek		= generic_file_llseek,
 };
 
+static const struct file_operations tracing_total_entries_fops = {
+	.open		= tracing_open_generic,
+	.read		= tracing_total_entries_read,
+	.llseek		= generic_file_llseek,
+};
+
 static const struct file_operations tracing_free_buffer_fops = {
 	.write		= tracing_free_buffer_write,
 	.release	= tracing_free_buffer_release,
@@ -4450,6 +4480,9 @@ static __init int tracer_init_debugfs(void)
 	trace_create_file("buffer_size_kb", 0644, d_tracer,
 			&global_trace, &tracing_entries_fops);
 
+	trace_create_file("buffer_total_size_kb", 0444, d_tracer,
+			&global_trace, &tracing_total_entries_fops);
+
 	trace_create_file("free_buffer", 0644, d_tracer,
 			&global_trace, &tracing_free_buffer_fops);
 
-- 
1.7.6.3



[-- Attachment #2: This is a digitally signed message part --]
[-- Type: application/pgp-signature, Size: 836 bytes --]

  parent reply	other threads:[~2011-10-10 13:43 UTC|newest]

Thread overview: 30+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-10-10 13:38 [PATCH 00/20] [GIT PULL][v3.2] tracing: queued updates Steven Rostedt
2011-10-10 13:38 ` [PATCH 01/20] tracing: Clean up tb_fmt to not give faulty compile warning Steven Rostedt
2011-10-10 13:38 ` [PATCH 02/20] Tracepoint: Dissociate from module mutex Steven Rostedt
2011-10-10 13:38 ` [PATCH 03/20] x86: jump_label: arch_jump_label_text_poke_early: add missing __init Steven Rostedt
2011-10-10 13:38 ` [PATCH 04/20] tracing/filter: Use static allocation for filter predicates Steven Rostedt
2011-10-10 13:38 ` [PATCH 05/20] tracing/filter: Separate predicate init and filter addition Steven Rostedt
2011-10-10 13:38 ` [PATCH 06/20] tracing/filter: Remove field_name from filter_pred struct Steven Rostedt
2011-10-10 13:38 ` [PATCH 07/20] tracing/filter: Simplify tracepoint event lookup Steven Rostedt
2011-10-10 13:39 ` [PATCH 08/20] tracing/filter: Unify predicate tree walking, change check_pred_tree Steven Rostedt
2011-10-10 13:39 ` [PATCH 09/20] tracing/filter: Change count_leafs function to use walk_pred_tree Steven Rostedt
2011-10-10 13:39 ` [PATCH 10/20] tracing/filter: Change fold_pred_tree " Steven Rostedt
2011-10-10 13:39 ` [PATCH 11/20] tracing/filter: Change fold_pred " Steven Rostedt
2011-10-10 13:39 ` [PATCH 12/20] tracing/filter: Change filter_match_preds function to use Steven Rostedt
2011-10-10 13:39 ` [PATCH 13/20] tracing/filter: Add startup tests for events filter Steven Rostedt
2011-10-10 13:39 ` [PATCH 14/20] tracing: Add preempt disable for filter self test Steven Rostedt
2011-10-10 13:39 ` Steven Rostedt [this message]
2011-10-10 13:39 ` [PATCH 16/20] trace: Add ring buffer stats to measure rate of events Steven Rostedt
2011-10-10 13:39 ` [PATCH 17/20] tracing: Add a counter clock for those that do not trust clocks Steven Rostedt
2011-10-10 13:39 ` [PATCH 18/20] tracing: Fix preemptirqsoff tracer to not stop at preempt off Steven Rostedt
2011-10-10 13:39 ` [PATCH 19/20] tracing: Warn on output if the function tracer was found corrupted Steven Rostedt
2011-10-10 13:39 ` [PATCH 20/20] tracing: Do not allocate buffer for trace_marker Steven Rostedt
2011-10-10 13:52 ` [PATCH 00/20] [GIT PULL][v3.2] tracing: queued updates Steven Rostedt
2011-10-11  5:51   ` Ingo Molnar
2011-10-11  8:15     ` Ingo Molnar
2011-10-11 11:14       ` Steven Rostedt
2011-10-11  5:50 ` Ingo Molnar
2011-10-11 21:08   ` Valdis.Kletnieks
2011-10-12  8:07     ` Ingo Molnar
2011-10-12 14:19       ` Jeff King
2011-10-12 16:29         ` Ingo Molnar

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20111010134144.310010179@goodmis.org \
    --to=rostedt@goodmis.org \
    --cc=akpm@linux-foundation.org \
    --cc=dhsharp@google.com \
    --cc=fweisbec@gmail.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mingo@elte.hu \
    --cc=mrubin@google.com \
    --cc=tglx@linutronix.de \
    --cc=vnagarnaik@google.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox