Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 3c05d748 authored by Steven Rostedt's avatar Steven Rostedt Committed by Steven Rostedt
Browse files

ring-buffer: Check for end of page in iterator



If the iterator comes to an empty page for some reason, or if
the page is emptied by a consuming read. The iterator code currently
does not check if the iterator is pass the contents, and may
return a false entry.

This patch adds a check to the ring buffer iterator to test if the
current page has been completely read and sets the iterator to the
next page if necessary.

Signed-off-by: default avatarSteven Rostedt <rostedt@goodmis.org>
parent 492a74f4
Loading
Loading
Loading
Loading
+8 −3
Original line number Original line Diff line number Diff line
@@ -3064,9 +3064,6 @@ rb_iter_peek(struct ring_buffer_iter *iter, u64 *ts)
	struct ring_buffer_event *event;
	struct ring_buffer_event *event;
	int nr_loops = 0;
	int nr_loops = 0;


	if (ring_buffer_iter_empty(iter))
		return NULL;

	cpu_buffer = iter->cpu_buffer;
	cpu_buffer = iter->cpu_buffer;
	buffer = cpu_buffer->buffer;
	buffer = cpu_buffer->buffer;


@@ -3080,6 +3077,9 @@ rb_iter_peek(struct ring_buffer_iter *iter, u64 *ts)
		rb_iter_reset(iter);
		rb_iter_reset(iter);


 again:
 again:
	if (ring_buffer_iter_empty(iter))
		return NULL;

	/*
	/*
	 * We repeat when a timestamp is encountered.
	 * We repeat when a timestamp is encountered.
	 * We can get multiple timestamps by nested interrupts or also
	 * We can get multiple timestamps by nested interrupts or also
@@ -3094,6 +3094,11 @@ rb_iter_peek(struct ring_buffer_iter *iter, u64 *ts)
	if (rb_per_cpu_empty(cpu_buffer))
	if (rb_per_cpu_empty(cpu_buffer))
		return NULL;
		return NULL;


	if (iter->head >= local_read(&iter->head_page->page->commit)) {
		rb_inc_iter(iter);
		goto again;
	}

	event = rb_iter_head_event(iter);
	event = rb_iter_head_event(iter);


	switch (event->type_len) {
	switch (event->type_len) {