diff mbox series

riscv: stacktrace: fix usage of ftrace_graph_ret_addr()

Message ID 20240618145820.62112-1-puranjay@kernel.org (mailing list archive)
State Accepted
Commit 393da6cbb2ff89aadc47683a85269f913aa1c139
Headers show
Series riscv: stacktrace: fix usage of ftrace_graph_ret_addr() | expand

Checks

Context Check Description
conchuod/vmtest-for-next-PR success PR summary
conchuod/patch-1-test-1 success .github/scripts/patches/tests/build_rv32_defconfig.sh
conchuod/patch-1-test-2 success .github/scripts/patches/tests/build_rv64_clang_allmodconfig.sh
conchuod/patch-1-test-3 success .github/scripts/patches/tests/build_rv64_gcc_allmodconfig.sh
conchuod/patch-1-test-4 success .github/scripts/patches/tests/build_rv64_nommu_k210_defconfig.sh
conchuod/patch-1-test-5 success .github/scripts/patches/tests/build_rv64_nommu_virt_defconfig.sh
conchuod/patch-1-test-6 success .github/scripts/patches/tests/checkpatch.sh
conchuod/patch-1-test-7 success .github/scripts/patches/tests/dtb_warn_rv64.sh
conchuod/patch-1-test-8 success .github/scripts/patches/tests/header_inline.sh
conchuod/patch-1-test-9 success .github/scripts/patches/tests/kdoc.sh
conchuod/patch-1-test-10 success .github/scripts/patches/tests/module_param.sh
conchuod/patch-1-test-11 success .github/scripts/patches/tests/verify_fixes.sh
conchuod/patch-1-test-12 success .github/scripts/patches/tests/verify_signedoff.sh

Commit Message

Puranjay Mohan June 18, 2024, 2:58 p.m. UTC
ftrace_graph_ret_addr() takes an `idx` integer pointer that is used to
optimize the stack unwinding. Pass it a valid pointer to utilize the
optimizations that might be available in the future.

The commit is making riscv's usage of ftrace_graph_ret_addr() match
x86_64.

Signed-off-by: Puranjay Mohan <puranjay@kernel.org>
---
 arch/riscv/kernel/stacktrace.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

Comments

Steven Rostedt June 18, 2024, 4:13 p.m. UTC | #1
On Tue, 18 Jun 2024 14:58:20 +0000
Puranjay Mohan <puranjay@kernel.org> wrote:

> ftrace_graph_ret_addr() takes an `idx` integer pointer that is used to
> optimize the stack unwinding. Pass it a valid pointer to utilize the
> optimizations that might be available in the future.
> 
> The commit is making riscv's usage of ftrace_graph_ret_addr() match
> x86_64.
> 
> Signed-off-by: Puranjay Mohan <puranjay@kernel.org>

Not only that, the updated code for ftrace_graph_ret_addr() will just
return the passed in return address if it is NULL. Basically, it will
not work without this.

Reviewed-by: Steven Rostedt (Google) <rostedt@goodmis.org>

-- Steve


> ---
>  arch/riscv/kernel/stacktrace.c | 3 ++-
>  1 file changed, 2 insertions(+), 1 deletion(-)
> 
> diff --git a/arch/riscv/kernel/stacktrace.c b/arch/riscv/kernel/stacktrace.c
> index 528ec7cc9a62..6cb7f9ca9d82 100644
> --- a/arch/riscv/kernel/stacktrace.c
> +++ b/arch/riscv/kernel/stacktrace.c
> @@ -32,6 +32,7 @@ void notrace walk_stackframe(struct task_struct *task, struct pt_regs *regs,
>  			     bool (*fn)(void *, unsigned long), void *arg)
>  {
>  	unsigned long fp, sp, pc;
> +	int graph_idx = 0;
>  	int level = 0;
>  
>  	if (regs) {
> @@ -68,7 +69,7 @@ void notrace walk_stackframe(struct task_struct *task, struct pt_regs *regs,
>  			pc = regs->ra;
>  		} else {
>  			fp = frame->fp;
> -			pc = ftrace_graph_ret_addr(current, NULL, frame->ra,
> +			pc = ftrace_graph_ret_addr(current, &graph_idx, frame->ra,
>  						   &frame->ra);
>  			if (pc == (unsigned long)ret_from_exception) {
>  				if (unlikely(!__kernel_text_address(pc) || !fn(arg, pc)))
patchwork-bot+linux-riscv@kernel.org July 4, 2024, 1:10 p.m. UTC | #2
Hello:

This patch was applied to riscv/linux.git (fixes)
by Palmer Dabbelt <palmer@rivosinc.com>:

On Tue, 18 Jun 2024 14:58:20 +0000 you wrote:
> ftrace_graph_ret_addr() takes an `idx` integer pointer that is used to
> optimize the stack unwinding. Pass it a valid pointer to utilize the
> optimizations that might be available in the future.
> 
> The commit is making riscv's usage of ftrace_graph_ret_addr() match
> x86_64.
> 
> [...]

Here is the summary with links:
  - riscv: stacktrace: fix usage of ftrace_graph_ret_addr()
    https://git.kernel.org/riscv/c/393da6cbb2ff

You are awesome, thank you!
diff mbox series

Patch

diff --git a/arch/riscv/kernel/stacktrace.c b/arch/riscv/kernel/stacktrace.c
index 528ec7cc9a62..6cb7f9ca9d82 100644
--- a/arch/riscv/kernel/stacktrace.c
+++ b/arch/riscv/kernel/stacktrace.c
@@ -32,6 +32,7 @@  void notrace walk_stackframe(struct task_struct *task, struct pt_regs *regs,
 			     bool (*fn)(void *, unsigned long), void *arg)
 {
 	unsigned long fp, sp, pc;
+	int graph_idx = 0;
 	int level = 0;
 
 	if (regs) {
@@ -68,7 +69,7 @@  void notrace walk_stackframe(struct task_struct *task, struct pt_regs *regs,
 			pc = regs->ra;
 		} else {
 			fp = frame->fp;
-			pc = ftrace_graph_ret_addr(current, NULL, frame->ra,
+			pc = ftrace_graph_ret_addr(current, &graph_idx, frame->ra,
 						   &frame->ra);
 			if (pc == (unsigned long)ret_from_exception) {
 				if (unlikely(!__kernel_text_address(pc) || !fn(arg, pc)))