Skip to content

Commit 60303ed

Browse files
David Sharprostedt
authored andcommitted
tracing: Reset ring buffer when changing trace_clocks
Because the "tsc" clock isn't in nanoseconds, the ring buffer must be reset when changing clocks so that incomparable timestamps don't end up in the same trace. Tested: Confirmed switching clocks resets the trace buffer. Google-Bug-Id: 6980623 Link: http://lkml.kernel.org/r/[email protected] Cc: Masami Hiramatsu <[email protected]> Signed-off-by: David Sharp <[email protected]> Signed-off-by: Steven Rostedt <[email protected]>
1 parent 60efc15 commit 60303ed

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

kernel/trace/trace.c

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4073,6 +4073,14 @@ static ssize_t tracing_clock_write(struct file *filp, const char __user *ubuf,
40734073
if (max_tr.buffer)
40744074
ring_buffer_set_clock(max_tr.buffer, trace_clocks[i].func);
40754075

4076+
/*
4077+
* New clock may not be consistent with the previous clock.
4078+
* Reset the buffer so that it doesn't have incomparable timestamps.
4079+
*/
4080+
tracing_reset_online_cpus(&global_trace);
4081+
if (max_tr.buffer)
4082+
tracing_reset_online_cpus(&max_tr);
4083+
40764084
mutex_unlock(&trace_types_lock);
40774085

40784086
*fpos += cnt;

0 commit comments

Comments
 (0)