[PATCH v2 0/4] ring-buffer: Making persistent ring buffers robust

From: Masami Hiramatsu (Google)

Date: Wed Feb 18 2026 - 05:23:30 EST


Hi,

Here is a series of improvement patches for making persistent
ring buffers robust to failures. This fixes some issues of
persistent ring buffer on real machines.
We naively assumed that event data stored in a persistent ring
buffer would be preserved across reboots. However, event data
is written on the hardware cache and is not flushed on reboot.
As a result, the data on the ring buffer will be partially
corrupted, which will be detected during startup validation
and all ring buffer data will be erased. (I have actually
observed this on an actual arm64 machine.)

To fix these issues, this series introduces following patches;

- [1/4] Fix to check event length before using it, because
if event data is partially saved, the data length will be
completely wrong and the rb_read_data_buffer() will access
invalid address (which crashes kernel at boot).

- [2/4] Flush and stop persistent ring buffer on panic.
For the kernel panic case, we can use callback to stop event
recording and flush hardware cache for the persistent memory.
This ensures that the ring buffer data is written to memory
in the event of a panic.

- [3/4] Skip invalid sub-buffers when validating persistent
ring buffer. Instead of invalidating whole CPU buffer,
invalidate only corrupted sub buffer.

- [4/4] Record invalid buffer event on invalidated buffer for
notifying users which sub-buffer was corrupted.

[3/4] and [4/4] could be combined, but I have separated them
for ease of review.

Thank you,

---

Masami Hiramatsu (Google) (4):
ring-buffer: Fix to check event length before using
ring-buffer: Flush and stop persistent ring buffer on panic
ring-buffer: Skip invalid sub-buffers when validating persistent ring buffer
ring-buffer: Record invalid buffer event


kernel/trace/ring_buffer.c | 84 ++++++++++++++++++++++++++++++++++++------
kernel/trace/trace.h | 1 +
kernel/trace/trace_entries.h | 15 ++++++++
3 files changed, 87 insertions(+), 13 deletions(-)

--
Masami Hiramatsu (Google) <mhiramat@xxxxxxxxxx>