linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [for-next-3.11][PATCH 0/4] tracing
@ 2013-08-03 12:49 Steven Rostedt
  2013-08-03 12:49 ` [for-next-3.11][PATCH 1/4] tracing: Fix fields of struct trace_iterator that are zeroed by mistake Steven Rostedt
                   ` (3 more replies)
  0 siblings, 4 replies; 7+ messages in thread
From: Steven Rostedt @ 2013-08-03 12:49 UTC (permalink / raw)
  To: linux-kernel; +Cc: Ingo Molnar, Frederic Weisbecker, Andrew Morton

Hopefully this is the last of the fixes for 3.11. Famous last words.
These are some minor bug fixes, but still should be in 3.11 and stable.

-- Steve

  git://git.kernel.org/pub/scm/linux/kernel/git/rostedt/linux-trace.git
for-next

Head SHA1: 9457158bbc0ee04ecef76862d73eecd8076e9c7b


Alexander Z Lam (2):
      tracing: Make TRACE_ITER_STOP_ON_FREE stop the correct buffer
      tracing: Fix reset of time stamps during trace_clock changes

Andrew Vagin (1):
      tracing: Fix fields of struct trace_iterator that are zeroed by mistake

Dhaval Giani (1):
      tracing: Fix trace_dump_stack() proto when CONFIG_TRACING is not set

----
 include/linux/ftrace_event.h |   10 ++++++----
 include/linux/kernel.h       |    2 +-
 kernel/trace/trace.c         |   27 ++++++++++++++-------------
 3 files changed, 21 insertions(+), 18 deletions(-)

^ permalink raw reply	[flat|nested] 7+ messages in thread

* [for-next-3.11][PATCH 1/4] tracing: Fix fields of struct trace_iterator that are zeroed by mistake
  2013-08-03 12:49 [for-next-3.11][PATCH 0/4] tracing Steven Rostedt
@ 2013-08-03 12:49 ` Steven Rostedt
  2013-08-03 12:49 ` [for-next-3.11][PATCH 2/4] tracing: Fix trace_dump_stack() proto when CONFIG_TRACING is not set Steven Rostedt
                   ` (2 subsequent siblings)
  3 siblings, 0 replies; 7+ messages in thread
From: Steven Rostedt @ 2013-08-03 12:49 UTC (permalink / raw)
  To: linux-kernel
  Cc: Ingo Molnar, Frederic Weisbecker, Andrew Morton, stable, Andrew Vagin

[-- Attachment #1: 0001-tracing-Fix-fields-of-struct-trace_iterator-that-are.patch --]
[-- Type: text/plain, Size: 2229 bytes --]

From: Andrew Vagin <avagin@openvz.org>

tracing_read_pipe zeros all fields bellow "seq". The declaration contains
a comment about that, but it doesn't help.

The first field is "snapshot", it's true when current open file is
snapshot. Looks obvious, that it should not be zeroed.

The second field is "started". It was converted from cpumask_t to
cpumask_var_t (v2.6.28-4983-g4462344), in other words it was
converted from cpumask to pointer on cpumask.

Currently the reference on "started" memory is lost after the first read
from tracing_read_pipe and a proper object will never be freed.

The "started" is never dereferenced for trace_pipe, because trace_pipe
can't have the TRACE_FILE_ANNOTATE options.

Link: http://lkml.kernel.org/r/1375463803-3085183-1-git-send-email-avagin@openvz.org

Cc: stable@vger.kernel.org # 2.6.30
Signed-off-by: Andrew Vagin <avagin@openvz.org>
Signed-off-by: Steven Rostedt <rostedt@goodmis.org>
---
 include/linux/ftrace_event.h |   10 ++++++----
 kernel/trace/trace.c         |    1 +
 2 files changed, 7 insertions(+), 4 deletions(-)

diff --git a/include/linux/ftrace_event.h b/include/linux/ftrace_event.h
index f98ab06..120d57a 100644
--- a/include/linux/ftrace_event.h
+++ b/include/linux/ftrace_event.h
@@ -78,6 +78,11 @@ struct trace_iterator {
 	/* trace_seq for __print_flags() and __print_symbolic() etc. */
 	struct trace_seq	tmp_seq;
 
+	cpumask_var_t		started;
+
+	/* it's true when current open file is snapshot */
+	bool			snapshot;
+
 	/* The below is zeroed out in pipe_read */
 	struct trace_seq	seq;
 	struct trace_entry	*ent;
@@ -90,10 +95,7 @@ struct trace_iterator {
 	loff_t			pos;
 	long			idx;
 
-	cpumask_var_t		started;
-
-	/* it's true when current open file is snapshot */
-	bool			snapshot;
+	/* All new field here will be zeroed out in pipe_read */
 };
 
 enum trace_iter_flags {
diff --git a/kernel/trace/trace.c b/kernel/trace/trace.c
index 882ec1d..f5b35a5 100644
--- a/kernel/trace/trace.c
+++ b/kernel/trace/trace.c
@@ -4151,6 +4151,7 @@ waitagain:
 	memset(&iter->seq, 0,
 	       sizeof(struct trace_iterator) -
 	       offsetof(struct trace_iterator, seq));
+	cpumask_clear(iter->started);
 	iter->pos = -1;
 
 	trace_event_read_lock();
-- 
1.7.10.4



^ permalink raw reply related	[flat|nested] 7+ messages in thread

* [for-next-3.11][PATCH 2/4] tracing: Fix trace_dump_stack() proto when CONFIG_TRACING is not set
  2013-08-03 12:49 [for-next-3.11][PATCH 0/4] tracing Steven Rostedt
  2013-08-03 12:49 ` [for-next-3.11][PATCH 1/4] tracing: Fix fields of struct trace_iterator that are zeroed by mistake Steven Rostedt
@ 2013-08-03 12:49 ` Steven Rostedt
  2013-08-03 12:49 ` [for-next-3.11][PATCH 3/4] tracing: Make TRACE_ITER_STOP_ON_FREE stop the correct buffer Steven Rostedt
  2013-08-03 12:49 ` [for-next-3.11][PATCH 4/4] tracing: Fix reset of time stamps during trace_clock changes Steven Rostedt
  3 siblings, 0 replies; 7+ messages in thread
From: Steven Rostedt @ 2013-08-03 12:49 UTC (permalink / raw)
  To: linux-kernel
  Cc: Ingo Molnar, Frederic Weisbecker, Andrew Morton, Dhaval Giani

[-- Attachment #1: 0002-tracing-Fix-trace_dump_stack-proto-when-CONFIG_TRACI.patch --]
[-- Type: text/plain, Size: 1035 bytes --]

From: Dhaval Giani <dhaval.giani@gmail.com>

When CONFIG_TRACING is not enabled, the stub prototype for trace_dump_stack()
is incorrect. It has (void) when it should be (int).

Link: http://lkml.kernel.org/r/CAPhKKr_H=ukFnBL4WgDOVT5ay2xeF-Ho+CA0DWZX0E2JW-=vSQ@mail.gmail.com

Signed-off-by: Dhaval Giani <dhaval.giani@gmail.com>
Signed-off-by: Steven Rostedt <rostedt@goodmis.org>
---
 include/linux/kernel.h |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/include/linux/kernel.h b/include/linux/kernel.h
index 3bef14c..482ad2d 100644
--- a/include/linux/kernel.h
+++ b/include/linux/kernel.h
@@ -629,7 +629,7 @@ extern void ftrace_dump(enum ftrace_dump_mode oops_dump_mode);
 static inline void tracing_start(void) { }
 static inline void tracing_stop(void) { }
 static inline void ftrace_off_permanent(void) { }
-static inline void trace_dump_stack(void) { }
+static inline void trace_dump_stack(int skip) { }
 
 static inline void tracing_on(void) { }
 static inline void tracing_off(void) { }
-- 
1.7.10.4



^ permalink raw reply related	[flat|nested] 7+ messages in thread

* [for-next-3.11][PATCH 3/4] tracing: Make TRACE_ITER_STOP_ON_FREE stop the correct buffer
  2013-08-03 12:49 [for-next-3.11][PATCH 0/4] tracing Steven Rostedt
  2013-08-03 12:49 ` [for-next-3.11][PATCH 1/4] tracing: Fix fields of struct trace_iterator that are zeroed by mistake Steven Rostedt
  2013-08-03 12:49 ` [for-next-3.11][PATCH 2/4] tracing: Fix trace_dump_stack() proto when CONFIG_TRACING is not set Steven Rostedt
@ 2013-08-03 12:49 ` Steven Rostedt
  2013-08-03 12:49 ` [for-next-3.11][PATCH 4/4] tracing: Fix reset of time stamps during trace_clock changes Steven Rostedt
  3 siblings, 0 replies; 7+ messages in thread
From: Steven Rostedt @ 2013-08-03 12:49 UTC (permalink / raw)
  To: linux-kernel
  Cc: Ingo Molnar, Frederic Weisbecker, Andrew Morton,
	Vaibhav Nagarnaik, David Sharp, Alexander Z Lam, stable,
	Alexander Z Lam

[-- Attachment #1: 0003-tracing-Make-TRACE_ITER_STOP_ON_FREE-stop-the-correc.patch --]
[-- Type: text/plain, Size: 1085 bytes --]

From: Alexander Z Lam <azl@google.com>

Releasing the free_buffer file in an instance causes the global buffer
to be stopped when TRACE_ITER_STOP_ON_FREE is enabled. Operate on the
correct buffer.

Link: http://lkml.kernel.org/r/1375493777-17261-1-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>
---
 kernel/trace/trace.c |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/kernel/trace/trace.c b/kernel/trace/trace.c
index f5b35a5..531c9e6 100644
--- a/kernel/trace/trace.c
+++ b/kernel/trace/trace.c
@@ -4469,7 +4469,7 @@ tracing_free_buffer_release(struct inode *inode, struct file *filp)
 
 	/* disable tracing ? */
 	if (trace_flags & TRACE_ITER_STOP_ON_FREE)
-		tracing_off();
+		tracer_tracing_off(tr);
 	/* resize the ring buffer to 0 */
 	tracing_resize_ring_buffer(tr, 0, RING_BUFFER_ALL_CPUS);
 
-- 
1.7.10.4



^ permalink raw reply related	[flat|nested] 7+ messages in thread

* [for-next-3.11][PATCH 4/4] tracing: Fix reset of time stamps during trace_clock changes
  2013-08-03 12:49 [for-next-3.11][PATCH 0/4] tracing Steven Rostedt
                   ` (2 preceding siblings ...)
  2013-08-03 12:49 ` [for-next-3.11][PATCH 3/4] tracing: Make TRACE_ITER_STOP_ON_FREE stop the correct buffer Steven Rostedt
@ 2013-08-03 12:49 ` Steven Rostedt
  2013-08-08 16:12   ` Steven Rostedt
  3 siblings, 1 reply; 7+ messages in thread
From: Steven Rostedt @ 2013-08-03 12:49 UTC (permalink / raw)
  To: linux-kernel
  Cc: Ingo Molnar, Frederic Weisbecker, Andrew Morton,
	Vaibhav Nagarnaik, David Sharp, Alexander Z Lam, stable,
	Alexander Z Lam

[-- Attachment #1: 0004-tracing-Fix-reset-of-time-stamps-during-trace_clock-.patch --]
[-- Type: text/plain, Size: 3309 bytes --]

From: Alexander Z Lam <azl@google.com>

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>
---
 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



^ permalink raw reply related	[flat|nested] 7+ messages in thread

* Re: [for-next-3.11][PATCH 4/4] tracing: Fix reset of time stamps during trace_clock changes
  2013-08-03 12:49 ` [for-next-3.11][PATCH 4/4] tracing: Fix reset of time stamps during trace_clock changes Steven Rostedt
@ 2013-08-08 16:12   ` Steven Rostedt
  2013-08-12  4:13     ` Greg Kroah-Hartman
  0 siblings, 1 reply; 7+ messages in thread
From: Steven Rostedt @ 2013-08-08 16:12 UTC (permalink / raw)
  To: linux-kernel, Greg Kroah-Hartman
  Cc: Ingo Molnar, Frederic Weisbecker, Andrew Morton,
	Vaibhav Nagarnaik, David Sharp, Alexander Z Lam, stable,
	Alexander Z Lam

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@google.com>
> 
> 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>
> ---
>  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);



^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [for-next-3.11][PATCH 4/4] tracing: Fix reset of time stamps during trace_clock changes
  2013-08-08 16:12   ` Steven Rostedt
@ 2013-08-12  4:13     ` Greg Kroah-Hartman
  0 siblings, 0 replies; 7+ messages in thread
From: Greg Kroah-Hartman @ 2013-08-12  4:13 UTC (permalink / raw)
  To: Steven Rostedt
  Cc: linux-kernel, Ingo Molnar, Frederic Weisbecker, Andrew Morton,
	Vaibhav Nagarnaik, David Sharp, Alexander Z Lam, stable,
	Alexander Z Lam

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

^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2013-08-12  4:12 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2013-08-03 12:49 [for-next-3.11][PATCH 0/4] tracing Steven Rostedt
2013-08-03 12:49 ` [for-next-3.11][PATCH 1/4] tracing: Fix fields of struct trace_iterator that are zeroed by mistake Steven Rostedt
2013-08-03 12:49 ` [for-next-3.11][PATCH 2/4] tracing: Fix trace_dump_stack() proto when CONFIG_TRACING is not set Steven Rostedt
2013-08-03 12:49 ` [for-next-3.11][PATCH 3/4] tracing: Make TRACE_ITER_STOP_ON_FREE stop the correct buffer Steven Rostedt
2013-08-03 12:49 ` [for-next-3.11][PATCH 4/4] tracing: Fix reset of time stamps during trace_clock changes Steven Rostedt
2013-08-08 16:12   ` Steven Rostedt
2013-08-12  4:13     ` Greg Kroah-Hartman

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).