Login | Register For Free | Help
Search for: (Advanced)

Mailing List Archive: Linux: Kernel

[for-next-3.11][PATCH 4/4] tracing: Fix reset of time stamps during trace_clock changes

 

 

Linux kernel RSS feed   Index | Next | Previous | View Threaded


rostedt at goodmis

Aug 3, 2013, 5:49 AM

Post #1 of 3 (18 views)
Permalink
[for-next-3.11][PATCH 4/4] tracing: Fix reset of time stamps during trace_clock changes

From: Alexander Z Lam <azl [at] google>

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 [at] google

Cc: Vaibhav Nagarnaik <vnagarnaik [at] google>
Cc: David Sharp <dhsharp [at] google>
Cc: Alexander Z Lam <lambchop468 [at] gmail>
Cc: stable [at] vger # 3.10
Signed-off-by: Alexander Z Lam <azl [at] google>
Signed-off-by: Steven Rostedt <rostedt [at] goodmis>
---
kernel/trace/trace.c | 24 ++++++++++++------------
1 file changed, 12 insertions(+), 12 deletions(-)

diff --git a/kernel/trace/trace.c b/kernel/trace/trace.c
index 531c9e6..496f94d 100644
--- a/kernel/trace/trace.c
+++ b/kernel/trace/trace.c
@@ -243,20 +243,25 @@ int filter_current_check_discard(struct ring_buffer *buffer,
}
EXPORT_SYMBOL_GPL(filter_current_check_discard);

-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 */
synchronize_sched();

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

for_each_online_cpu(cpu)
ring_buffer_reset_cpu(buffer, cpu);
@@ -1219,11 +1224,6 @@ void tracing_reset_online_cpus(struct trace_buffer *buf)
ring_buffer_record_enable(buffer);
}

-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.
*/
- tracing_reset_online_cpus(&global_trace.trace_buffer);
+ tracing_reset_online_cpus(&tr->trace_buffer);

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

mutex_unlock(&trace_types_lock);
--
1.7.10.4


--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo [at] vger
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/


rostedt at goodmis

Aug 8, 2013, 9:12 AM

Post #2 of 3 (7 views)
Permalink
Re: [for-next-3.11][PATCH 4/4] tracing: Fix reset of time stamps during trace_clock changes [In reply to]

Greg,

I'm testing the backports, and I found that this patch depends on commit
10246fa35d4ffdfe472185d4cbf9c2dfd9a9f023 "tracing: Use flag
buffer_disabled for irqsoff tracer"

Please add that to 3.10 before applying this fix.

Thanks!

-- Steve


On Sat, 2013-08-03 at 08:49 -0400, Steven Rostedt wrote:
> plain text document attachment
> (0004-tracing-Fix-reset-of-time-stamps-during-trace_clock-.patch)
> From: Alexander Z Lam <azl [at] google>
>
> 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 [at] google
>
> Cc: Vaibhav Nagarnaik <vnagarnaik [at] google>
> Cc: David Sharp <dhsharp [at] google>
> Cc: Alexander Z Lam <lambchop468 [at] gmail>
> Cc: stable [at] vger # 3.10
> Signed-off-by: Alexander Z Lam <azl [at] google>
> Signed-off-by: Steven Rostedt <rostedt [at] goodmis>
> ---
> kernel/trace/trace.c | 24 ++++++++++++------------
> 1 file changed, 12 insertions(+), 12 deletions(-)
>
> diff --git a/kernel/trace/trace.c b/kernel/trace/trace.c
> index 531c9e6..496f94d 100644
> --- a/kernel/trace/trace.c
> +++ b/kernel/trace/trace.c
> @@ -243,20 +243,25 @@ int filter_current_check_discard(struct ring_buffer *buffer,
> }
> EXPORT_SYMBOL_GPL(filter_current_check_discard);
>
> -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 */
> synchronize_sched();
>
> - buf->time_start = ftrace_now(buf->cpu);
> + buf->time_start = buffer_ftrace_now(buf, buf->cpu);
>
> for_each_online_cpu(cpu)
> ring_buffer_reset_cpu(buffer, cpu);
> @@ -1219,11 +1224,6 @@ void tracing_reset_online_cpus(struct trace_buffer *buf)
> ring_buffer_record_enable(buffer);
> }
>
> -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.
> */
> - tracing_reset_online_cpus(&global_trace.trace_buffer);
> + tracing_reset_online_cpus(&tr->trace_buffer);
>
> #ifdef CONFIG_TRACER_MAX_TRACE
> if (tr->flags & TRACE_ARRAY_FL_GLOBAL && tr->max_buffer.buffer)
> ring_buffer_set_clock(tr->max_buffer.buffer, trace_clocks[i].func);
> - tracing_reset_online_cpus(&global_trace.max_buffer);
> + tracing_reset_online_cpus(&tr->max_buffer);
> #endif
>
> mutex_unlock(&trace_types_lock);


--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo [at] vger
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/


gregkh at linuxfoundation

Aug 11, 2013, 9:13 PM

Post #3 of 3 (6 views)
Permalink
Re: [for-next-3.11][PATCH 4/4] tracing: Fix reset of time stamps during trace_clock changes [In reply to]

On Thu, Aug 08, 2013 at 12:12:06PM -0400, Steven Rostedt wrote:
> Greg,
>
> I'm testing the backports, and I found that this patch depends on commit
> 10246fa35d4ffdfe472185d4cbf9c2dfd9a9f023 "tracing: Use flag
> buffer_disabled for irqsoff tracer"
>
> Please add that to 3.10 before applying this fix.

Oops, I sent out the "FAILED" email before seeing this, sorry about
that. I've applied this patch, and now the original one applies as
well, thanks.

greg k-h
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo [at] vger
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/

Linux kernel RSS feed   Index | Next | Previous | View Threaded
 
 


Interested in having your list archived? Contact Gossamer Threads
 
  Web Applications & Managed Hosting Powered by Gossamer Threads Inc.