public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Lai Jiangshan <laijs@cn.fujitsu.com>
To: Steven Rostedt <rostedt@goodmis.org>,
	linux-kernel@vger.kernel.org, Ingo Molnar <mingo@elte.hu>,
	Andrew Morton <akpm@linux-foundation.org>,
	Frederic Weisbecker <fweisbec@gmail.com>
Subject: [PATCH 3/6] tracing: tracing_stats_read() uses simple buffer instead of trace_seq
Date: Tue, 19 Jan 2010 15:34:08 +0800	[thread overview]
Message-ID: <4B556070.6000204@cn.fujitsu.com> (raw)


It seems that struct trace_seq is too heavy for tracing_stats_read().
we use simple buffer instead of struct trace_seq.

Signed-off-by: Lai Jiangshan <laijs@cn.fujitsu.com>
---
diff --git a/kernel/trace/trace.c b/kernel/trace/trace.c
index 27fecf8..aa1cd92 100644
--- a/kernel/trace/trace.c
+++ b/kernel/trace/trace.c
@@ -3807,27 +3807,22 @@ tracing_stats_read(struct file *filp, char __user *ubuf,
 {
 	unsigned long cpu = (unsigned long)filp->private_data;
 	struct trace_array *tr = &global_trace;
-	struct trace_seq *s;
 	unsigned long cnt;
 
-	s = kmalloc(sizeof(*s), GFP_KERNEL);
-	if (!s)
-		return -ENOMEM;
-
-	trace_seq_init(s);
+	unsigned char buf[128];
+	int len = 0;
 
 	cnt = ring_buffer_entries_cpu(tr->buffer, cpu);
-	trace_seq_printf(s, "entries: %ld\n", cnt);
+	len += sprintf(buf + len, "entries: %ld\n", cnt);
 
 	cnt = ring_buffer_overrun_cpu(tr->buffer, cpu);
-	trace_seq_printf(s, "overrun: %ld\n", cnt);
+	len += sprintf(buf + len, "overrun: %ld\n", cnt);
 
 	cnt = ring_buffer_commit_overrun_cpu(tr->buffer, cpu);
-	trace_seq_printf(s, "commit overrun: %ld\n", cnt);
-
-	count = simple_read_from_buffer(ubuf, count, ppos, s->buffer, s->len);
+	len += sprintf(buf + len, "commit overrun: %ld\n", cnt);
 
-	kfree(s);
+	BUG_ON(len >= sizeof(buf)); /* should not happen, 128 is enough. */
+	count = simple_read_from_buffer(ubuf, count, ppos, buf, len);
 
 	return count;
 }


             reply	other threads:[~2010-01-19  7:35 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-01-19  7:34 Lai Jiangshan [this message]
2010-01-20 18:00 ` [PATCH 3/6] tracing: tracing_stats_read() uses simple buffer instead of trace_seq Frederic Weisbecker

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=4B556070.6000204@cn.fujitsu.com \
    --to=laijs@cn.fujitsu.com \
    --cc=akpm@linux-foundation.org \
    --cc=fweisbec@gmail.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mingo@elte.hu \
    --cc=rostedt@goodmis.org \
    /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