Commit afbab76a authored by Steven Rostedt's avatar Steven Rostedt Committed by Steven Rostedt

ring-buffer: have read page swap increment counter with page entries

In the swap page ring buffer code that is used by the ftrace splice code,
we scan the page to increment the counter of entries read.

With the number of entries already in the page we simply need to add it.

[ Impact: speed up reading page from ring buffer ]
Signed-off-by: default avatarSteven Rostedt <rostedt@goodmis.org>
parent 778c55d4
...@@ -2785,28 +2785,6 @@ int ring_buffer_swap_cpu(struct ring_buffer *buffer_a, ...@@ -2785,28 +2785,6 @@ int ring_buffer_swap_cpu(struct ring_buffer *buffer_a,
} }
EXPORT_SYMBOL_GPL(ring_buffer_swap_cpu); EXPORT_SYMBOL_GPL(ring_buffer_swap_cpu);
static void rb_remove_entries(struct ring_buffer_per_cpu *cpu_buffer,
struct buffer_data_page *bpage,
unsigned int offset)
{
struct ring_buffer_event *event;
unsigned long head;
__raw_spin_lock(&cpu_buffer->lock);
for (head = offset; head < local_read(&bpage->commit);
head += rb_event_length(event)) {
event = __rb_data_page_index(bpage, head);
if (RB_WARN_ON(cpu_buffer, rb_null_event(event)))
return;
/* Only count data entries */
if (event->type_len > RINGBUF_TYPE_DATA_TYPE_LEN_MAX)
continue;
cpu_buffer->read++;
}
__raw_spin_unlock(&cpu_buffer->lock);
}
/** /**
* ring_buffer_alloc_read_page - allocate a page to read from buffer * ring_buffer_alloc_read_page - allocate a page to read from buffer
* @buffer: the buffer to allocate for. * @buffer: the buffer to allocate for.
...@@ -2977,6 +2955,9 @@ int ring_buffer_read_page(struct ring_buffer *buffer, ...@@ -2977,6 +2955,9 @@ int ring_buffer_read_page(struct ring_buffer *buffer,
/* we copied everything to the beginning */ /* we copied everything to the beginning */
read = 0; read = 0;
} else { } else {
/* update the entry counter */
cpu_buffer->read += local_read(&reader->entries);
/* swap the pages */ /* swap the pages */
rb_init_page(bpage); rb_init_page(bpage);
bpage = reader->page; bpage = reader->page;
...@@ -2985,9 +2966,6 @@ int ring_buffer_read_page(struct ring_buffer *buffer, ...@@ -2985,9 +2966,6 @@ int ring_buffer_read_page(struct ring_buffer *buffer,
local_set(&reader->entries, 0); local_set(&reader->entries, 0);
reader->read = 0; reader->read = 0;
*data_page = bpage; *data_page = bpage;
/* update the entry counter */
rb_remove_entries(cpu_buffer, bpage, read);
} }
ret = read; ret = read;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment