Skip to contentSkip to conversation

ftrace: allow dumping traces without tracking trace started cpus

PATCH In review Sasha Levin 3 participants 6 messages Sep 4, 2015 – Sep 8, 2015 Tracing

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 ftrace: allow dumping traces without tracking trace started cpus

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.

---
 kernel/trace/trace.c |    5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)
kernel/trace/trace.c +3 -2
index 6e79408..0dc647f 100644
@@ -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)
Signature · 1 line
1.7.10.4
#1 lore raw
Quoted 14 lines · 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.

---
 kernel/trace/trace.c |    5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)
kernel/trace/trace.c +0 -0
index 6e79408..0dc647f 100644

kernel/trace/trace.c static void test_cpu_buff_start(struct trace_iterator *iter) · line 2675

Quoted 6 lines
kernel/trace/trace.c +1 -1
@@ -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

#2 lore raw
Quoted 25 lines · Minfei Huang
Quoted 17 lines · Sasha Levin
Quoted 17 lines

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.

---
 kernel/trace/trace.c |    5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)
kernel/trace/trace.c +0 -0
index 6e79408..0dc647f 100644
@@ -2671,13 +2671,14 @@ static void test_cpu_buff_start(struct trace_iterator *iter)
 	if (!(iter->iter_flags & TRACE_FILE_ANNOTATE))
 		return;
 
Quoted 3 lines

kernel/trace/trace.c static void test_cpu_buff_start(struct trace_iterator *iter) · line 2675

Quoted 3 lines
kernel/trace/trace.c +1 -1
-	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.

Quoted 2 lines

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

maintainer
#3 lore raw
Quoted 5 lines · On Sun, 06 Sep 2015 10:29:43 -0400 Sasha Levin <[email protected]> wrote:
Quoted 2 lines

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

#4 lore raw
Quoted 7 lines · Steven Rostedt
Quoted 3 lines · On Sun, 06 Sep 2015 10:29:43 -0400 Sasha Levin <[email protected]> wrote:
Quoted 2 lines

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

Quoted 6 lines
Quoted 2 lines

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

maintainer
#5 lore raw
Quoted 4 lines · On Tue, 08 Sep 2015 10:17:15 -0400 Sasha Levin <[email protected]> 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