Skip to content

Commit 9457158

Browse files
Alexander Z Lamrostedt
authored andcommitted
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 Link: http://lkml.kernel.org/r/1375493777-17261-2-git-send-email-azl@google.com Cc: Vaibhav Nagarnaik <vnagarnaik@google.com> Cc: David Sharp <dhsharp@google.com> Cc: Alexander Z Lam <lambchop468@gmail.com> Cc: stable@vger.kernel.org # 3.10 Signed-off-by: Alexander Z Lam <azl@google.com> Signed-off-by: Steven Rostedt <rostedt@goodmis.org>
1 parent 711e124 commit 9457158

1 file changed

Lines changed: 12 additions & 12 deletions

File tree

‎kernel/trace/trace.c‎

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -243,20 +243,25 @@ int filter_current_check_discard(struct ring_buffer *buffer,
243243
}
244244
EXPORT_SYMBOL_GPL(filter_current_check_discard);
245245

246-
cycle_t ftrace_now(int cpu)
246+
cycle_t buffer_ftrace_now(struct trace_buffer *buf, int cpu)
247247
{
248248
u64 ts;
249249

250250
/* Early boot up does not have a buffer yet */
251-
if (!global_trace.trace_buffer.buffer)
251+
if (!buf->buffer)
252252
return trace_clock_local();
253253

254-
ts = ring_buffer_time_stamp(global_trace.trace_buffer.buffer, cpu);
255-
ring_buffer_normalize_time_stamp(global_trace.trace_buffer.buffer, cpu, &ts);
254+
ts = ring_buffer_time_stamp(buf->buffer, cpu);
255+
ring_buffer_normalize_time_stamp(buf->buffer, cpu, &ts);
256256

257257
return ts;
258258
}
259259

260+
cycle_t ftrace_now(int cpu)
261+
{
262+
return buffer_ftrace_now(&global_trace.trace_buffer, cpu);
263+
}
264+
260265
/**
261266
* tracing_is_enabled - Show if global_trace has been disabled
262267
*
@@ -1211,19 +1216,14 @@ void tracing_reset_online_cpus(struct trace_buffer *buf)
12111216
/* Make sure all commits have finished */
12121217
synchronize_sched();
12131218

1214-
buf->time_start = ftrace_now(buf->cpu);
1219+
buf->time_start = buffer_ftrace_now(buf, buf->cpu);
12151220

12161221
for_each_online_cpu(cpu)
12171222
ring_buffer_reset_cpu(buffer, cpu);
12181223

12191224
ring_buffer_record_enable(buffer);
12201225
}
12211226

1222-
void tracing_reset_current(int cpu)
1223-
{
1224-
tracing_reset(&global_trace.trace_buffer, cpu);
1225-
}
1226-
12271227
/* Must have trace_types_lock held */
12281228
void tracing_reset_all_online_cpus(void)
12291229
{
@@ -4634,12 +4634,12 @@ static ssize_t tracing_clock_write(struct file *filp, const char __user *ubuf,
46344634
* New clock may not be consistent with the previous clock.
46354635
* Reset the buffer so that it doesn't have incomparable timestamps.
46364636
*/
4637-
tracing_reset_online_cpus(&global_trace.trace_buffer);
4637+
tracing_reset_online_cpus(&tr->trace_buffer);
46384638

46394639
#ifdef CONFIG_TRACER_MAX_TRACE
46404640
if (tr->flags & TRACE_ARRAY_FL_GLOBAL && tr->max_buffer.buffer)
46414641
ring_buffer_set_clock(tr->max_buffer.buffer, trace_clocks[i].func);
4642-
tracing_reset_online_cpus(&global_trace.max_buffer);
4642+
tracing_reset_online_cpus(&tr->max_buffer);
46434643
#endif
46444644

46454645
mutex_unlock(&trace_types_lock);

0 commit comments

Comments
 (0)