public inbox for linux-trace-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH v2 0/4] ring-buffer: Making persistent ring buffers robust
@ 2026-02-18 10:14 Masami Hiramatsu (Google)
  2026-02-18 10:14 ` [PATCH v2 1/4] ring-buffer: Fix to check event length before using Masami Hiramatsu (Google)
                   ` (3 more replies)
  0 siblings, 4 replies; 9+ messages in thread
From: Masami Hiramatsu (Google) @ 2026-02-18 10:14 UTC (permalink / raw)
  To: Steven Rostedt
  Cc: Masami Hiramatsu, Mathieu Desnoyers, linux-kernel,
	linux-trace-kernel

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@kernel.org>

^ permalink raw reply	[flat|nested] 9+ messages in thread

end of thread, other threads:[~2026-02-23  7:39 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-02-18 10:14 [PATCH v2 0/4] ring-buffer: Making persistent ring buffers robust Masami Hiramatsu (Google)
2026-02-18 10:14 ` [PATCH v2 1/4] ring-buffer: Fix to check event length before using Masami Hiramatsu (Google)
2026-02-18 10:14 ` [PATCH v2 2/4] ring-buffer: Flush and stop persistent ring buffer on panic Masami Hiramatsu (Google)
2026-02-20 19:53   ` Steven Rostedt
2026-02-18 10:14 ` [PATCH v2 3/4] ring-buffer: Skip invalid sub-buffers when validating persistent ring buffer Masami Hiramatsu (Google)
2026-02-20 19:56   ` Steven Rostedt
2026-02-23  7:39     ` Masami Hiramatsu
2026-02-18 10:14 ` [PATCH v2 4/4] ring-buffer: Record invalid buffer event Masami Hiramatsu (Google)
2026-02-20 19:59   ` Steven Rostedt

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox