<feed xmlns='http://www.w3.org/2005/Atom'>
<title>linux-dev/arch/riscv/kernel/mcount-dyn.S, branch linus/master</title>
<subtitle>Linux kernel development work - see feature branches</subtitle>
<id>https://git.zx2c4.com/linux-dev/atom/arch/riscv/kernel/mcount-dyn.S?h=linus%2Fmaster</id>
<link rel='self' href='https://git.zx2c4.com/linux-dev/atom/arch/riscv/kernel/mcount-dyn.S?h=linus%2Fmaster'/>
<link rel='alternate' type='text/html' href='https://git.zx2c4.com/linux-dev/'/>
<updated>2021-01-14T23:09:05Z</updated>
<entry>
<title>riscv: Using PATCHABLE_FUNCTION_ENTRY instead of MCOUNT</title>
<updated>2021-01-14T23:09:05Z</updated>
<author>
<name>Guo Ren</name>
<email>guoren@linux.alibaba.com</email>
</author>
<published>2020-12-17T16:01:41Z</published>
<link rel='alternate' type='text/html' href='https://git.zx2c4.com/linux-dev/commit/?id=afc76b8b80112189b6f11e67e19cf58301944814'/>
<id>urn:sha1:afc76b8b80112189b6f11e67e19cf58301944814</id>
<content type='text'>
This patch changes the current detour mechanism of dynamic ftrace
which has been discussed during LPC 2020 RISCV-MC [1].

Before the patch, we used mcount for detour:
&lt;funca&gt;:
	addi sp,sp,-16
	sd   ra,8(sp)
	sd   s0,0(sp)
	addi s0,sp,16
	mv   a5,ra
	mv   a0,a5
	auipc ra,0x0 -&gt; nop
	jalr  -296(ra) &lt;_mcount@plt&gt; -&gt;nop
	...

After the patch, we use nop call site area for detour:
&lt;funca&gt;:
	nop -&gt; REG_S ra, -SZREG(sp)
	nop -&gt; auipc ra, 0x?
	nop -&gt; jalr ?(ra)
	nop -&gt; REG_L ra, -SZREG(sp)
	...

The mcount mechanism is mixed with gcc function prologue which is
not very clear. The patchable function entry just put 16 bytes nop
before the front of the function prologue which could be filled
with a separated detour mechanism.

[1] https://www.linuxplumbersconf.org/event/7/contributions/807/

Signed-off-by: Guo Ren &lt;guoren@linux.alibaba.com&gt;
Signed-off-by: Palmer Dabbelt &lt;palmerdabbelt@google.com&gt;
</content>
</entry>
<entry>
<title>riscv/ftrace: Add DYNAMIC_FTRACE_WITH_REGS support</title>
<updated>2018-04-03T02:59:13Z</updated>
<author>
<name>Alan Kao</name>
<email>alankao@andestech.com</email>
</author>
<published>2018-02-13T05:13:20Z</published>
<link rel='alternate' type='text/html' href='https://git.zx2c4.com/linux-dev/commit/?id=aea4c671fb985e6a9ffc365c43ea6f5e0d737fea'/>
<id>urn:sha1:aea4c671fb985e6a9ffc365c43ea6f5e0d737fea</id>
<content type='text'>
Cc: Greentime Hu &lt;greentime@andestech.com&gt;
Signed-off-by: Alan Kao &lt;alankao@andestech.com&gt;
Signed-off-by: Palmer Dabbelt &lt;palmer@sifive.com&gt;
</content>
</entry>
<entry>
<title>riscv/ftrace: Add ARCH_SUPPORTS_FTRACE_OPS support</title>
<updated>2018-04-03T02:59:12Z</updated>
<author>
<name>Alan Kao</name>
<email>alankao@andestech.com</email>
</author>
<published>2018-02-13T05:13:19Z</published>
<link rel='alternate' type='text/html' href='https://git.zx2c4.com/linux-dev/commit/?id=71e736a7d65551e49136c1efc4759e5902729cc2'/>
<id>urn:sha1:71e736a7d65551e49136c1efc4759e5902729cc2</id>
<content type='text'>
Cc: Greentime Hu &lt;greentime@andestech.com&gt;
Signed-off-by: Alan Kao &lt;alankao@andestech.com&gt;
Signed-off-by: Palmer Dabbelt &lt;palmer@sifive.com&gt;
</content>
</entry>
<entry>
<title>riscv/ftrace: Add dynamic function graph tracer support</title>
<updated>2018-04-03T02:59:12Z</updated>
<author>
<name>Alan Kao</name>
<email>alankao@andestech.com</email>
</author>
<published>2018-02-13T05:13:18Z</published>
<link rel='alternate' type='text/html' href='https://git.zx2c4.com/linux-dev/commit/?id=bc1a4c3a842556852bb02039887d73899d513532'/>
<id>urn:sha1:bc1a4c3a842556852bb02039887d73899d513532</id>
<content type='text'>
Once the function_graph tracer is enabled, a filtered function has the
following call sequence:

* ftracer_caller         ==&gt; on/off by ftrace_make_call/ftrace_make_nop
* ftrace_graph_caller
* ftrace_graph_call      ==&gt; on/off by ftrace_en/disable_ftrace_graph_caller
* prepare_ftrace_return

Considering the following DYNAMIC_FTRACE_WITH_REGS feature, it would be
more extendable to have a ftrace_graph_caller function, instead of
calling prepare_ftrace_return directly in ftrace_caller.

Cc: Greentime Hu &lt;greentime@andestech.com&gt;
Signed-off-by: Alan Kao &lt;alankao@andestech.com&gt;
Signed-off-by: Palmer Dabbelt &lt;palmer@sifive.com&gt;
</content>
</entry>
<entry>
<title>riscv/ftrace: Add dynamic function tracer support</title>
<updated>2018-04-03T02:59:12Z</updated>
<author>
<name>Alan Kao</name>
<email>alankao@andestech.com</email>
</author>
<published>2018-02-13T05:13:17Z</published>
<link rel='alternate' type='text/html' href='https://git.zx2c4.com/linux-dev/commit/?id=c15ac4fd60d5ffdb151bb2c7805f377fd7f90363'/>
<id>urn:sha1:c15ac4fd60d5ffdb151bb2c7805f377fd7f90363</id>
<content type='text'>
We now have dynamic ftrace with the following added items:

* ftrace_make_call, ftrace_make_nop (in kernel/ftrace.c)
  The two functions turn each recorded call site of filtered functions
  into a call to ftrace_caller or nops

* ftracce_update_ftrace_func (in kernel/ftrace.c)
  turns the nops at ftrace_call into a call to a generic entry for
  function tracers.

* ftrace_caller (in kernel/mcount-dyn.S)
  The entry where each _mcount call sites calls to once they are
  filtered to be traced.

Also, this patch fixes the semantic problems in mcount.S, which will be
treated as only a reference implementation once we have the dynamic
ftrace.

Cc: Greentime Hu &lt;greentime@andestech.com&gt;
Signed-off-by: Alan Kao &lt;alankao@andestech.com&gt;
Signed-off-by: Palmer Dabbelt &lt;palmer@sifive.com&gt;
</content>
</entry>
</feed>
