Skip to content
/ linux Public

Commit 0b9c581

Browse files
mhiramatSasha Levin
authored andcommitted
tracing: Reset last_boot_info if ring buffer is reset
[ Upstream commit 804c4a2 ] Commit 32dc004 ("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: 32dc004 ("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>
1 parent 127f948 commit 0b9c581

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

kernel/trace/trace.c

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4852,6 +4852,8 @@ static int tracing_single_release_tr(struct inode *inode, struct file *file)
48524852
return single_release(inode, file);
48534853
}
48544854

4855+
static bool update_last_data_if_empty(struct trace_array *tr);
4856+
48554857
static int tracing_open(struct inode *inode, struct file *file)
48564858
{
48574859
struct trace_array *tr = inode->i_private;
@@ -4876,6 +4878,8 @@ static int tracing_open(struct inode *inode, struct file *file)
48764878
tracing_reset_online_cpus(trace_buf);
48774879
else
48784880
tracing_reset_cpu(trace_buf, cpu);
4881+
4882+
update_last_data_if_empty(tr);
48794883
}
48804884

48814885
if (file->f_mode & FMODE_READ) {
@@ -5917,6 +5921,7 @@ tracing_set_trace_read(struct file *filp, char __user *ubuf,
59175921
int tracer_init(struct tracer *t, struct trace_array *tr)
59185922
{
59195923
tracing_reset_online_cpus(&tr->array_buffer);
5924+
update_last_data_if_empty(tr);
59205925
return t->init(tr);
59215926
}
59225927

@@ -7582,6 +7587,7 @@ int tracing_set_clock(struct trace_array *tr, const char *clockstr)
75827587
ring_buffer_set_clock(tr->max_buffer.buffer, trace_clocks[i].func);
75837588
tracing_reset_online_cpus(&tr->max_buffer);
75847589
#endif
7590+
update_last_data_if_empty(tr);
75857591

75867592
if (tr->scratch && !(tr->flags & TRACE_ARRAY_FL_LAST_BOOT)) {
75877593
struct trace_scratch *tscratch = tr->scratch;

0 commit comments

Comments
 (0)