public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH] riscv: stacktrace: fix usage of ftrace_graph_ret_addr()
@ 2024-06-18 14:58 Puranjay Mohan
  2024-06-18 16:13 ` Steven Rostedt
  2024-07-04 13:10 ` patchwork-bot+linux-riscv
  0 siblings, 2 replies; 3+ messages in thread
From: Puranjay Mohan @ 2024-06-18 14:58 UTC (permalink / raw)
  To: Paul Walmsley, Palmer Dabbelt, Albert Ou, Samuel Holland,
	Matthew Bystrin, linux-riscv, linux-kernel
  Cc: puranjay12, rostedt

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(-)

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)))
-- 
2.40.1


^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH] riscv: stacktrace: fix usage of ftrace_graph_ret_addr()
  2024-06-18 14:58 [PATCH] riscv: stacktrace: fix usage of ftrace_graph_ret_addr() Puranjay Mohan
@ 2024-06-18 16:13 ` Steven Rostedt
  2024-07-04 13:10 ` patchwork-bot+linux-riscv
  1 sibling, 0 replies; 3+ messages in thread
From: Steven Rostedt @ 2024-06-18 16:13 UTC (permalink / raw)
  To: Puranjay Mohan
  Cc: Paul Walmsley, Palmer Dabbelt, Albert Ou, Samuel Holland,
	Matthew Bystrin, linux-riscv, linux-kernel, puranjay12

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)))


^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] riscv: stacktrace: fix usage of ftrace_graph_ret_addr()
  2024-06-18 14:58 [PATCH] riscv: stacktrace: fix usage of ftrace_graph_ret_addr() Puranjay Mohan
  2024-06-18 16:13 ` Steven Rostedt
@ 2024-07-04 13:10 ` patchwork-bot+linux-riscv
  1 sibling, 0 replies; 3+ messages in thread
From: patchwork-bot+linux-riscv @ 2024-07-04 13:10 UTC (permalink / raw)
  To: Puranjay Mohan
  Cc: linux-riscv, paul.walmsley, palmer, aou, samuel.holland,
	dev.mbstr, linux-kernel, puranjay12, rostedt

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!
-- 
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html



^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2024-07-04 13:10 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-06-18 14:58 [PATCH] riscv: stacktrace: fix usage of ftrace_graph_ret_addr() Puranjay Mohan
2024-06-18 16:13 ` Steven Rostedt
2024-07-04 13:10 ` patchwork-bot+linux-riscv

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox