Experimental Linux Patches Allow Kernel Tracing To Work Past Reboots/Crashes

Written by Michael Larabel in Linux Kernel on 7 March 2024 at 06:13 AM EST. 10 Comments
Steven Rostedt this week posted some interesting albeit experimental patches for the Linux kernel to support persistent traces that work across a reboot or crash.

The tentative patches allow for mapping a ring buffer instance across a reboot or crash rather than losing that information that can be useful in debugging issues. Rostedt explained with the initial kernel patches:
"This is a way to map a ring buffer instance across reboots. The requirement is that you have a memory region that is not erased. I tested this on a Debian VM running on qemu on a Debian server, and even tested it on a baremetal box running Fedora. I was surprised that it worked on the baremetal box, but it does so surprisingly consistently.
Finally, this is still a proof of concept. How to create this memory mapping isn't decided yet. In this patch set I simply hacked into kexec crash code and hard coded an address that worked for one of my machines (for the other machine I had to play around to find another address). Perhaps we could add a kernel command line parameter that lets people decided, or an option where it could possibly look at the ACPI (for intel) tables to come up with an address on its own.

Anyway, I plan on using this for debugging, as it already is pretty featureful but there's much more that can be done.

Basically, all you need to do is:

echo 1 > /sys/kernel/tracing/instances/boot_mapped/events/enable

Do what ever you want and the system crashes (and boots to the same kernel). Then:

cat /sys/kernel/tracing/instances/boot_mapped/trace

and it will have the trace.

I'm sure there's still some gotchas here, which is why this is currently still just a POC."

See this patch series for this interesting work that will hopefully evolve and at some point make it into the mainline Linux kernel.
Related News
About The Author
Michael Larabel

Michael Larabel is the principal author of Phoronix.com and founded the site in 2004 with a focus on enriching the Linux hardware experience. Michael has written more than 20,000 articles covering the state of Linux hardware support, Linux performance, graphics drivers, and other topics. Michael is also the lead developer of the Phoronix Test Suite, Phoromatic, and OpenBenchmarking.org automated benchmarking software. He can be followed via Twitter, LinkedIn, or contacted via MichaelLarabel.com.

Popular News This Week