]> git.ipfire.org Git - thirdparty/kernel/linux.git/commit
ring-buffer: Add persistent ring buffer invalid-page inject test
authorMasami Hiramatsu (Google) <mhiramat@kernel.org>
Fri, 22 May 2026 17:09:00 +0000 (13:09 -0400)
committerSteven Rostedt <rostedt@goodmis.org>
Fri, 29 May 2026 02:40:51 +0000 (22:40 -0400)
commit68413a36f0051bd7ba7ea37ae2167951aeae5bd2
tree8dc4c373cc4880a55f8af87d96c84a1849cf161f
parentc8a7d4b4723a21e7464efe86dcf80627e0b4df33
ring-buffer: Add persistent ring buffer invalid-page inject test

Add a self-corrupting test for the persistent ring buffer.

This will inject an erroneous value to some sub-buffer pages (where
the index is even or multiples of 5) in the persistent ring buffer
when the kernel panics, and checks whether the number of detected
invalid pages and the total entry_bytes are the same as the recorded
values after reboot.

This ensures that the kernel can correctly recover a partially
corrupted persistent ring buffer after a reboot or panic.

The test only runs on the persistent ring buffer whose name is
"ptracingtest". The user has to fill it with events before a
kernel panic.

To run the test, enable CONFIG_RING_BUFFER_PERSISTENT_INJECT
and add the following kernel cmdline:

 reserve_mem=20M:2M:trace trace_instance=ptracingtest^traceoff@trace
 panic=1

Run the following commands after the 1st boot:

 cd /sys/kernel/tracing/instances/ptracingtest
 echo 1 > tracing_on
 echo 1 > events/enable
 sleep 3
 echo c > /proc/sysrq-trigger

After panic message, the kernel will reboot and run the verification
on the persistent ring buffer, e.g.

 Ring buffer meta [2] invalid buffer page detected
 Ring buffer meta [2] is from previous boot! (318 pages discarded)
 Ring buffer testing [2] invalid pages: PASSED (318/318)
 Ring buffer testing [2] entry_bytes: PASSED (1300476/1300476)

Link: https://patch.msgid.link/20260522171051.260140328@kernel.org
Signed-off-by: Masami Hiramatsu (Google) <mhiramat@kernel.org>
Signed-off-by: Steven Rostedt <rostedt@goodmis.org>
include/linux/ring_buffer.h
kernel/trace/Kconfig
kernel/trace/ring_buffer.c
kernel/trace/trace.c