]> git.ipfire.org Git - thirdparty/kernel/stable.git/commitdiff
tracing: Reset last_boot_info if ring buffer is reset
authorMasami Hiramatsu (Google) <mhiramat@kernel.org>
Tue, 10 Feb 2026 08:43:43 +0000 (17:43 +0900)
committerSasha Levin <sashal@kernel.org>
Wed, 4 Mar 2026 12:21:28 +0000 (07:21 -0500)
[ Upstream commit 804c4a2209bcf6ed4c45386f033e4d0f7c5bfda5 ]

Commit 32dc0042528d ("tracing: Reset last-boot buffers when reading
out all cpu buffers") resets the last_boot_info when user read out
all data via trace_pipe* files. But it is not reset when user
resets the buffer from other files. (e.g. write `trace` file)

Reset it when the corresponding ring buffer is reset too.

Cc: stable@vger.kernel.org
Cc: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
Link: https://patch.msgid.link/177071302364.2293046.17895165659153977720.stgit@mhiramat.tok.corp.google.com
Fixes: 32dc0042528d ("tracing: Reset last-boot buffers when reading out all cpu buffers")
Signed-off-by: Masami Hiramatsu (Google) <mhiramat@kernel.org>
Signed-off-by: Steven Rostedt (Google) <rostedt@goodmis.org>
Signed-off-by: Sasha Levin <sashal@kernel.org>
kernel/trace/trace.c

index e1d902464e08037ae8114c8bffd42597e547e57d..d2eabc162205c8502212eb0e155bf842afd11322 100644 (file)
@@ -4852,6 +4852,8 @@ static int tracing_single_release_tr(struct inode *inode, struct file *file)
        return single_release(inode, file);
 }
 
+static bool update_last_data_if_empty(struct trace_array *tr);
+
 static int tracing_open(struct inode *inode, struct file *file)
 {
        struct trace_array *tr = inode->i_private;
@@ -4876,6 +4878,8 @@ static int tracing_open(struct inode *inode, struct file *file)
                        tracing_reset_online_cpus(trace_buf);
                else
                        tracing_reset_cpu(trace_buf, cpu);
+
+               update_last_data_if_empty(tr);
        }
 
        if (file->f_mode & FMODE_READ) {
@@ -5917,6 +5921,7 @@ tracing_set_trace_read(struct file *filp, char __user *ubuf,
 int tracer_init(struct tracer *t, struct trace_array *tr)
 {
        tracing_reset_online_cpus(&tr->array_buffer);
+       update_last_data_if_empty(tr);
        return t->init(tr);
 }
 
@@ -7582,6 +7587,7 @@ int tracing_set_clock(struct trace_array *tr, const char *clockstr)
                ring_buffer_set_clock(tr->max_buffer.buffer, trace_clocks[i].func);
        tracing_reset_online_cpus(&tr->max_buffer);
 #endif
+       update_last_data_if_empty(tr);
 
        if (tr->scratch && !(tr->flags & TRACE_ARRAY_FL_LAST_BOOT)) {
                struct trace_scratch *tscratch = tr->scratch;