public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: David Sharp <dhsharp@google.com>
To: linux-kernel@vger.kernel.org
Cc: David Sharp <dhsharp@google.com>,
	Steven Rostedt <rostedt@goodmis.org>,
	Masami Hiramatsu <masami.hiramatsu.pt@hitachi.com>
Subject: [PATCH v5 2/3] tracing: Reset ring buffer when changing trace_clocks
Date: Mon,  1 Oct 2012 20:31:19 -0700	[thread overview]
Message-ID: <1349148680-9509-2-git-send-email-dhsharp@google.com> (raw)
In-Reply-To: <1349148680-9509-1-git-send-email-dhsharp@google.com>

Because the "tsc" clock isn't in nanoseconds, the ring buffer must be
reset when changing clocks so that incomparable timestamps don't end up
in the same trace.

Tested: Confirmed switching clocks resets the trace buffer.

Google-Bug-Id: 6980623
Signed-off-by: David Sharp <dhsharp@google.com>
Cc: Steven Rostedt <rostedt@goodmis.org>
Cc: Masami Hiramatsu <masami.hiramatsu.pt@hitachi.com>
---
 kernel/trace/trace.c |    8 ++++++++
 1 files changed, 8 insertions(+), 0 deletions(-)

diff --git a/kernel/trace/trace.c b/kernel/trace/trace.c
index 92fb08e..4e26df3 100644
--- a/kernel/trace/trace.c
+++ b/kernel/trace/trace.c
@@ -4012,6 +4012,14 @@ static ssize_t tracing_clock_write(struct file *filp, const char __user *ubuf,
 	if (max_tr.buffer)
 		ring_buffer_set_clock(max_tr.buffer, trace_clocks[i].func);
 
+	/*
+	 * New clock may not be consistent with the previous clock.
+	 * Reset the buffer so that it doesn't have incomparable timestamps.
+	 */
+	tracing_reset_online_cpus(&global_trace);
+	if (max_tr.buffer)
+		tracing_reset_online_cpus(&max_tr);
+
 	mutex_unlock(&trace_types_lock);
 
 	*fpos += cnt;
-- 
1.7.7.3


  reply	other threads:[~2012-10-02  3:31 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-10-02  3:31 [PATCH v5 1/3] tracing,x86: Add a TSC trace_clock David Sharp
2012-10-02  3:31 ` David Sharp [this message]
2012-10-02  3:31 ` [PATCH v5 3/3] tracing: Format non-nanosec times from tsc clock without a decimal point David Sharp
2012-10-11 20:43   ` Steven Rostedt
2012-10-11 22:58     ` David Sharp
2012-10-09  2:08 ` [PATCH v5 1/3] tracing,x86: Add a TSC trace_clock Yoshihiro YUNOMAE
2012-10-11 23:30   ` David Sharp
2012-10-09  2:08 ` [PATCH 0/2] ftrace: [BUGFIX] type of ring_buffer_oldest_event_ts() and showing of stats per cpu directory Yoshihiro YUNOMAE
2012-10-09  2:08   ` [PATCH 1/2] ftrace: Change unsigned long type of ring_buffer_oldest_event_ts() to u64 Yoshihiro YUNOMAE
2012-10-09  2:08   ` [PATCH 2/2] ftrace: Show raw time stamp on stats per cpu using counter or tsc mode for trace_clock Yoshihiro YUNOMAE

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=1349148680-9509-2-git-send-email-dhsharp@google.com \
    --to=dhsharp@google.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=masami.hiramatsu.pt@hitachi.com \
    --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