Skip to content

Commit afbab76

Browse files
Steven Rostedtrostedt
authored andcommitted
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: Steven Rostedt <rostedt@goodmis.org>
1 parent 778c55d commit afbab76

1 file changed

Lines changed: 3 additions & 25 deletions

File tree

‎kernel/trace/ring_buffer.c‎

Lines changed: 3 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -2785,28 +2785,6 @@ int ring_buffer_swap_cpu(struct ring_buffer *buffer_a,
27852785
}
27862786
EXPORT_SYMBOL_GPL(ring_buffer_swap_cpu);
27872787

2788-
static void rb_remove_entries(struct ring_buffer_per_cpu *cpu_buffer,
2789-
struct buffer_data_page *bpage,
2790-
unsigned int offset)
2791-
{
2792-
struct ring_buffer_event *event;
2793-
unsigned long head;
2794-
2795-
__raw_spin_lock(&cpu_buffer->lock);
2796-
for (head = offset; head < local_read(&bpage->commit);
2797-
head += rb_event_length(event)) {
2798-
2799-
event = __rb_data_page_index(bpage, head);
2800-
if (RB_WARN_ON(cpu_buffer, rb_null_event(event)))
2801-
return;
2802-
/* Only count data entries */
2803-
if (event->type_len > RINGBUF_TYPE_DATA_TYPE_LEN_MAX)
2804-
continue;
2805-
cpu_buffer->read++;
2806-
}
2807-
__raw_spin_unlock(&cpu_buffer->lock);
2808-
}
2809-
28102788
/**
28112789
* ring_buffer_alloc_read_page - allocate a page to read from buffer
28122790
* @buffer: the buffer to allocate for.
@@ -2977,6 +2955,9 @@ int ring_buffer_read_page(struct ring_buffer *buffer,
29772955
/* we copied everything to the beginning */
29782956
read = 0;
29792957
} else {
2958+
/* update the entry counter */
2959+
cpu_buffer->read += local_read(&reader->entries);
2960+
29802961
/* swap the pages */
29812962
rb_init_page(bpage);
29822963
bpage = reader->page;
@@ -2985,9 +2966,6 @@ int ring_buffer_read_page(struct ring_buffer *buffer,
29852966
local_set(&reader->entries, 0);
29862967
reader->read = 0;
29872968
*data_page = bpage;
2988-
2989-
/* update the entry counter */
2990-
rb_remove_entries(cpu_buffer, bpage, read);
29912969
}
29922970
ret = read;
29932971

0 commit comments

Comments
 (0)