aboutsummaryrefslogtreecommitdiffstats
path: root/kernel/trace/ring_buffer.c
diff options
context:
space:
mode:
authorSteven Rostedt (Red Hat) <rostedt@goodmis.org>2015-05-29 10:29:10 -0400
committerSteven Rostedt <rostedt@goodmis.org>2015-07-20 22:30:49 -0400
commit7d75e6833b579adb3de2c7b917de1204eeafea47 (patch)
tree4da33dac5a0c679ac3b4398bc09f7e4d2cf9c8c5 /kernel/trace/ring_buffer.c
parenta4543a2fa9ef31d6d0f854a4e14f8f82e7996d8d (diff)
ring-buffer: Make sure event has enough room for extend and padding
Now that events only add time extends after it is committed, in case an event comes in before it can discard the allocated event, the time extend needs to be stored within the event. If the event is bigger than then size needed for the time extend, padding must be added. The minimum padding size is 8 bytes. Thus if the event is 12 bytes (size of time extend + 4), there will not be enough room to add both the time extend and padding. Make sure all events are either 8 bytes or 16 or more bytes. Signed-off-by: Steven Rostedt <rostedt@goodmis.org>
Diffstat (limited to 'kernel/trace/ring_buffer.c')
-rw-r--r--kernel/trace/ring_buffer.c15
1 files changed, 15 insertions, 0 deletions
diff --git a/kernel/trace/ring_buffer.c b/kernel/trace/ring_buffer.c
index b5ed553e0a45..781ce359976c 100644
--- a/kernel/trace/ring_buffer.c
+++ b/kernel/trace/ring_buffer.c
@@ -2208,6 +2208,21 @@ static unsigned rb_calculate_event_length(unsigned length)
2208 length += RB_EVNT_HDR_SIZE; 2208 length += RB_EVNT_HDR_SIZE;
2209 length = ALIGN(length, RB_ARCH_ALIGNMENT); 2209 length = ALIGN(length, RB_ARCH_ALIGNMENT);
2210 2210
2211 /*
2212 * In case the time delta is larger than the 27 bits for it
2213 * in the header, we need to add a timestamp. If another
2214 * event comes in when trying to discard this one to increase
2215 * the length, then the timestamp will be added in the allocated
2216 * space of this event. If length is bigger than the size needed
2217 * for the TIME_EXTEND, then padding has to be used. The events
2218 * length must be either RB_LEN_TIME_EXTEND, or greater than or equal
2219 * to RB_LEN_TIME_EXTEND + 8, as 8 is the minimum size for padding.
2220 * As length is a multiple of 4, we only need to worry if it
2221 * is 12 (RB_LEN_TIME_EXTEND + 4).
2222 */
2223 if (length == RB_LEN_TIME_EXTEND + RB_ALIGNMENT)
2224 length += RB_ALIGNMENT;
2225
2211 return length; 2226 return length;
2212} 2227}
2213 2228