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>,
	Frederic Weisbecker <fweisbec@gmail.com>
Subject: [PATCH 15/15] tracing: Fix irqoff selftest expanding max buffer
Date: Thu, 10 Mar 2011 10:58:15 -0500	[thread overview]
Message-ID: <20110310155912.913153141@goodmis.org> (raw)
In-Reply-To: 20110310155800.478792851@goodmis.org

[-- Attachment #1: 0015-tracing-Fix-irqoff-selftest-expanding-max-buffer.patch --]
[-- Type: text/plain, Size: 3193 bytes --]

From: Steven Rostedt <srostedt@redhat.com>

If the kernel command line declares a tracer "ftrace=sometracer" and
that tracer is either not defined or is enabled after irqsoff,
then the irqs off selftest will fail with the following error:

Testing tracer irqsoff:
------------[ cut here ]------------
WARNING: at /home/rostedt/work/autotest/nobackup/linux-test.git/kernel/trace/tra
ce.c:713 update_max_tr_single+0xfa/0x11b()
Hardware name:
Modules linked in:
Pid: 1, comm: swapper Not tainted 2.6.38-rc8-test #1
Call Trace:
 [<c0441d9d>] ? warn_slowpath_common+0x65/0x7a
 [<c049adb2>] ? update_max_tr_single+0xfa/0x11b
 [<c0441dc1>] ? warn_slowpath_null+0xf/0x13
 [<c049adb2>] ? update_max_tr_single+0xfa/0x11b
 [<c049e454>] ? stop_critical_timing+0x154/0x204
 [<c049b54b>] ? trace_selftest_startup_irqsoff+0x5b/0xc1
 [<c049b54b>] ? trace_selftest_startup_irqsoff+0x5b/0xc1
 [<c049b54b>] ? trace_selftest_startup_irqsoff+0x5b/0xc1
 [<c049e529>] ? time_hardirqs_on+0x25/0x28
 [<c0468bca>] ? trace_hardirqs_on_caller+0x18/0x12f
 [<c0468cec>] ? trace_hardirqs_on+0xb/0xd
 [<c049b54b>] ? trace_selftest_startup_irqsoff+0x5b/0xc1
 [<c049b6b8>] ? register_tracer+0xf8/0x1a3
 [<c14e93fe>] ? init_irqsoff_tracer+0xd/0x11
 [<c040115e>] ? do_one_initcall+0x71/0x121
 [<c14e93f1>] ? init_irqsoff_tracer+0x0/0x11
 [<c14ce3a9>] ? kernel_init+0x13a/0x1b6
 [<c14ce26f>] ? kernel_init+0x0/0x1b6
 [<c0403842>] ? kernel_thread_helper+0x6/0x10
---[ end trace e93713a9d40cd06c ]---
.. no entries found ..FAILED!

What happens is the "ftrace=..." will expand the ring buffer to its
default size (from its minimum size) but it will not expand the
max ring buffer (the ring buffer to store maximum latencies).
When the irqsoff test runs, it will call the ring buffer swap routine
that checks if the max ring buffer is the same size as the normal
ring buffer, and will fail if it is not. This causes the test to fail.

The solution is to expand the max ring buffer before running the self
test if the max ring buffer is used by that tracer and the normal ring
buffer is expanded. The max ring buffer should be shrunk again after
the test is done to save space.

Signed-off-by: Steven Rostedt <rostedt@goodmis.org>
---
 kernel/trace/trace.c |    9 +++++++++
 1 files changed, 9 insertions(+), 0 deletions(-)

diff --git a/kernel/trace/trace.c b/kernel/trace/trace.c
index fd6e1b9..9541c27 100644
--- a/kernel/trace/trace.c
+++ b/kernel/trace/trace.c
@@ -779,6 +779,11 @@ __acquires(kernel_lock)
 		tracing_reset_online_cpus(tr);
 
 		current_trace = type;
+
+		/* If we expanded the buffers, make sure the max is expanded too */
+		if (ring_buffer_expanded && type->use_max_tr)
+			ring_buffer_resize(max_tr.buffer, trace_buf_size);
+
 		/* the test is responsible for initializing and enabling */
 		pr_info("Testing tracer %s: ", type->name);
 		ret = type->selftest(type, tr);
@@ -791,6 +796,10 @@ __acquires(kernel_lock)
 		/* Only reset on passing, to avoid touching corrupted buffers */
 		tracing_reset_online_cpus(tr);
 
+		/* Shrink the max buffer again */
+		if (ring_buffer_expanded && type->use_max_tr)
+			ring_buffer_resize(max_tr.buffer, 1);
+
 		printk(KERN_CONT "PASSED\n");
 	}
 #endif
-- 
1.7.2.3



  parent reply	other threads:[~2011-03-10 16:00 UTC|newest]

Thread overview: 17+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-03-10 15:58 [PATCH 00/15] [GIT PULL] tracing: updates for 2.6.39 Steven Rostedt
2011-03-10 15:58 ` [PATCH 01/15] tracing: Add an overwrite trace_option Steven Rostedt
2011-03-10 15:58 ` [PATCH 02/15] ring-buffer: Remove unused #include <linux/trace_irq.h> Steven Rostedt
2011-03-10 15:58 ` [PATCH 03/15] tracing: Remove lock_depth from event entry Steven Rostedt
2011-03-10 15:58 ` [PATCH 04/15] tracing: Fix event alignment: ftrace:context_switch and ftrace:wakeup Steven Rostedt
2011-03-10 15:58 ` [PATCH 05/15] tracing: Fix event alignment: module:module_request Steven Rostedt
2011-03-10 15:58 ` [PATCH 06/15] tracing: Fix event alignment: kvm:kvm_hv_hypercall Steven Rostedt
2011-03-10 15:58 ` [PATCH 07/15] tracing: Fix event alignment: mce:mce_record Steven Rostedt
2011-03-10 15:58 ` [PATCH 08/15] tracing: Fix event alignment: skb:kfree_skb Steven Rostedt
2011-03-10 15:58 ` [PATCH 09/15] tracing: Adjust conditional expression latency formatting Steven Rostedt
2011-03-10 15:58 ` [PATCH 10/15] ftrace: Add .ref.text as one of the safe areas to trace Steven Rostedt
2011-03-10 15:58 ` [PATCH 11/15] ftrace/graph: Trace function entry before updating index Steven Rostedt
2011-03-10 15:58 ` [PATCH 12/15] tracing: Explain about unstable clock on resume with ring buffer warning Steven Rostedt
2011-03-10 15:58 ` [PATCH 13/15] tracing: Export trace_set_clr_event() Steven Rostedt
2011-03-10 15:58 ` [PATCH 14/15] tracing: Align 4 byte ints together in struct tracer Steven Rostedt
2011-03-10 15:58 ` Steven Rostedt [this message]
2011-03-11  8:27 ` [PATCH 00/15] [GIT PULL] tracing: updates for 2.6.39 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=20110310155912.913153141@goodmis.org \
    --to=rostedt@goodmis.org \
    --cc=akpm@linux-foundation.org \
    --cc=fweisbec@gmail.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mingo@elte.hu \
    /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