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>
Subject: [PATCH 3/5] ring-buffer: Check for end of page in iterator
Date: Tue, 26 Jan 2010 17:09:26 -0500	[thread overview]
Message-ID: <20100126221712.930071285@goodmis.org> (raw)
In-Reply-To: 20100126220923.534282809@goodmis.org

[-- Attachment #1: 0003-ring-buffer-Check-for-end-of-page-in-iterator.patch --]
[-- Type: text/plain, Size: 1589 bytes --]

From: Steven Rostedt <srostedt@redhat.com>

If the iterator comes to an empty page for some reason, or if
the page is emptied by a consuming read. The iterator code currently
does not check if the iterator is pass the contents, and may
return a false entry.

This patch adds a check to the ring buffer iterator to test if the
current page has been completely read and sets the iterator to the
next page if necessary.

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

diff --git a/kernel/trace/ring_buffer.c b/kernel/trace/ring_buffer.c
index 503b630..8c1b2d2 100644
--- a/kernel/trace/ring_buffer.c
+++ b/kernel/trace/ring_buffer.c
@@ -3064,9 +3064,6 @@ rb_iter_peek(struct ring_buffer_iter *iter, u64 *ts)
 	struct ring_buffer_event *event;
 	int nr_loops = 0;
 
-	if (ring_buffer_iter_empty(iter))
-		return NULL;
-
 	cpu_buffer = iter->cpu_buffer;
 	buffer = cpu_buffer->buffer;
 
@@ -3080,6 +3077,9 @@ rb_iter_peek(struct ring_buffer_iter *iter, u64 *ts)
 		rb_iter_reset(iter);
 
  again:
+	if (ring_buffer_iter_empty(iter))
+		return NULL;
+
 	/*
 	 * We repeat when a timestamp is encountered.
 	 * We can get multiple timestamps by nested interrupts or also
@@ -3094,6 +3094,11 @@ rb_iter_peek(struct ring_buffer_iter *iter, u64 *ts)
 	if (rb_per_cpu_empty(cpu_buffer))
 		return NULL;
 
+	if (iter->head >= local_read(&iter->head_page->page->commit)) {
+		rb_inc_iter(iter);
+		goto again;
+	}
+
 	event = rb_iter_head_event(iter);
 
 	switch (event->type_len) {
-- 
1.6.5



  parent reply	other threads:[~2010-01-26 22:17 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-01-26 22:09 [PATCH 0/5][GIT PULL][v2.6.33] tracing: fixes and documentation updates Steven Rostedt
2010-01-26 22:09 ` [PATCH 1/5] tracing: Prevent kernel oops with corrupted buffer Steven Rostedt
2010-01-26 22:32   ` Andrew Morton
2010-01-26 22:39     ` Frederic Weisbecker
2010-01-26 23:20       ` Steven Rostedt
2010-01-26 23:24     ` Steven Rostedt
2010-01-26 22:09 ` [PATCH 2/5] ring-buffer: Check if ring buffer iterator has stale data Steven Rostedt
2010-01-26 22:09 ` Steven Rostedt [this message]
2010-01-26 22:09 ` [PATCH 4/5] tracing/documentation: Fix a typo in ftrace.txt Steven Rostedt
2010-01-26 22:09 ` [PATCH 5/5] tracing/documentation: Cover new frame pointer semantics Steven Rostedt
2010-01-27  9:37 ` [PATCH 0/5][GIT PULL][v2.6.33] tracing: fixes and documentation updates 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=20100126221712.930071285@goodmis.org \
    --to=rostedt@goodmis.org \
    --cc=akpm@linux-foundation.org \
    --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