diff options
| author | Alexander Z Lam <azl@google.com> | 2013-08-02 21:36:16 -0400 |
|---|---|---|
| committer | Steven Rostedt <rostedt@goodmis.org> | 2013-08-02 22:40:09 -0400 |
| commit | 9457158bbc0ee04ecef76862d73eecd8076e9c7b (patch) | |
| tree | c2469bc10aefdfff49a4ffc588ce4aa1912e214d | |
| parent | 711e124379e0f889e40e2f01d7f5d61936d3cd23 (diff) | |
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>
| -rw-r--r-- | kernel/trace/trace.c | 24 |
1 files changed, 12 insertions, 12 deletions
diff --git a/kernel/trace/trace.c b/kernel/trace/trace.c index 531c9e69d0b3..496f94d57698 100644 --- a/kernel/trace/trace.c +++ b/kernel/trace/trace.c | |||
| @@ -243,20 +243,25 @@ int filter_current_check_discard(struct ring_buffer *buffer, | |||
| 243 | } | 243 | } |
| 244 | EXPORT_SYMBOL_GPL(filter_current_check_discard); | 244 | EXPORT_SYMBOL_GPL(filter_current_check_discard); |
| 245 | 245 | ||
| 246 | cycle_t ftrace_now(int cpu) | 246 | cycle_t buffer_ftrace_now(struct trace_buffer *buf, int cpu) |
| 247 | { | 247 | { |
| 248 | u64 ts; | 248 | u64 ts; |
| 249 | 249 | ||
| 250 | /* Early boot up does not have a buffer yet */ | 250 | /* Early boot up does not have a buffer yet */ |
| 251 | if (!global_trace.trace_buffer.buffer) | 251 | if (!buf->buffer) |
| 252 | return trace_clock_local(); | 252 | return trace_clock_local(); |
| 253 | 253 | ||
| 254 | ts = ring_buffer_time_stamp(global_trace.trace_buffer.buffer, cpu); | 254 | ts = ring_buffer_time_stamp(buf->buffer, cpu); |
| 255 | ring_buffer_normalize_time_stamp(global_trace.trace_buffer.buffer, cpu, &ts); | 255 | ring_buffer_normalize_time_stamp(buf->buffer, cpu, &ts); |
| 256 | 256 | ||
| 257 | return ts; | 257 | return ts; |
| 258 | } | 258 | } |
| 259 | 259 | ||
| 260 | cycle_t ftrace_now(int cpu) | ||
| 261 | { | ||
| 262 | return buffer_ftrace_now(&global_trace.trace_buffer, cpu); | ||
| 263 | } | ||
| 264 | |||
| 260 | /** | 265 | /** |
| 261 | * tracing_is_enabled - Show if global_trace has been disabled | 266 | * tracing_is_enabled - Show if global_trace has been disabled |
| 262 | * | 267 | * |
| @@ -1211,7 +1216,7 @@ void tracing_reset_online_cpus(struct trace_buffer *buf) | |||
| 1211 | /* Make sure all commits have finished */ | 1216 | /* Make sure all commits have finished */ |
| 1212 | synchronize_sched(); | 1217 | synchronize_sched(); |
| 1213 | 1218 | ||
| 1214 | buf->time_start = ftrace_now(buf->cpu); | 1219 | buf->time_start = buffer_ftrace_now(buf, buf->cpu); |
| 1215 | 1220 | ||
| 1216 | for_each_online_cpu(cpu) | 1221 | for_each_online_cpu(cpu) |
| 1217 | ring_buffer_reset_cpu(buffer, cpu); | 1222 | ring_buffer_reset_cpu(buffer, cpu); |
| @@ -1219,11 +1224,6 @@ void tracing_reset_online_cpus(struct trace_buffer *buf) | |||
| 1219 | ring_buffer_record_enable(buffer); | 1224 | ring_buffer_record_enable(buffer); |
| 1220 | } | 1225 | } |
| 1221 | 1226 | ||
| 1222 | void tracing_reset_current(int cpu) | ||
| 1223 | { | ||
| 1224 | tracing_reset(&global_trace.trace_buffer, cpu); | ||
| 1225 | } | ||
| 1226 | |||
| 1227 | /* Must have trace_types_lock held */ | 1227 | /* Must have trace_types_lock held */ |
| 1228 | void tracing_reset_all_online_cpus(void) | 1228 | void tracing_reset_all_online_cpus(void) |
| 1229 | { | 1229 | { |
| @@ -4634,12 +4634,12 @@ static ssize_t tracing_clock_write(struct file *filp, const char __user *ubuf, | |||
| 4634 | * New clock may not be consistent with the previous clock. | 4634 | * New clock may not be consistent with the previous clock. |
| 4635 | * Reset the buffer so that it doesn't have incomparable timestamps. | 4635 | * Reset the buffer so that it doesn't have incomparable timestamps. |
| 4636 | */ | 4636 | */ |
| 4637 | tracing_reset_online_cpus(&global_trace.trace_buffer); | 4637 | tracing_reset_online_cpus(&tr->trace_buffer); |
| 4638 | 4638 | ||
| 4639 | #ifdef CONFIG_TRACER_MAX_TRACE | 4639 | #ifdef CONFIG_TRACER_MAX_TRACE |
| 4640 | if (tr->flags & TRACE_ARRAY_FL_GLOBAL && tr->max_buffer.buffer) | 4640 | if (tr->flags & TRACE_ARRAY_FL_GLOBAL && tr->max_buffer.buffer) |
| 4641 | ring_buffer_set_clock(tr->max_buffer.buffer, trace_clocks[i].func); | 4641 | 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); |
| 4643 | #endif | 4643 | #endif |
| 4644 | 4644 | ||
| 4645 | mutex_unlock(&trace_types_lock); | 4645 | mutex_unlock(&trace_types_lock); |
