mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Robert Richter <robert.richter@amd.com>
To: Ingo Molnar <mingo@elte.hu>
Cc: LKML <linux-kernel@vger.kernel.org>,
	oprofile-list <oprofile-list@lists.sourceforge.net>,
	Robert Richter <robert.richter@amd.com>,
	Steven Rostedt <rostedt@goodmis.org>
Subject: [PATCH 7/9] ring_buffer: fix ring_buffer_event_length()
Date: Wed, 7 Jan 2009 23:45:23 +0100	[thread overview]
Message-ID: <1231368325-19246-8-git-send-email-robert.richter@amd.com> (raw)
In-Reply-To: <1231368325-19246-1-git-send-email-robert.richter@amd.com>

Function ring_buffer_event_length() provides an interface to detect
the length of data stored in an entry. However, the length contains
offsets depending on the internal usage. This makes it unusable. This
patch fixes this and now ring_buffer_event_length() returns the
alligned length that has been used in ring_buffer_lock_reserve().

Cc: Steven Rostedt <rostedt@goodmis.org>
Signed-off-by: Robert Richter <robert.richter@amd.com>
---
 kernel/trace/ring_buffer.c |    8 +++++++-
 1 files changed, 7 insertions(+), 1 deletions(-)

diff --git a/kernel/trace/ring_buffer.c b/kernel/trace/ring_buffer.c
index 30d57dd..d42b882 100644
--- a/kernel/trace/ring_buffer.c
+++ b/kernel/trace/ring_buffer.c
@@ -117,7 +117,13 @@ rb_event_length(struct ring_buffer_event *event)
  */
 unsigned ring_buffer_event_length(struct ring_buffer_event *event)
 {
-	return rb_event_length(event);
+	unsigned length = rb_event_length(event);
+	if (event->type != RINGBUF_TYPE_DATA)
+		return length;
+	length -= RB_EVNT_HDR_SIZE;
+	if (length > RB_MAX_SMALL_DATA + sizeof(event->array[0]))
+                length -= sizeof(event->array[0]);
+	return length;
 }
 EXPORT_SYMBOL_GPL(ring_buffer_event_length);
 
-- 
1.6.0.1



  parent reply	other threads:[~2009-01-07 22:59 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-01-07 22:45 [PATCH 0/9] oprofile: implement support of samples with variable data size Robert Richter
2009-01-07 22:45 ` [PATCH 1/9] oprofile: add op_cpu_buffer_write_reserve() Robert Richter
2009-01-07 22:45 ` [PATCH 2/9] oprofile: modify op_cpu_buffer_read_entry() Robert Richter
2009-01-07 22:45 ` [PATCH 3/9] oprofile: rework implementation of cpu buffer events Robert Richter
2009-01-07 22:45 ` [PATCH 4/9] oprofile: add op_cpu_buffer_add_data() Robert Richter
2009-01-07 22:45 ` [PATCH 5/9] oprofile: add op_cpu_buffer_get_data() Robert Richter
2009-01-07 22:45 ` [PATCH 6/9] oprofile: use new data sample format for ibs Robert Richter
2009-01-07 22:45 ` Robert Richter [this message]
2009-01-07 22:45 ` [PATCH 8/9] oprofile: remove #ifdef CONFIG_OPROFILE_IBS in non-ibs code Robert Richter
2009-01-07 22:45 ` [PATCH 9/9] oprofile: make new cpu buffer functions part of the api Robert Richter
2009-01-14 21:53 ` [PATCH 0/9] oprofile: implement support of samples with variable data size Maynard Johnson

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=1231368325-19246-8-git-send-email-robert.richter@amd.com \
    --to=robert.richter@amd.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mingo@elte.hu \
    --cc=oprofile-list@lists.sourceforge.net \
    --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

Powered by JetHome