Skip to content

Commit 238b301

Browse files
rostedtgregkh
authored andcommitted
ring-buffer: Update pages_touched to reflect persistent buffer content
commit 9793783 upstream. The pages_touched field represents the number of subbuffers in the ring buffer that have content that can be read. This is used in accounting of "dirty_pages" and "buffer_percent" to allow the user to wait for the buffer to be filled to a certain amount before it reads the buffer in blocking mode. The persistent buffer never updated this value so it was set to zero, and this accounting would take it as it had no content. This would cause user space to wait for content even though there's enough content in the ring buffer that satisfies the buffer_percent. Cc: stable@vger.kernel.org Cc: Masami Hiramatsu <mhiramat@kernel.org> Cc: Mathieu Desnoyers <mathieu.desnoyers@efficios.com> Cc: Vincent Donnefort <vdonnefort@google.com> Link: https://lore.kernel.org/20250214123512.0631436e@gandalf.local.home Fixes: 5f3b6e8 ("ring-buffer: Validate boot range memory events") Signed-off-by: Steven Rostedt (Google) <rostedt@goodmis.org> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
1 parent 0d547a6 commit 238b301

File tree

1 file changed

+5
-0
lines changed

1 file changed

+5
-0
lines changed

kernel/trace/ring_buffer.c

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1850,6 +1850,11 @@ static void rb_meta_validate_events(struct ring_buffer_per_cpu *cpu_buffer)
18501850
cpu_buffer->cpu);
18511851
goto invalid;
18521852
}
1853+
1854+
/* If the buffer has content, update pages_touched */
1855+
if (ret)
1856+
local_inc(&cpu_buffer->pages_touched);
1857+
18531858
entries += ret;
18541859
entry_bytes += local_read(&head_page->page->commit);
18551860
local_set(&cpu_buffer->head_page->entries, ret);

0 commit comments

Comments
 (0)