Skip to content

Commit

Permalink
riscv: stacktrace: convert arch_stack_walk() to noinstr
Browse files Browse the repository at this point in the history
[ Upstream commit 23b2188 ]

arch_stack_walk() is called intensively in function_graph when the
kernel is compiled with CONFIG_TRACE_IRQFLAGS. As a result, the kernel
logs a lot of arch_stack_walk and its sub-functions into the ftrace
buffer. However, these functions should not appear on the trace log
because they are part of the ftrace itself. This patch references what
arm64 does for the smae function. So it further prevent the re-enter
kprobe issue, which is also possible on riscv.

Related-to: commit 0fbcd8a ("arm64: Prohibit instrumentation on arch_stack_walk()")
Fixes: 6803413 ("riscv: add CALLER_ADDRx support")
Signed-off-by: Andy Chiu <andy.chiu@sifive.com>
Reviewed-by: Alexandre Ghiti <alexghiti@rivosinc.com>
Link: https://lore.kernel.org/r/20240613-dev-andyc-dyn-ftrace-v4-v1-1-1a538e12c01e@sifive.com
Signed-off-by: Palmer Dabbelt <palmer@rivosinc.com>
Signed-off-by: Sasha Levin <sashal@kernel.org>
  • Loading branch information
AndybnACT authored and gregkh committed Jul 5, 2024
1 parent 09f64e7 commit c3b4257
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion arch/riscv/kernel/stacktrace.c
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,7 @@ unsigned long __get_wchan(struct task_struct *task)
return pc;
}

noinline void arch_stack_walk(stack_trace_consume_fn consume_entry, void *cookie,
noinline noinstr void arch_stack_walk(stack_trace_consume_fn consume_entry, void *cookie,
struct task_struct *task, struct pt_regs *regs)
{
walk_stackframe(task, regs, consume_entry, cookie);
Expand Down

0 comments on commit c3b4257

Please sign in to comment.