From: Markos Chandras <Markos.Chandras@imgtec.com>
To: Steven Rostedt <rostedt@goodmis.org>
Cc: "linux-mips@linux-mips.org" <linux-mips@linux-mips.org>,
<mingo@redhat.com>
Subject: Re: ftrace function graph with static ftrace does not work on MIPS
Date: Fri, 21 Nov 2014 09:33:44 +0000 [thread overview]
Message-ID: <546F06F8.4070500@imgtec.com> (raw)
In-Reply-To: <20141120110942.0bbc70a1@gandalf.local.home>
On 11/20/2014 04:09 PM, Steven Rostedt wrote:
> On Thu, 13 Nov 2014 09:23:45 +0000
> Markos Chandras <Markos.Chandras@imgtec.com> wrote:
>
>> Hi,
>>
>> I am trying to understand why ftrace function graph doesn't work when
>> using static ftrace on MIPS. So, what happens when I do 'echo
>> function_graph > current_tracer' is that the ftrace_graph_caller from
>> mcount.S is executed once. The function that called it is
>> 'core_kernel_data()' from __register_ftrace_function in
>> kernel/trace/ftrace.c
>>
>> However, this is the only function that is reported in the trace file
>>
>> # cat trace
>> # tracer: function_graph
>> #
>> # CPU DURATION FUNCTION CALLS
>> # | | | | | | |
>> 0) | core_kernel_data() {
>> 0) 0.000 us | } /* core_kernel_data */
>>
>> The reason that the ftrace_graph_caller is never executed after that is
>> that the following as far as I understand:
>>
>> NESTED(_mcount, PT_SIZE, ra)
>> PTR_LA t1, ftrace_stub
>> PTR_L t2, ftrace_trace_function /* Prepare t2 for (1) */
>> bne t1, t2, static_trace
>> nop
>>
>> #ifdef CONFIG_FUNCTION_GRAPH_TRACER
>> PTR_L t3, ftrace_graph_return
>> bne t1, t3, ftrace_graph_caller
>> nop
>> PTR_LA t1, ftrace_graph_entry_stub
>> PTR_L t3, ftrace_graph_entry
>> bne t1, t3, ftrace_graph_caller
>> nop
>> #endif
>>
>> The previous 3 conditionals exists in arch/mips/kernel/mcount.S.
>> Originally, ftrace_trace_function == ftrace_stub, so the first
>> conditional is not taken and we end up executed the ftrace_graph_caller.
>> All good.
>> However, later on, ftrace_trace_function is set to 'ftrace_ops_no_ops',
>> so the first 'bne' is taken and the ftrace_graph_caller is never
>> executed after that. It is not clear to me if this behaviour is expected
>> so I used QEMU to get a backtrace when ftrace_trace_function is set to
>> ftrace_ops_no_ops.
>
> Looks like the static tracing code in wrong. The function graph code
> should be tested every time.
>
> -- Steve
>
Hi Steven,
I had a look on
https://www.kernel.org/doc/Documentation/trace/ftrace-design.txt
and section "HAVE_FUNCTION_GRAPH_TRACER"
According to the sample code, first we check "ftrace_trace_function !=
ftrace_stub" and if that's true, then we never check the ftrace_graph_*
functions which is exactly what MIPS does. So the graph functions are
not always checked. x86 seems to do something similar in mcount_64.S
--
markos
WARNING: multiple messages have this Message-ID (diff)
From: Markos Chandras <Markos.Chandras@imgtec.com>
To: Steven Rostedt <rostedt@goodmis.org>
Cc: "linux-mips@linux-mips.org" <linux-mips@linux-mips.org>,
mingo@redhat.com
Subject: Re: ftrace function graph with static ftrace does not work on MIPS
Date: Fri, 21 Nov 2014 09:33:44 +0000 [thread overview]
Message-ID: <546F06F8.4070500@imgtec.com> (raw)
Message-ID: <20141121093344.nLUrCS17UMgSjUljIW3OMYOqkGX-oMUfOK9YVy9RzXE@z> (raw)
In-Reply-To: <20141120110942.0bbc70a1@gandalf.local.home>
On 11/20/2014 04:09 PM, Steven Rostedt wrote:
> On Thu, 13 Nov 2014 09:23:45 +0000
> Markos Chandras <Markos.Chandras@imgtec.com> wrote:
>
>> Hi,
>>
>> I am trying to understand why ftrace function graph doesn't work when
>> using static ftrace on MIPS. So, what happens when I do 'echo
>> function_graph > current_tracer' is that the ftrace_graph_caller from
>> mcount.S is executed once. The function that called it is
>> 'core_kernel_data()' from __register_ftrace_function in
>> kernel/trace/ftrace.c
>>
>> However, this is the only function that is reported in the trace file
>>
>> # cat trace
>> # tracer: function_graph
>> #
>> # CPU DURATION FUNCTION CALLS
>> # | | | | | | |
>> 0) | core_kernel_data() {
>> 0) 0.000 us | } /* core_kernel_data */
>>
>> The reason that the ftrace_graph_caller is never executed after that is
>> that the following as far as I understand:
>>
>> NESTED(_mcount, PT_SIZE, ra)
>> PTR_LA t1, ftrace_stub
>> PTR_L t2, ftrace_trace_function /* Prepare t2 for (1) */
>> bne t1, t2, static_trace
>> nop
>>
>> #ifdef CONFIG_FUNCTION_GRAPH_TRACER
>> PTR_L t3, ftrace_graph_return
>> bne t1, t3, ftrace_graph_caller
>> nop
>> PTR_LA t1, ftrace_graph_entry_stub
>> PTR_L t3, ftrace_graph_entry
>> bne t1, t3, ftrace_graph_caller
>> nop
>> #endif
>>
>> The previous 3 conditionals exists in arch/mips/kernel/mcount.S.
>> Originally, ftrace_trace_function == ftrace_stub, so the first
>> conditional is not taken and we end up executed the ftrace_graph_caller.
>> All good.
>> However, later on, ftrace_trace_function is set to 'ftrace_ops_no_ops',
>> so the first 'bne' is taken and the ftrace_graph_caller is never
>> executed after that. It is not clear to me if this behaviour is expected
>> so I used QEMU to get a backtrace when ftrace_trace_function is set to
>> ftrace_ops_no_ops.
>
> Looks like the static tracing code in wrong. The function graph code
> should be tested every time.
>
> -- Steve
>
Hi Steven,
I had a look on
https://www.kernel.org/doc/Documentation/trace/ftrace-design.txt
and section "HAVE_FUNCTION_GRAPH_TRACER"
According to the sample code, first we check "ftrace_trace_function !=
ftrace_stub" and if that's true, then we never check the ftrace_graph_*
functions which is exactly what MIPS does. So the graph functions are
not always checked. x86 seems to do something similar in mcount_64.S
--
markos
next prev parent reply other threads:[~2014-11-21 9:33 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-11-13 9:23 ftrace function graph with static ftrace does not work on MIPS Markos Chandras
2014-11-13 9:23 ` Markos Chandras
2014-11-20 16:09 ` Steven Rostedt
2014-11-20 16:09 ` Steven Rostedt
2014-11-21 9:33 ` Markos Chandras [this message]
2014-11-21 9:33 ` Markos Chandras
2014-11-21 21:31 ` Steven Rostedt
2014-11-21 21:31 ` Steven Rostedt
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=546F06F8.4070500@imgtec.com \
--to=markos.chandras@imgtec.com \
--cc=linux-mips@linux-mips.org \
--cc=mingo@redhat.com \
--cc=rostedt@goodmis.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.