Commit 9457158b authored by Alexander Z Lam's avatar Alexander Z Lam Committed by Steven Rostedt
Browse files

tracing: Fix reset of time stamps during trace_clock changes

Fixed two issues with changing the timestamp clock with trace_clock:

 - The global buffer was reset on instance clock changes. Change this to pass
   the correct per-instance buffer
 - ftrace_now() is used to set buf->time_start in tracing_reset_online_cpus().
   This was incorrect because ftrace_now() used the global buffer's clock to
   return the current time. Change this to use buffer_ftrace_now() which
   returns the current time for the correct per-instance buffer.

Also removed tracing_reset_current() because it is not used anywhere


Cc: Vaibhav Nagarnaik <>
Cc: David Sharp <>
Cc: Alexander Z Lam <>
Cc: # 3.10
Signed-off-by: default avatarAlexander Z Lam <>
Signed-off-by: default avatarSteven Rostedt <>
parent 711e1243
......@@ -243,20 +243,25 @@ int filter_current_check_discard(struct ring_buffer *buffer,
cycle_t ftrace_now(int cpu)
cycle_t buffer_ftrace_now(struct trace_buffer *buf, int cpu)
u64 ts;
/* Early boot up does not have a buffer yet */
if (!global_trace.trace_buffer.buffer)
if (!buf->buffer)
return trace_clock_local();
ts = ring_buffer_time_stamp(global_trace.trace_buffer.buffer, cpu);
ring_buffer_normalize_time_stamp(global_trace.trace_buffer.buffer, cpu, &ts);
ts = ring_buffer_time_stamp(buf->buffer, cpu);
ring_buffer_normalize_time_stamp(buf->buffer, cpu, &ts);
return ts;
cycle_t ftrace_now(int cpu)
return buffer_ftrace_now(&global_trace.trace_buffer, cpu);
* tracing_is_enabled - Show if global_trace has been disabled
......@@ -1211,7 +1216,7 @@ void tracing_reset_online_cpus(struct trace_buffer *buf)
/* Make sure all commits have finished */
buf->time_start = ftrace_now(buf->cpu);
buf->time_start = buffer_ftrace_now(buf, buf->cpu);
ring_buffer_reset_cpu(buffer, cpu);
......@@ -1219,11 +1224,6 @@ void tracing_reset_online_cpus(struct trace_buffer *buf)
void tracing_reset_current(int cpu)
tracing_reset(&global_trace.trace_buffer, cpu);
/* Must have trace_types_lock held */
void tracing_reset_all_online_cpus(void)
......@@ -4634,12 +4634,12 @@ static ssize_t tracing_clock_write(struct file *filp, const char __user *ubuf,
* New clock may not be consistent with the previous clock.
* Reset the buffer so that it doesn't have incomparable timestamps.
if (tr->flags & TRACE_ARRAY_FL_GLOBAL && tr->max_buffer.buffer)
ring_buffer_set_clock(tr->max_buffer.buffer, trace_clocks[i].func);
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment