ring_buffer: compressed event header
Subsystems (2)
PATCH 1/1 ring_buffer: compressed event header
RB_MAX_SMALL_DATA = 28bytes is too small for most tracers, it wastes an 'u32' to save the actually length for events which data size > 28.
This fix uses compressed event header and enlarges RB_MAX_SMALL_DATA.
Impact: saves about 0%-12.5%(depends on tracer) memory in ring_buffer
---
include/linux/ring_buffer.h +9 -7
@@ -13,7 +13,7 @@ struct ring_buffer_iter;*/ struct ring_buffer_event { kmemcheck_define_bitfield(bitfield, { -u32 type:2 , len:3 , time_delta:27 ; +u32 type_len:5 , time_delta:27 ; });u32 array[];
@@ -28,7 +28,8 @@ struct ring_buffer_event {* size is variable depending on how much * padding is needed * If time_delta is non zero: -* everything else same as RINGBUF_TYPE_DATA +* array[0] holds the actual length +* size = 4 + length (bytes) * * @RINGBUF_TYPE_TIME_EXTEND: Extend the time delta * array[0] = time delta (28 .. 59)
@@ -39,22 +40,23 @@ struct ring_buffer_event {* array[1..2] = tv_sec * size = 16 bytes * -* @RINGBUF_TYPE_DATA: Data record -* If len is zero: +* <= @RINGBUF_TYPE_DATA_TYPE_LEN_MAX: +* Data record +* If type_len is zero: * array[0] holds the actual length * array[1..(length+3)/4] holds data -* size = 4 + 4 + length (bytes) +* size = 4 + length (bytes) * else -* length = len << 2 +* length = type_len << 2 * array[0..(length+3)/4-1] holds data * size = 4 + length (bytes) */ enum ring_buffer_type { +RINGBUF_TYPE_DATA_TYPE_LEN_MAX =28 ,RINGBUF_TYPE_PADDING ,RINGBUF_TYPE_TIME_EXTEND ,/* FIXME: RINGBUF_TYPE_TIME_STAMP not implemented */ RINGBUF_TYPE_TIME_STAMP , -RINGBUF_TYPE_DATA , };unsigned ring_buffer_event_length (struct ring_buffer_event *event);
kernel/trace/ring_buffer.c +41 -42
244 lines not on this page · raw message
Quoted 10 lines · Lai Jiangshan
RB_MAX_SMALL_DATA= 28bytes is too small for most tracers, it wastes an 'u32' to save the actually length for events which data size > 28.This fix uses compressed event header and enlarges
RB_MAX_SMALL_DATA.Impact: saves about 0%-12.5%(depends on tracer) memory in
ring_bufferSigned-off-by Lai Jiangshan <[email protected]>
Thanks, applied!
-- Steve
Commit-ID: 334d4169a6592d3fcd863bbe822a8f6985ffa9af Gitweb: http://git.kernel.org/tip/334d4169a6592d3fcd863bbe822a8f6985ffa9af Author: Lai Jiangshan <[email protected]> AuthorDate: Fri, 24 Apr 2009 11:27:05 +0800 Committer: Steven Rostedt <[email protected]> CommitDate: Fri, 24 Apr 2009 00:08:38 -0400
ring_buffer: compressed event header
RB_MAX_SMALL_DATA = 28bytes is too small for most tracers, it wastes an 'u32' to save the actually length for events which data size > 28.
This fix uses compressed event header and enlarges RB_MAX_SMALL_DATA.
[ Impact: saves about 0%-12.5%(depends on tracer) memory in ring_buffer ]
LKML-Reference: <[email protected]>
--- include/linux/ring_buffer.h | 16 +++++---- kernel/trace/ring_buffer.c | 83 +++++++++++++++++++++---------------------- 2 files changed, 50 insertions(+), 49 deletions(-)
include/linux/ring_buffer.h +9 -7
@@ -11,7 +11,7 @@ struct ring_buffer_iter;* Don't refer to this struct directly, use functions below. */ struct ring_buffer_event { -u32 type:2 , len:3 , time_delta:27 ; +u32 type_len:5 , time_delta:27 ;u32 array[]; };
@@ -24,7 +24,8 @@ struct ring_buffer_event {* size is variable depending on how much * padding is needed * If time_delta is non zero: -* everything else same as RINGBUF_TYPE_DATA +* array[0] holds the actual length +* size = 4 + length (bytes) * * @RINGBUF_TYPE_TIME_EXTEND: Extend the time delta * array[0] = time delta (28 .. 59)
@@ -35,22 +36,23 @@ struct ring_buffer_event {* array[1..2] = tv_sec * size = 16 bytes * -* @RINGBUF_TYPE_DATA: Data record -* If len is zero: +* <= @RINGBUF_TYPE_DATA_TYPE_LEN_MAX: +* Data record +* If type_len is zero: * array[0] holds the actual length * array[1..(length+3)/4] holds data -* size = 4 + 4 + length (bytes) +* size = 4 + length (bytes) * else -* length = len << 2 +* length = type_len << 2 * array[0..(length+3)/4-1] holds data * size = 4 + length (bytes) */ enum ring_buffer_type { +RINGBUF_TYPE_DATA_TYPE_LEN_MAX =28 ,RINGBUF_TYPE_PADDING ,RINGBUF_TYPE_TIME_EXTEND ,/* FIXME: RINGBUF_TYPE_TIME_STAMP not implemented */ RINGBUF_TYPE_TIME_STAMP , -RINGBUF_TYPE_DATA , };unsigned ring_buffer_event_length (struct ring_buffer_event *event);
kernel/trace/ring_buffer.c +41 -42
244 lines not on this page · raw message