# \[RFC PATCH 2/2\] tracing: Record and show boot ID in last\_boot\_info

- From: Masami Hiramatsu (Google) \<mhiramat@kernel.org\>
- Date: 2026-05-21 14:57:19 
- List: linux-trace-kernel
- Page: https://ratatoskr.run/linux-trace-kernel/2026/05/17015463
- Thread: https://ratatoskr.run/linux-trace-kernel/2026/05/17015461/t.md

```text
From: Masami Hiramatsu (Google) <mhiramat@kernel.org>

Record the boot ID (random UUID for each boot) when tracing on the
persistent ring buffer and show it in the last_boot_info file.
User can use this boot ID when cross-referencing it with other logs.

For example:

  # cat /proc/sys/kernel/random/boot_id
 df152e7a-c0a7-4d32-9f0b-7f5c39fb7b68

 (enable tracing on persistent instance and reboot)

  # cat /sys/kernel/tracing/instances/ptracingtest/last_boot_info
 # boot_id: df152e7a-c0a7-4d32-9f0b-7f5c39fb7b68
 ffffffff81000000	[kernel]

 Thus, if user saves the other logs with this boot_id,
 user can easily find the appropriate logs.

Signed-off-by: Masami Hiramatsu (Google) <mhiramat@kernel.org>
---
 kernel/trace/trace.c |   14 ++++++++++++--
 1 file changed, 12 insertions(+), 2 deletions(-)

diff --git a/kernel/trace/trace.c b/kernel/trace/trace.c
index 6eb4d3097a4d..c56694bb5e0c 100644
--- a/kernel/trace/trace.c
+++ b/kernel/trace/trace.c
@@ -34,10 +34,12 @@
 #include <linux/percpu.h>
 #include <linux/splice.h>
 #include <linux/kdebug.h>
+#include <linux/random.h>
 #include <linux/string.h>
 #include <linux/mount.h>
 #include <linux/rwsem.h>
 #include <linux/slab.h>
+#include <linux/uuid.h>
 #include <linux/ctype.h>
 #include <linux/init.h>
 #include <linux/panic_notifier.h>
@@ -4804,6 +4806,7 @@ struct trace_mod_entry {
 struct trace_scratch {
 	unsigned int		clock_id;
 	unsigned long		text_addr;
+	u8			boot_id[UUID_SIZE];
 	unsigned long		nr_entries;
 	struct trace_mod_entry	entries[];
 };
@@ -4921,6 +4924,7 @@ static void update_last_data(struct trace_array *tr)
 	/* Reset the module list and reload them */
 	if (tr->scratch) {
 		struct trace_scratch *tscratch = tr->scratch;
+		const u8 *boot_id = get_boot_id();
 
 		tscratch->clock_id = tr->clock_id;
 		memset(tscratch->entries, 0,
@@ -4929,6 +4933,11 @@ static void update_last_data(struct trace_array *tr)
 
 		guard(mutex)(&scratch_mutex);
 		module_for_each_mod(save_mod, tr);
+		/* Also, update boot ID if exists */
+		if (boot_id)
+			memcpy(tscratch->boot_id, boot_id, sizeof(tscratch->boot_id));
+		else
+			memset(tscratch->boot_id, 0, sizeof(tscratch->boot_id));
 	}
 
 	/*
@@ -5822,9 +5831,10 @@ static void show_last_boot_header(struct seq_file *m, struct trace_array *tr)
 	 * Otherwise it shows the KASLR address from the previous boot which
 	 * should not be the same as the current boot.
 	 */
-	if (tscratch && (tr->flags & TRACE_ARRAY_FL_LAST_BOOT))
+	if (tscratch && (tr->flags & TRACE_ARRAY_FL_LAST_BOOT)) {
+		seq_printf(m, "# boot_id: %pUb\n", tscratch->boot_id);
 		seq_printf(m, "%lx\t[kernel]\n", tscratch->text_addr);
-	else
+	} else
 		seq_puts(m, "# Current\n");
 }
 

```
