lkml.org 
[lkml]   [2009]   [Jan]   [7]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
Patch in this message
/
Date
From
Subject[PATCH] ring_buffer: fix ring_buffer_event_length()

Hi Ingo,

I added the Impact line. This probably should go into 2.6.29.

The following patch is in:

git://git.kernel.org/pub/scm/linux/kernel/git/rostedt/linux-2.6-trace.git

branch: tip/devel


Robert Richter (1):
ring_buffer: fix ring_buffer_event_length()

----
kernel/trace/ring_buffer.c | 8 +++++++-
1 files changed, 7 insertions(+), 1 deletions(-)
---------------------------
commit 49c86f2104c25d36f1a44e569c08968f388da75d
Author: Robert Richter <robert.richter@amd.com>
Date: Wed Jan 7 23:45:23 2009 +0100
ring_buffer: fix ring_buffer_event_length()

Impact: fix to ring_buffer_event_length()

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().

Signed-off-by: Robert Richter <robert.richter@amd.com>
Signed-off-by: Steven Rostedt <srostedt@redhat.com>

diff --git a/kernel/trace/ring_buffer.c b/kernel/trace/ring_buffer.c
index a9d9760..8b0daf0 100644
--- a/kernel/trace/ring_buffer.c
+++ b/kernel/trace/ring_buffer.c
@@ -168,7 +168,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);



\
 
 \ /
  Last update: 2009-01-08 06:01    [W:0.095 / U:0.452 seconds]
©2003-2014 Jasper Spaans. Advertise on this site