linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] ftrace: allow dumping traces without tracking trace started cpus
@ 2015-09-04 16:45 Sasha Levin
  2015-09-06  9:20 ` Minfei Huang
  0 siblings, 1 reply; 6+ messages in thread
From: Sasha Levin @ 2015-09-04 16:45 UTC (permalink / raw)
  To: rostedt, mingo; +Cc: linux-kernel, Sasha Levin

We don't init iter->started when dumping the ftrace buffer, and there's no
real need to do so - so allow skipping that check if the iter doesn't have
an initialized ->started cpumask.

Signed-off-by: Sasha Levin <sasha.levin@oracle.com>
---
 kernel/trace/trace.c |    5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/kernel/trace/trace.c b/kernel/trace/trace.c
index 6e79408..0dc647f 100644
--- a/kernel/trace/trace.c
+++ b/kernel/trace/trace.c
@@ -2671,13 +2671,14 @@ static void test_cpu_buff_start(struct trace_iterator *iter)
 	if (!(iter->iter_flags & TRACE_FILE_ANNOTATE))
 		return;
 
-	if (cpumask_test_cpu(iter->cpu, iter->started))
+	if (iter->started && cpumask_test_cpu(iter->cpu, iter->started))
 		return;
 
 	if (per_cpu_ptr(iter->trace_buffer->data, iter->cpu)->skipped_entries)
 		return;
 
-	cpumask_set_cpu(iter->cpu, iter->started);
+	if (iter->started)
+		cpumask_set_cpu(iter->cpu, iter->started);
 
 	/* Don't print started cpu buffer for the first entry of the trace */
 	if (iter->idx > 1)
-- 
1.7.10.4


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

* Re: [PATCH] ftrace: allow dumping traces without tracking trace started cpus
  2015-09-04 16:45 [PATCH] ftrace: allow dumping traces without tracking trace started cpus Sasha Levin
@ 2015-09-06  9:20 ` Minfei Huang
  2015-09-06 14:29   ` Sasha Levin
  0 siblings, 1 reply; 6+ messages in thread
From: Minfei Huang @ 2015-09-06  9:20 UTC (permalink / raw)
  To: Sasha Levin; +Cc: rostedt, mingo, linux-kernel

On 09/04/15 at 12:45pm, Sasha Levin wrote:
> We don't init iter->started when dumping the ftrace buffer, and there's no
> real need to do so - so allow skipping that check if the iter doesn't have
> an initialized ->started cpumask.
> 
> Signed-off-by: Sasha Levin <sasha.levin@oracle.com>
> ---
>  kernel/trace/trace.c |    5 +++--
>  1 file changed, 3 insertions(+), 2 deletions(-)
> 
> diff --git a/kernel/trace/trace.c b/kernel/trace/trace.c
> index 6e79408..0dc647f 100644
> --- a/kernel/trace/trace.c
> +++ b/kernel/trace/trace.c
> @@ -2671,13 +2671,14 @@ static void test_cpu_buff_start(struct trace_iterator *iter)
>  	if (!(iter->iter_flags & TRACE_FILE_ANNOTATE))
>  		return;
>  
> -	if (cpumask_test_cpu(iter->cpu, iter->started))
> +	if (iter->started && cpumask_test_cpu(iter->cpu, iter->started))
>  		return;

Ftrace will initialize the variable iter->started in the function
trace_init_global_iter. Otherwise kernel will panic during calling the
function cpumask_test_cpu.

So it is safe to call the function cpumask_test_cpu without doing
checking.

Thanks
Minfei

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

* Re: [PATCH] ftrace: allow dumping traces without tracking trace started cpus
  2015-09-06  9:20 ` Minfei Huang
@ 2015-09-06 14:29   ` Sasha Levin
  2015-09-08 14:13     ` Steven Rostedt
  0 siblings, 1 reply; 6+ messages in thread
From: Sasha Levin @ 2015-09-06 14:29 UTC (permalink / raw)
  To: Minfei Huang; +Cc: rostedt, mingo, linux-kernel

On 09/06/2015 05:20 AM, Minfei Huang wrote:
> On 09/04/15 at 12:45pm, Sasha Levin wrote:
>> > We don't init iter->started when dumping the ftrace buffer, and there's no
>> > real need to do so - so allow skipping that check if the iter doesn't have
>> > an initialized ->started cpumask.
>> > 
>> > Signed-off-by: Sasha Levin <sasha.levin@oracle.com>
>> > ---
>> >  kernel/trace/trace.c |    5 +++--
>> >  1 file changed, 3 insertions(+), 2 deletions(-)
>> > 
>> > diff --git a/kernel/trace/trace.c b/kernel/trace/trace.c
>> > index 6e79408..0dc647f 100644
>> > --- a/kernel/trace/trace.c
>> > +++ b/kernel/trace/trace.c
>> > @@ -2671,13 +2671,14 @@ static void test_cpu_buff_start(struct trace_iterator *iter)
>> >  	if (!(iter->iter_flags & TRACE_FILE_ANNOTATE))
>> >  		return;
>> >  
>> > -	if (cpumask_test_cpu(iter->cpu, iter->started))
>> > +	if (iter->started && cpumask_test_cpu(iter->cpu, iter->started))
>> >  		return;
> Ftrace will initialize the variable iter->started in the function
> trace_init_global_iter. Otherwise kernel will panic during calling the
> function cpumask_test_cpu.
> 
> So it is safe to call the function cpumask_test_cpu without doing
> checking.

Can you point me to exactly where trace_init_global_iter() initializes
iter->started?


Thanks,
Sasha

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

* Re: [PATCH] ftrace: allow dumping traces without tracking trace started cpus
  2015-09-06 14:29   ` Sasha Levin
@ 2015-09-08 14:13     ` Steven Rostedt
  2015-09-08 14:17       ` Sasha Levin
  0 siblings, 1 reply; 6+ messages in thread
From: Steven Rostedt @ 2015-09-08 14:13 UTC (permalink / raw)
  To: Sasha Levin; +Cc: Minfei Huang, mingo, linux-kernel

On Sun, 06 Sep 2015 10:29:43 -0400
Sasha Levin <sasha.levin@oracle.com> wrote:


> > So it is safe to call the function cpumask_test_cpu without doing
> > checking.
> 
> Can you point me to exactly where trace_init_global_iter() initializes
> iter->started?

Wouldn't the better solution be to initialize it in that function,
instead of checking if it is NULL? I think that's the true fix.
"started" should not be ignored.

-- Steve


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

* Re: [PATCH] ftrace: allow dumping traces without tracking trace started cpus
  2015-09-08 14:13     ` Steven Rostedt
@ 2015-09-08 14:17       ` Sasha Levin
  2015-09-08 15:37         ` Steven Rostedt
  0 siblings, 1 reply; 6+ messages in thread
From: Sasha Levin @ 2015-09-08 14:17 UTC (permalink / raw)
  To: Steven Rostedt; +Cc: Minfei Huang, mingo, linux-kernel

On 09/08/2015 10:13 AM, Steven Rostedt wrote:
> On Sun, 06 Sep 2015 10:29:43 -0400
> Sasha Levin <sasha.levin@oracle.com> wrote:
> 
> 
>>> So it is safe to call the function cpumask_test_cpu without doing
>>> checking.
>>
>> Can you point me to exactly where trace_init_global_iter() initializes
>> iter->started?
> 
> Wouldn't the better solution be to initialize it in that function,
> instead of checking if it is NULL? I think that's the true fix.
> "started" should not be ignored.

Yes, I agree that it would be nicer if we init it rather than ignore it,
but I wanted to avoid trying to do an extra allocation on this path since
it usually happens when the system oopsed, so allocations might be reliable
and we want to get the ftrace buffer out as reliably as we can.


Thanks,
Sasha


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

* Re: [PATCH] ftrace: allow dumping traces without tracking trace started cpus
  2015-09-08 14:17       ` Sasha Levin
@ 2015-09-08 15:37         ` Steven Rostedt
  0 siblings, 0 replies; 6+ messages in thread
From: Steven Rostedt @ 2015-09-08 15:37 UTC (permalink / raw)
  To: Sasha Levin; +Cc: Minfei Huang, mingo, linux-kernel

On Tue, 08 Sep 2015 10:17:15 -0400
Sasha Levin <sasha.levin@oracle.com> wrote:


> Yes, I agree that it would be nicer if we init it rather than ignore it,
> but I wanted to avoid trying to do an extra allocation on this path since
> it usually happens when the system oopsed, so allocations might be reliable
> and we want to get the ftrace buffer out as reliably as we can.

Fair enough. I'll keep the patch as is then.

-- Steve

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

end of thread, other threads:[~2015-09-08 15:37 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-09-04 16:45 [PATCH] ftrace: allow dumping traces without tracking trace started cpus Sasha Levin
2015-09-06  9:20 ` Minfei Huang
2015-09-06 14:29   ` Sasha Levin
2015-09-08 14:13     ` Steven Rostedt
2015-09-08 14:17       ` Sasha Levin
2015-09-08 15:37         ` Steven Rostedt

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