Skip to content

Commit 804c4a2

Browse files
mhiramatrostedt
authored andcommitted
tracing: Reset last_boot_info if ring buffer is reset
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>
1 parent f844282 commit 804c4a2

1 file changed

Lines changed: 6 additions & 0 deletions

File tree

kernel/trace/trace.c

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4127,6 +4127,8 @@ static int tracing_single_release_tr(struct inode *inode, struct file *file)
41274127
return single_release(inode, file);
41284128
}
41294129

4130+
static bool update_last_data_if_empty(struct trace_array *tr);
4131+
41304132
static int tracing_open(struct inode *inode, struct file *file)
41314133
{
41324134
struct trace_array *tr = inode->i_private;
@@ -4151,6 +4153,8 @@ static int tracing_open(struct inode *inode, struct file *file)
41514153
tracing_reset_online_cpus(trace_buf);
41524154
else
41534155
tracing_reset_cpu(trace_buf, cpu);
4156+
4157+
update_last_data_if_empty(tr);
41544158
}
41554159

41564160
if (file->f_mode & FMODE_READ) {
@@ -5215,6 +5219,7 @@ tracing_set_trace_read(struct file *filp, char __user *ubuf,
52155219
int tracer_init(struct tracer *t, struct trace_array *tr)
52165220
{
52175221
tracing_reset_online_cpus(&tr->array_buffer);
5222+
update_last_data_if_empty(tr);
52185223
return t->init(tr);
52195224
}
52205225

@@ -7028,6 +7033,7 @@ int tracing_set_clock(struct trace_array *tr, const char *clockstr)
70287033
ring_buffer_set_clock(tr->snapshot_buffer.buffer, trace_clocks[i].func);
70297034
tracing_reset_online_cpus(&tr->snapshot_buffer);
70307035
#endif
7036+
update_last_data_if_empty(tr);
70317037

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

0 commit comments

Comments
 (0)