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@kernel.org>,
	Andrew Morton <akpm@linux-foundation.org>,
	<stable@vger.kernel.org>
Subject: [for-next][PATCH 1/7] ring-buffer: Update read stamp with first real commit on page
Date: Wed, 25 Nov 2015 11:08:39 -0500	[thread overview]
Message-ID: <20151125160912.136773678@goodmis.org> (raw)
In-Reply-To: 20151125160838.739491216@goodmis.org

[-- Attachment #1: 0001-ring-buffer-Update-read-stamp-with-first-real-commit.patch --]
[-- Type: text/plain, Size: 2105 bytes --]

From: "Steven Rostedt (Red Hat)" <rostedt@goodmis.org>

Do not update the read stamp after swapping out the reader page from the
write buffer. If the reader page is swapped out of the buffer before an
event is written to it, then the read_stamp may get an out of date
timestamp, as the page timestamp is updated on the first commit to that
page.

rb_get_reader_page() only returns a page if it has an event on it, otherwise
it will return NULL. At that point, check if the page being returned has
events and has not been read yet. Then at that point update the read_stamp
to match the time stamp of the reader page.

Cc: stable@vger.kernel.org # 2.6.30+
Signed-off-by: Steven Rostedt <rostedt@goodmis.org>
---
 kernel/trace/ring_buffer.c | 12 +++++-------
 1 file changed, 5 insertions(+), 7 deletions(-)

diff --git a/kernel/trace/ring_buffer.c b/kernel/trace/ring_buffer.c
index 75f1d05ea82d..4dd6d5bc4e11 100644
--- a/kernel/trace/ring_buffer.c
+++ b/kernel/trace/ring_buffer.c
@@ -1887,12 +1887,6 @@ rb_event_index(struct ring_buffer_event *event)
 	return (addr & ~PAGE_MASK) - BUF_PAGE_HDR_SIZE;
 }
 
-static void rb_reset_reader_page(struct ring_buffer_per_cpu *cpu_buffer)
-{
-	cpu_buffer->read_stamp = cpu_buffer->reader_page->page->time_stamp;
-	cpu_buffer->reader_page->read = 0;
-}
-
 static void rb_inc_iter(struct ring_buffer_iter *iter)
 {
 	struct ring_buffer_per_cpu *cpu_buffer = iter->cpu_buffer;
@@ -3626,7 +3620,7 @@ rb_get_reader_page(struct ring_buffer_per_cpu *cpu_buffer)
 
 	/* Finally update the reader page to the new head */
 	cpu_buffer->reader_page = reader;
-	rb_reset_reader_page(cpu_buffer);
+	cpu_buffer->reader_page->read = 0;
 
 	if (overwrite != cpu_buffer->last_overrun) {
 		cpu_buffer->lost_events = overwrite - cpu_buffer->last_overrun;
@@ -3636,6 +3630,10 @@ rb_get_reader_page(struct ring_buffer_per_cpu *cpu_buffer)
 	goto again;
 
  out:
+	/* Update the read_stamp on the first event */
+	if (reader && reader->read == 0)
+		cpu_buffer->read_stamp = reader->page->time_stamp;
+
 	arch_spin_unlock(&cpu_buffer->lock);
 	local_irq_restore(flags);
 
-- 
2.6.1



  reply	other threads:[~2015-11-25 16:11 UTC|newest]

Thread overview: 17+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-11-25 16:08 [for-next][PATCH 0/7] tracing: Updates for 4.5 (and some stuff going into 4.4) Steven Rostedt
2015-11-25 16:08 ` Steven Rostedt [this message]
2015-11-25 16:08 ` [for-next][PATCH 2/7] ring-buffer: Put back the length if crossed page with add_timestamp Steven Rostedt
2015-11-25 16:08 ` [for-next][PATCH 3/7] ftracetest: Add instance create and delete test Steven Rostedt
2015-11-25 16:31   ` Steven Rostedt
2015-12-09  5:09   ` Michael Ellerman
2015-12-11 19:36     ` Steven Rostedt
2016-01-15  5:08       ` Michael Ellerman
2016-01-15 17:50         ` Steven Rostedt
2016-01-18  5:47           ` Michael Ellerman
2016-02-18 12:37           ` Michael Ellerman
2016-02-18 14:04             ` Steven Rostedt
2015-11-25 16:08 ` [for-next][PATCH 4/7] ring-buffer: Use READ_ONCE() for most tail_page access Steven Rostedt
2015-11-25 16:08 ` [for-next][PATCH 5/7] ring-buffer: Remove redundant update of page timestamp Steven Rostedt
2015-11-25 16:08 ` [for-next][PATCH 6/7] ring-buffer: Process commits whenever moving to a new page Steven Rostedt
2015-11-25 20:22   ` Steven Rostedt
2015-11-25 16:08 ` [for-next][PATCH 7/7] tracing: Update cond flag when enabling or disabling a trigger Steven Rostedt

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=20151125160912.136773678@goodmis.org \
    --to=rostedt@goodmis.org \
    --cc=akpm@linux-foundation.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mingo@kernel.org \
    --cc=stable@vger.kernel.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