diff options
author | Steven Rostedt <srostedt@redhat.com> | 2009-05-11 14:42:53 -0400 |
---|---|---|
committer | Steven Rostedt <rostedt@goodmis.org> | 2009-05-11 14:42:53 -0400 |
commit | be957c447f7233a67904a1b11eb3ab61e702bf4d (patch) | |
tree | fa92f4d46678c9a200ce9f92c1445da3bd71c74f /kernel/trace/ring_buffer.c | |
parent | 1cd8d7358948909ab80b254eb14bcebc555ad417 (diff) |
ring-buffer: move calculation of event length
The event length is calculated and passed in to rb_reserve_next_event
in two different locations. Having rb_reserve_next_event do the
calculations directly makes only one location to do the change and
causes the calculation to be inlined by gcc.
Before:
text data bss dec hex filename
16538 24 12 16574 40be kernel/trace/ring_buffer.o
After:
text data bss dec hex filename
16490 24 12 16526 408e kernel/trace/ring_buffer.o
[ Impact: smaller more efficient code ]
Signed-off-by: Steven Rostedt <rostedt@goodmis.org>
Diffstat (limited to 'kernel/trace/ring_buffer.c')
-rw-r--r-- | kernel/trace/ring_buffer.c | 14 |
1 files changed, 9 insertions, 5 deletions
diff --git a/kernel/trace/ring_buffer.c b/kernel/trace/ring_buffer.c index fe40f6c3507c..493cba46abc9 100644 --- a/kernel/trace/ring_buffer.c +++ b/kernel/trace/ring_buffer.c | |||
@@ -367,6 +367,9 @@ static inline int test_time_stamp(u64 delta) | |||
367 | 367 | ||
368 | #define BUF_PAGE_SIZE (PAGE_SIZE - BUF_PAGE_HDR_SIZE) | 368 | #define BUF_PAGE_SIZE (PAGE_SIZE - BUF_PAGE_HDR_SIZE) |
369 | 369 | ||
370 | /* Max payload is BUF_PAGE_SIZE - header (8bytes) */ | ||
371 | #define BUF_MAX_DATA_SIZE (BUF_PAGE_SIZE - (sizeof(u32) * 2)) | ||
372 | |||
370 | int ring_buffer_print_page_header(struct trace_seq *s) | 373 | int ring_buffer_print_page_header(struct trace_seq *s) |
371 | { | 374 | { |
372 | struct buffer_data_page field; | 375 | struct buffer_data_page field; |
@@ -1396,6 +1399,7 @@ rb_reserve_next_event(struct ring_buffer_per_cpu *cpu_buffer, | |||
1396 | int commit = 0; | 1399 | int commit = 0; |
1397 | int nr_loops = 0; | 1400 | int nr_loops = 0; |
1398 | 1401 | ||
1402 | length = rb_calculate_event_length(length); | ||
1399 | again: | 1403 | again: |
1400 | /* | 1404 | /* |
1401 | * We allow for interrupts to reenter here and do a trace. | 1405 | * We allow for interrupts to reenter here and do a trace. |
@@ -1552,8 +1556,7 @@ ring_buffer_lock_reserve(struct ring_buffer *buffer, unsigned long length) | |||
1552 | if (atomic_read(&cpu_buffer->record_disabled)) | 1556 | if (atomic_read(&cpu_buffer->record_disabled)) |
1553 | goto out; | 1557 | goto out; |
1554 | 1558 | ||
1555 | length = rb_calculate_event_length(length); | 1559 | if (length > BUF_MAX_DATA_SIZE) |
1556 | if (length > BUF_PAGE_SIZE) | ||
1557 | goto out; | 1560 | goto out; |
1558 | 1561 | ||
1559 | event = rb_reserve_next_event(cpu_buffer, length); | 1562 | event = rb_reserve_next_event(cpu_buffer, length); |
@@ -1758,7 +1761,6 @@ int ring_buffer_write(struct ring_buffer *buffer, | |||
1758 | { | 1761 | { |
1759 | struct ring_buffer_per_cpu *cpu_buffer; | 1762 | struct ring_buffer_per_cpu *cpu_buffer; |
1760 | struct ring_buffer_event *event; | 1763 | struct ring_buffer_event *event; |
1761 | unsigned long event_length; | ||
1762 | void *body; | 1764 | void *body; |
1763 | int ret = -EBUSY; | 1765 | int ret = -EBUSY; |
1764 | int cpu, resched; | 1766 | int cpu, resched; |
@@ -1781,8 +1783,10 @@ int ring_buffer_write(struct ring_buffer *buffer, | |||
1781 | if (atomic_read(&cpu_buffer->record_disabled)) | 1783 | if (atomic_read(&cpu_buffer->record_disabled)) |
1782 | goto out; | 1784 | goto out; |
1783 | 1785 | ||
1784 | event_length = rb_calculate_event_length(length); | 1786 | if (length > BUF_MAX_DATA_SIZE) |
1785 | event = rb_reserve_next_event(cpu_buffer, event_length); | 1787 | goto out; |
1788 | |||
1789 | event = rb_reserve_next_event(cpu_buffer, length); | ||
1786 | if (!event) | 1790 | if (!event) |
1787 | goto out; | 1791 | goto out; |
1788 | 1792 | ||