ftrace: allow dumping traces without tracking trace started cpus
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
@@ -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
Quoted 14 lines · Sasha Levin
We don't init
iter->startedwhen 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 <[email protected]>--- kernel/trace/trace.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-)kernel/trace/trace.c +0
-0
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
Quoted 25 lines · Minfei Huang
Quoted 17 lines · Sasha Levin
Quoted 17 lines
We don't init
iter->startedwhen 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 <[email protected]>--- kernel/trace/trace.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-)kernel/trace/trace.c +0
-0@@ -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->startedin the functiontrace_init_global_iter. Otherwise kernel will panic during calling the functioncpumask_test_cpu.
Quoted 2 lines
So it is safe to call the function
cpumask_test_cpuwithout doing checking.
Can you point me to exactly where trace_init_global_iter() initializes iter->started?
Thanks,
Sasha
Steven Rostedt
maintainerQuoted 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_cpuwithout doing checking.Can you point me to exactly where
trace_init_global_iter()initializesiter->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
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_cpuwithout doing checking.
Quoted 6 lines
Quoted 2 lines
Can you point me to exactly where
trace_init_global_iter()initializesiter->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
Steven Rostedt
maintainerQuoted 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