From: Wu Zhangjin <wuzhangjin@gmail.com>
To: David Daney <ddaney@caviumnetworks.com>
Cc: Ralf Baechle <ralf@linux-mips.org>,
Steven Rostedt <srostedt@redhat.com>,
linux-mips@linux-mips.org
Subject: Re: [PATCH] MIPS: tracing: Optimize the implementation
Date: Sat, 13 Mar 2010 12:10:36 +0800 [thread overview]
Message-ID: <1268453436.21443.10.camel@falcon> (raw)
In-Reply-To: <1268394209.6447.94.camel@falcon>
On Fri, 2010-03-12 at 19:43 +0800, Wu Zhangjin wrote:
[...]
> > > + * otherwise, it is in kernel space (0x80000000), return false.
> > > + */
> > > +#define in_module(ip) (unlikely((ip)& 0x40000000))
> > > +
> >
> > This isn't universally true, but it does hold for most configurations I
> > think.
>
> Although I'm not sure who is the exception, we always need an universal
> solution, what about this:
>
> Compare module with kernel:
>
> module:
>
> <saving registers>
>
> lui v1, hi16_mcount <--- ip
> addiu v1, v1, lo16_mcount
> move at, ra
> jalr v1
> nop
>
> kernel:
>
> <saving registers>
>
> move at, ra
> jal _mcount <--- ip
>
> The above _ip_ is the address have been recorded into the __mcount_loc
> section of the kernel by scripts/recordmcount.pl, as we can see, for
> kernel, the *(ip - 4) is "move at, ra": 03e0082d, a certain instruction,
> but for module, there is no possibility(?) of existing a "move at, ra"
> at *(ip -4) but a register saving operation("s {d,w} rs, offset(sp)",
> prefixed by 0xffb0 for 64bit and 0xafb0 for 32bit. ), and reversly, for
> kernel, there is no such instruction there.
>
> And consider the new option -mmcount-ra-address of gcc, some more
> instructions will be inserted between "move at, ra" and the calling site
> to mcount, so, *(ip-4) will not always be "move at, ra", then we need to
> check if there is a "s {d,w} rs, offset(sp)" there, if yes, it is in
> module, otherwise, it should be in kernel.
>
> #define S_RS_SP 0xafb00000 /* s{d,w} rs, offset(sp) */
>
> static inline int in_module(ip)
> {
> insn = *(ip - 4); /* need to use safe_load_code instead, what about big
> endian? */
>
> return ((insn & S_RS_SP) == S_RS_SP)
> }
The above method is not available for some cases, to avoid bring Ftrace
with extra overhead, currently, I will keep using the original version
although it may not work for some cases either.
And to let ftrace_make_nop/ftrace_make_call be lightweight, I will also
keep using the "b 1f" method in the old version.
Regards,
Wu Zhangjin
prev parent reply other threads:[~2010-03-13 4:17 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2010-03-11 18:07 [PATCH] MIPS: tracing: Optimize the implementation Wu Zhangjin
2010-03-12 8:50 ` Thomas Bogendoerfer
2010-03-12 10:11 ` Wu Zhangjin
2010-03-12 10:14 ` Ralf Baechle
2010-03-12 16:36 ` David Daney
[not found] ` <4B993B32.7000006@caviumnetworks.com>
2010-03-12 11:43 ` Wu Zhangjin
2010-03-12 14:57 ` Wu Zhangjin
2010-03-13 4:10 ` Wu Zhangjin [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=1268453436.21443.10.camel@falcon \
--to=wuzhangjin@gmail.com \
--cc=ddaney@caviumnetworks.com \
--cc=linux-mips@linux-mips.org \
--cc=ralf@linux-mips.org \
--cc=srostedt@redhat.com \
/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