From: chenmiao <chenmiao.ku@gmail.com>
Hello erverone,
This patch contains basic ftrace support for OR1K platform.
Specifically, function tracer (HAVE_FUNCTION_TRACER), function graph
tracer (HAVE_FUNCTION_GRAPH_TRACER), and a frame pointer test
(HAVE_FUNCTION_GRAPH_FP_TEST) are implemented following the
instructions in Documentation/trace/ftrace-design.txt.
Below, I briefly explain why FTRACE_GRAPH was not enabled.
During testing, it was found that when fgraph is used with static ftrace,
it calls the ftrace_startup_subops function. This function is used by
register_ftrace_graph and always returns the EINVAL value in the case of
static ftrace. So, we disable the fgraph. *If re-initialization is attempted,
it may lead to severe consequences*, leading to the following issues:
[ 76.040000] ------------[ cut here ]------------
[ 76.040000] WARNING: CPU: 0 PID: 140 at kernel/trace/fgraph.c:1328 register_ftrace_graph+0x750/0x7e4
[ 76.040000] function graph ops registered again
[ 76.040000] Modules linked in:
[ 76.040000] CPU: 0 UID: 0 PID: 140 Comm: bash Not tainted 6.17.0-rc3-00014-gda230ee3ff1c #1 NONE
[ 76.040000] Call trace:
[ 76.040000] [<0b43fbe5>] dump_stack_lvl+0x8c/0xc4
[ 76.040000] [<d2655aeb>] ? register_ftrace_graph+0x750/0x7e4
[ 76.040000] [<22405ca2>] dump_stack+0x1c/0x2c
[ 76.040000] [<04b97f00>] __warn+0xcc/0x1ac
[ 76.040000] [<d2655aeb>] ? register_ftrace_graph+0x750/0x7e4
[ 76.040000] [<34636c77>] warn_slowpath_fmt+0x1e8/0x1f0
[ 76.040000] [<d2655aeb>] register_ftrace_graph+0x750/0x7e4
[ 76.040000] [<94bcf66b>] ? do_ftrace_graph_caller+0x2c/0x40
[ 76.040000] [<863d51d0>] ? _raw_spin_unlock_irqrestore+0x3c/0x50
[ 76.040000] [<5e3d7fcf>] graph_trace_init+0x60/0xa0
[ 76.040000] [<239e8587>] tracing_set_tracer+0x180/0x29c
[ 76.040000] [<0bedd84e>] ? mutex_unlock+0x24/0x80
[ 76.040000] [<21c17ace>] tracing_set_trace_write+0xa4/0x118
[ 76.040000] [<0d244535>] vfs_write+0x108/0x5ac
[ 76.040000] [<94bcf66b>] ? do_ftrace_graph_caller+0x2c/0x40
[ 76.040000] [<c15d06f8>] ? fdget_pos+0x20/0x210
[ 76.040000] [<bc6b8897>] ksys_write+0x94/0x150
[ 76.040000] [<06a3d204>] sys_write+0x38/0x4c
[ 76.040000] [<2cd910fd>] ? _syscall_return+0x0/0x4
[ 76.040000] ---[ end trace 0000000000000000 ]---
Thanks,
Chen Miao
chenmiao (1):
openrisc: Add the basic static ftrace support
arch/openrisc/Kconfig | 1 +
arch/openrisc/configs/or1ksim_defconfig | 2 +-
arch/openrisc/configs/virt_defconfig | 1 +
arch/openrisc/include/asm/ftrace.h | 29 ++++
arch/openrisc/kernel/Makefile | 7 +
arch/openrisc/kernel/entry-ftrace.S | 185 ++++++++++++++++++++++++
arch/openrisc/kernel/ftrace.c | 35 +++++
7 files changed, 259 insertions(+), 1 deletion(-)
create mode 100644 arch/openrisc/include/asm/ftrace.h
create mode 100644 arch/openrisc/kernel/entry-ftrace.S
create mode 100644 arch/openrisc/kernel/ftrace.c
--
2.45.2