From: Alan Kao <nonerkao@gmail.com>
To: Palmer Dabbelt <palmer@sifive.com>
Cc: Jim Wilson <jimw@sifive.com>,
albert@sifive.com, rostedt@goodmis.org, mingo@redhat.com,
patches@groups.riscv.org, linux-kernel@vger.kernel.org,
greentime@andestech.com, alankao@andestech.com,
pombredanne@nexb.com, kito@andestech.com
Subject: Re: [patches] [PATCH v2] riscv/ftrace: Add basic support
Date: Wed, 13 Dec 2017 08:57:39 +0800 [thread overview]
Message-ID: <20171213005735.GB26787@1a3c108b4593> (raw)
In-Reply-To: <mhng-2ff6fcb7-db72-482b-b70b-c925ae43c220@palmer-si-x1c4>
On Mon, Dec 11, 2017 at 10:15:58AM -0800, Palmer Dabbelt wrote:
> On Wed, 06 Dec 2017 18:31:10 PST (-0800), nonerkao@gmail.com wrote:
Hi Palmer,
I forgot to explain this section in the previous reply:
> > +ENTRY(_mcount)
> > + la t4, ftrace_stub
> > +#ifdef CONFIG_FUNCTION_GRAPH_TRACER
> > + la t0, ftrace_graph_return
> > + ld t1, 0(t0)
> > + bne t1, t4, do_ftrace_graph_caller
> > +
> > + la t3, ftrace_graph_entry
> > + ld t2, 0(t3)
> > + la t6, ftrace_graph_entry_stub
> > + bne t2, t6, do_ftrace_graph_caller
> > +#endif
> > + la t3, ftrace_trace_function
> > + ld t5, 0(t3)
> > + bne t5, t4, do_trace
> > + ret
>
> * You can save an instruction when addressing by using somethingl like "ld
> t1, ftrace_graph_return" instead of "la t0, ftrace_graph_return; ld t1
> 0(t0)".
>
There are three "la-ld" instruction pairs for loading ftrace_graph_return,
ftrace_graph_entry, and ftrace_trace_function. All of them are function
pointers in C. The problem here is that, if we applied an "ld" inst. to a
function pointer, we would have loaded the content, which would be the
first 8 bytes in the function, rather than the address of the target function
that the function pointer stored before.
In brief, the logic of the "la-ld" pairs should be fine.
Alan
prev parent reply other threads:[~2017-12-13 0:57 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-12-07 2:31 [PATCH v2] riscv/ftrace: Add basic support Alan Kao
2017-12-11 18:15 ` [patches] " Palmer Dabbelt
2017-12-12 7:08 ` Alan Kao
2017-12-12 17:47 ` Jim Wilson
2017-12-13 0:37 ` Steven Rostedt
2017-12-13 0:34 ` Steven Rostedt
2017-12-13 0:57 ` Alan Kao [this message]
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=20171213005735.GB26787@1a3c108b4593 \
--to=nonerkao@gmail.com \
--cc=alankao@andestech.com \
--cc=albert@sifive.com \
--cc=greentime@andestech.com \
--cc=jimw@sifive.com \
--cc=kito@andestech.com \
--cc=linux-kernel@vger.kernel.org \
--cc=mingo@redhat.com \
--cc=palmer@sifive.com \
--cc=patches@groups.riscv.org \
--cc=pombredanne@nexb.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox