<feed xmlns='http://www.w3.org/2005/Atom'>
<title>kernel.git/arch/mips/kernel/ftrace.c, branch linux-2.6.37.y</title>
<subtitle>Hosts the 0x221E linux distro kernel.
</subtitle>
<id>https://git.0xinfinity.dev/distro/kernel.git/atom?h=linux-2.6.37.y</id>
<link rel='self' href='https://git.0xinfinity.dev/distro/kernel.git/atom?h=linux-2.6.37.y'/>
<link rel='alternate' type='text/html' href='https://git.0xinfinity.dev/distro/kernel.git/'/>
<updated>2010-07-05T16:17:30Z</updated>
<entry>
<title>MIPS: Tracing: Cleanup of address space checking</title>
<updated>2010-07-05T16:17:30Z</updated>
<author>
<name>Wu Zhangjin</name>
</author>
<published>2010-05-14T11:08:34Z</published>
<link rel='alternate' type='text/html' href='https://git.0xinfinity.dev/distro/kernel.git/commit/?id=c9f84873c1231621508cd438bb2991ddba770a69'/>
<id>urn:sha1:c9f84873c1231621508cd438bb2991ddba770a69</id>
<content type='text'>
This patch adds an inline function in_module() to check which space the
instruction pointer in, kernel space or module space.

Note:  This will not work when the kernel space and module space are the
same. If they are the same, we need to modify scripts/recordmcount.pl,
ftrace_make_nop/call() and the other related parts to ensure the
enabling/disabling of the calling site to _mcount is right for both
kernel and module.

[Ralf: It also is still incorrect for some 64-bit kernels.]

Signed-off-by: Wu Zhangjin &lt;wuzhangjin@gmail.com&gt;
Cc: linux-mips &lt;linux-mips@linux-mips.org&gt;
Cc: David Daney &lt;david.s.daney@gmail.com&gt;
Patchwork: http://patchwork.linux-mips.org/patch/1232/
Signed-off-by: Ralf Baechle &lt;ralf@linux-mips.org&gt;
</content>
</entry>
<entry>
<title>MIPS: Tracing: Cleanup of function graph tracer</title>
<updated>2010-07-05T16:17:30Z</updated>
<author>
<name>Wu Zhangjin</name>
</author>
<published>2010-05-14T11:08:33Z</published>
<link rel='alternate' type='text/html' href='https://git.0xinfinity.dev/distro/kernel.git/commit/?id=68ccf7521dc89bfcf01432fd1bf8cb4d7d534e4c'/>
<id>urn:sha1:68ccf7521dc89bfcf01432fd1bf8cb4d7d534e4c</id>
<content type='text'>
Cleans up comments and ftrace_get_parent_addr() of function graph tracer.

Signed-off-by: Wu Zhangjin &lt;wuzhangjin@gmail.com&gt;
Cc: linux-mips &lt;linux-mips@linux-mips.org&gt;
Cc: David Daney &lt;david.s.daney@gmail.com&gt;
Patchwork: http://patchwork.linux-mips.org/patch/1231/
Signed-off-by: Ralf Baechle &lt;ralf@linux-mips.org&gt;
</content>
</entry>
<entry>
<title>MIPS: Tracing: Reduce the overhead of dynamic Function Tracer</title>
<updated>2010-07-05T16:17:29Z</updated>
<author>
<name>Wu Zhangjin</name>
</author>
<published>2010-05-14T11:08:32Z</published>
<link rel='alternate' type='text/html' href='https://git.0xinfinity.dev/distro/kernel.git/commit/?id=e424054000878d7eb11e44289242886d6e219d22'/>
<id>urn:sha1:e424054000878d7eb11e44289242886d6e219d22</id>
<content type='text'>
With the help of uasm this patch encodes the instructions of the dynamic
function tracer in ftrace_dyn_arch_init() when initializing it.

As a result we can remove the dynamic encoding of instructions in
ftrace_make_nop()/call(), ftrace_enable_ftrace_graph_caller() and remove
the macro jump_insn_encode() and at last this reduce the overhead of
dynamic Function Tracer.  This also is cleaner.

Signed-off-by: Wu Zhangjin &lt;wuzhangjin@gmail.com&gt;
Cc: linux-mips &lt;linux-mips@linux-mips.org&gt;
Cc: David Daney &lt;david.s.daney@gmail.com&gt;
Patchwork: http://patchwork.linux-mips.org/patch/1230/
Signed-off-by: Ralf Baechle &lt;ralf@linux-mips.org&gt;
</content>
</entry>
<entry>
<title>MIPS: Tracing: Cleanup of instructions used</title>
<updated>2010-07-05T16:17:29Z</updated>
<author>
<name>Wu Zhangjin</name>
</author>
<published>2010-05-14T11:08:31Z</published>
<link rel='alternate' type='text/html' href='https://git.0xinfinity.dev/distro/kernel.git/commit/?id=4d6829f92a02d96e1bec2ffe6ee674ef3b49722b'/>
<id>urn:sha1:4d6829f92a02d96e1bec2ffe6ee674ef3b49722b</id>
<content type='text'>
This patch adds some cleanups of the instructions:
  o use macros instead of magic numbers
  o use macros instead of variables to reduce some overhead
  o add new macro for the jal instruction

Signed-off-by: Wu Zhangjin &lt;wuzhangjin@gmail.com&gt;
Cc: linux-mips &lt;linux-mips@linux-mips.org&gt;
Cc: David Daney &lt;david.s.daney@gmail.com&gt;
Patchwork: http://patchwork.linux-mips.org/patch/1229/
Signed-off-by: Ralf Baechle &lt;ralf@linux-mips.org&gt;
</content>
</entry>
<entry>
<title>MIPS: Tracing: Fix 32-bit support with -mmcount-ra-address</title>
<updated>2010-07-05T16:17:28Z</updated>
<author>
<name>Wu Zhangjin</name>
</author>
<published>2010-05-14T11:08:30Z</published>
<link rel='alternate' type='text/html' href='https://git.0xinfinity.dev/distro/kernel.git/commit/?id=3a2af2dc1bcbfe86b1f39e9e5f9c2c5447943f16'/>
<id>urn:sha1:3a2af2dc1bcbfe86b1f39e9e5f9c2c5447943f16</id>
<content type='text'>
For 32-bit kernel the -mmcount-ra-address option of gcc 4.5 emits one
extra instruction before calling to _mcount so we need to use a different
"b 1f" for it.

Signed-off-by: Wu Zhangjin &lt;wuzhangjin@gmail.com&gt;
Cc: linux-mips &lt;linux-mips@linux-mips.org&gt;
Cc: David Daney &lt;david.s.daney@gmail.com&gt;
Patchwork: http://patchwork.linux-mips.org/patch/1228/
Signed-off-by: Ralf Baechle &lt;ralf@linux-mips.org&gt;
</content>
</entry>
<entry>
<title>MIPS: Loongson: Change the Email address of Wu Zhangjin</title>
<updated>2010-02-27T11:53:12Z</updated>
<author>
<name>Wu Zhangjin</name>
</author>
<published>2010-01-04T09:16:51Z</published>
<link rel='alternate' type='text/html' href='https://git.0xinfinity.dev/distro/kernel.git/commit/?id=f7a904dffe30a02636053d8022498ced7e44d31c'/>
<id>urn:sha1:f7a904dffe30a02636053d8022498ced7e44d31c</id>
<content type='text'>
Currently wuzj@lemote.com is not usable; change it to wuzhangjin@gmail.com.

Signed-off-by: Wu Zhangjin &lt;wuzhangjin@gmail.com&gt;
Cc: linux-mips@linux-mips.org
Cc: yanh@lemote.com
Cc: huhb@lemote.com
Cc: zhangfx@lemote.com
Patchwork: http://patchwork.linux-mips.org/patch/829/
Signed-off-by: Ralf Baechle &lt;ralf@linux-mips.org&gt;
</content>
</entry>
<entry>
<title>MIPS: Tracing: Make function graph tracer work with -mmcount-ra-address</title>
<updated>2009-12-17T01:57:27Z</updated>
<author>
<name>Wu Zhangjin</name>
</author>
<published>2009-11-20T12:34:38Z</published>
<link rel='alternate' type='text/html' href='https://git.0xinfinity.dev/distro/kernel.git/commit/?id=7326c4e567b50e689d13c04d58aeffa515277ebb'/>
<id>urn:sha1:7326c4e567b50e689d13c04d58aeffa515277ebb</id>
<content type='text'>
That thread "MIPS: Add option to pass return address location to
_mcount" from "David Daney &lt;ddaney@caviumnetworks.com&gt;" have added a new
option -mmcount-ra-address to gcc(4.5) for MIPS to transfer the location
of the return address to _mcount.

Benefit from this new feature, function graph tracer on MIPS will be
easier and safer to hijack the return address of the kernel function,
which will save some overhead and make the whole thing more reliable.

In this patch, at first, try to enable the option -mmcount-ra-address in
arch/mips/Makefile with cc-option, if gcc support it, it will be
enabled, otherwise, no side effect.

and then, we need to support this new option of gcc 4.5 and also support
the old gcc versions.

with _mcount in the old gcc versions, it's not easy to get the location
of return address(tracing: add function graph tracer support for MIPS),
   so, we do it in a C function: ftrace_get_parent_addr(ftrace.c), but
   with -mmcount-ra-address, only several instructions need to get what
   we want, so, I put into asm(mcount.S). and also, as the $12(t0) is
   used by -mmcount-ra-address for transferring the localtion of return
   address to _mcount, we need to save it into the stack and restore it
   when enabled dynamic function tracer, 'Cause we have called
   "ftrace_call" before "ftrace_graph_caller", which may destroy
   $12(t0).

(Thanks to David for providing that -mcount-ra-address and giving the
 idea of KBUILD_MCOUNT_RA_ADDRESS, both of them have made the whole
 thing more beautiful!)

Signed-off-by: Wu Zhangjin &lt;wuzhangjin@gmail.com&gt;
Cc: Steven Rostedt &lt;rostedt@goodmis.org&gt;
Cc: Nicholas Mc Guire &lt;der.herr@hofr.at&gt;
Cc: zhangfx@lemote.com
Cc: Wu Zhangjin &lt;wuzhangjin@gmail.com&gt;
Cc: Ingo Molnar &lt;mingo@elte.hu&gt;
Cc: Thomas Gleixner &lt;tglx@linutronix.de&gt;
Cc: Frederic Weisbecker &lt;fweisbec@gmail.com&gt;
Cc: linux-kernel@vger.kernel.org
Cc: linux-mips@linux-mips.org
Patchwork: http://patchwork.linux-mips.org/patch/681/
Signed-off-by: Ralf Baechle &lt;ralf@linux-mips.org&gt;
</content>
</entry>
<entry>
<title>MIPS: Tracing: Make ftrace for MIPS work without -fno-omit-frame-pointer</title>
<updated>2009-12-17T01:57:25Z</updated>
<author>
<name>Wu Zhangjin</name>
</author>
<published>2009-11-20T12:34:36Z</published>
<link rel='alternate' type='text/html' href='https://git.0xinfinity.dev/distro/kernel.git/commit/?id=046199cae714a7f9e88f5a7940b077f4515f48cb'/>
<id>urn:sha1:046199cae714a7f9e88f5a7940b077f4515f48cb</id>
<content type='text'>
When remove the -fno-omit-frame-pointer, gcc will not save the frame
pointer for us, we need to save one ourselves.

Signed-off-by: Wu Zhangjin &lt;wuzhangjin@gmail.com&gt;
Cc: Steven Rostedt &lt;rostedt@goodmis.org&gt;
Cc: Nicholas Mc Guire &lt;der.herr@hofr.at&gt;
Cc: zhangfx@lemote.com
Cc: Wu Zhangjin &lt;wuzhangjin@gmail.com&gt;
Cc: Ingo Molnar &lt;mingo@elte.hu&gt;
Cc: Thomas Gleixner &lt;tglx@linutronix.de&gt;
Cc: Frederic Weisbecker &lt;fweisbec@gmail.com&gt;
Cc: linux-kernel@vger.kernel.org
Cc: linux-mips@linux-mips.org
Patchwork: http://patchwork.linux-mips.org/patch/679/
Signed-off-by: Ralf Baechle &lt;ralf@linux-mips.org&gt;
</content>
</entry>
<entry>
<title>MIPS: Tracing: Add dynamic function graph tracer for MIPS</title>
<updated>2009-12-17T01:57:25Z</updated>
<author>
<name>Wu Zhangjin</name>
</author>
<published>2009-11-20T12:34:35Z</published>
<link rel='alternate' type='text/html' href='https://git.0xinfinity.dev/distro/kernel.git/commit/?id=e17ff5fec65a0213416efbe7ceae5f2f9887dda2'/>
<id>urn:sha1:e17ff5fec65a0213416efbe7ceae5f2f9887dda2</id>
<content type='text'>
This patch make function graph tracer work with dynamic function tracer.

To share the source code of dynamic function tracer(MCOUNT_SAVE_REGS),
and avoid restoring the whole saved registers, we need to restore the ra
register from the stack.

(NOTE: This not work with 32bit! need to ensure why!)

Signed-off-by: Wu Zhangjin &lt;wuzhangjin@gmail.com&gt;
Cc: Steven Rostedt &lt;rostedt@goodmis.org&gt;
Cc: Nicholas Mc Guire &lt;der.herr@hofr.at&gt;
Cc: zhangfx@lemote.com
Cc: Wu Zhangjin &lt;wuzhangjin@gmail.com&gt;
Cc: Ingo Molnar &lt;mingo@elte.hu&gt;
Cc: Thomas Gleixner &lt;tglx@linutronix.de&gt;
Cc: Frederic Weisbecker &lt;fweisbec@gmail.com&gt;
Cc: linux-kernel@vger.kernel.org
Cc: linux-mips@linux-mips.org
Patchwork: http://patchwork.linux-mips.org/patch/678/
Signed-off-by: Ralf Baechle &lt;ralf@linux-mips.org&gt;
</content>
</entry>
<entry>
<title>MIPS: Tracing: Add function graph tracer support for MIPS</title>
<updated>2009-12-17T01:57:25Z</updated>
<author>
<name>Wu Zhangjin</name>
</author>
<published>2009-11-20T12:34:34Z</published>
<link rel='alternate' type='text/html' href='https://git.0xinfinity.dev/distro/kernel.git/commit/?id=29c5d3462f7c8f17bb9e0a29f0a299036468074d'/>
<id>urn:sha1:29c5d3462f7c8f17bb9e0a29f0a299036468074d</id>
<content type='text'>
The implementation of function graph tracer for MIPS is a little
different from X86.

in MIPS, gcc(with -pg) only transfer the caller's return address(at) and
the _mcount's return address(ra) to us.

For the kernel part without -mlong-calls:

move at, ra
jal _mcount

For the module part with -mlong-calls:

lui v1, hi16bit_of_mcount
addiu v1, v1, low16bit_of_mcount
move at, ra
jal _mcount

Without -mlong-calls,

if the function is a leaf, it will not save the return address(ra):

ffffffff80101298 &lt;au1k_wait&gt;:
ffffffff80101298:       67bdfff0        daddiu  sp,sp,-16
ffffffff8010129c:       ffbe0008        sd      s8,8(sp)
ffffffff801012a0:       03a0f02d        move    s8,sp
ffffffff801012a4:       03e0082d        move    at,ra
ffffffff801012a8:       0c042930        jal     ffffffff8010a4c0 &lt;_mcount&gt;
ffffffff801012ac:       00020021        nop

so, we can hijack it directly in _mcount, but if the function is non-leaf, the
return address is saved in the stack.

ffffffff80133030 &lt;copy_process&gt;:
ffffffff80133030:       67bdff50        daddiu  sp,sp,-176
ffffffff80133034:       ffbe00a0        sd      s8,160(sp)
ffffffff80133038:       03a0f02d        move    s8,sp
ffffffff8013303c:       ffbf00a8        sd      ra,168(sp)
ffffffff80133040:       ffb70098        sd      s7,152(sp)
ffffffff80133044:       ffb60090        sd      s6,144(sp)
ffffffff80133048:       ffb50088        sd      s5,136(sp)
ffffffff8013304c:       ffb40080        sd      s4,128(sp)
ffffffff80133050:       ffb30078        sd      s3,120(sp)
ffffffff80133054:       ffb20070        sd      s2,112(sp)
ffffffff80133058:       ffb10068        sd      s1,104(sp)
ffffffff8013305c:       ffb00060        sd      s0,96(sp)
ffffffff80133060:       03e0082d        move    at,ra
ffffffff80133064:       0c042930        jal     ffffffff8010a4c0 &lt;_mcount&gt;
ffffffff80133068:       00020021        nop

but we can not get the exact stack address(which saved ra) directly in
_mcount, we need to search the content of at register in the stack space
or search the "s{d,w} ra, offset(sp)" instruction in the text. 'Cause we
can not prove there is only a match in the stack space, so, we search
the text instead.

as we can see, if the first instruction above "move at, ra" is not a
store instruction, there should be a leaf function, so we hijack the at
register directly via putting &amp;return_to_handler into it, otherwise, we
search the "s{d,w} ra, offset(sp)" instruction to get the stack offset,
and then the stack address. we use the above copy_process() as an
example, we at last find "ffbf00a8", 0xa8 is the stack offset, we plus
it with s8(fp), that is the stack address, we hijack the content via
writing the &amp;return_to_handler in.

If with -mlong-calls, since there are two more instructions above "move
at, ra", so, we can move the pointer to the position above "lui v1,
hi16bit_of_mcount".

Signed-off-by: Wu Zhangjin &lt;wuzhangjin@gmail.com&gt;
Cc: Steven Rostedt &lt;rostedt@goodmis.org&gt;
Cc: Nicholas Mc Guire &lt;der.herr@hofr.at&gt;
Cc: zhangfx@lemote.com
Cc: Wu Zhangjin &lt;wuzhangjin@gmail.com&gt;
Cc: Ingo Molnar &lt;mingo@elte.hu&gt;
Cc: Thomas Gleixner &lt;tglx@linutronix.de&gt;
Cc: Frederic Weisbecker &lt;fweisbec@gmail.com&gt;
Cc: linux-kernel@vger.kernel.org
Cc: linux-mips@linux-mips.org
Patchwork: http://patchwork.linux-mips.org/patch/677/
Signed-off-by: Ralf Baechle &lt;ralf@linux-mips.org&gt;
</content>
</entry>
</feed>
