diff options
author | Robert Richter <robert.richter@amd.com> | 2009-01-07 09:32:11 -0500 |
---|---|---|
committer | Robert Richter <robert.richter@amd.com> | 2009-01-07 16:47:40 -0500 |
commit | 465634adc1d09b490c8ee31885575be39d375d53 (patch) | |
tree | b6c119d0112b428104dbd4edbd23925d717d7119 /kernel | |
parent | 1acda878e20ea0cd3708ba66dca67d52eaafdd2b (diff) |
ring_buffer: fix 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().
Cc: Steven Rostedt <rostedt@goodmis.org>
Signed-off-by: Robert Richter <robert.richter@amd.com>
Diffstat (limited to 'kernel')
-rw-r--r-- | 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 30d57dd01a85..d42b882dfe4b 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) | |||
117 | */ | 117 | */ |
118 | unsigned ring_buffer_event_length(struct ring_buffer_event *event) | 118 | unsigned ring_buffer_event_length(struct ring_buffer_event *event) |
119 | { | 119 | { |
120 | return rb_event_length(event); | 120 | unsigned length = rb_event_length(event); |
121 | if (event->type != RINGBUF_TYPE_DATA) | ||
122 | return length; | ||
123 | length -= RB_EVNT_HDR_SIZE; | ||
124 | if (length > RB_MAX_SMALL_DATA + sizeof(event->array[0])) | ||
125 | length -= sizeof(event->array[0]); | ||
126 | return length; | ||
121 | } | 127 | } |
122 | EXPORT_SYMBOL_GPL(ring_buffer_event_length); | 128 | EXPORT_SYMBOL_GPL(ring_buffer_event_length); |
123 | 129 | ||