All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] Stacktrace in ARM32 architecture has jumped the first 2 layers, which may ignore the display of save_stack_trace_tsk.
@ 2019-05-30 15:06 ` l00383200
  0 siblings, 0 replies; 6+ messages in thread
From: l00383200 @ 2019-05-30 15:06 UTC (permalink / raw)
  To: rmk+kernel, tglx
  Cc: peterz, gregkh, linux-arm-kernel, linux-kernel, liucheng32

Without optimization, both save_stack_trace_tsk and __save_stack_trace
will have stacktrace information in ARM32.

In this situation, "data.skip += 2" operation will skip the first two layers,
which may make the stacktrace strange and different from other architectures.

A simple example is as follows:
In ARM32 architecture:
[<ffffff80083cb3f8>] proc_pid_stack+0xac/0x12c
[<ffffff80083c7c70>] proc_single_show+0x5c/0xa8
[<ffffff800838aca8>] seq_read+0x130/0x420
[<ffffff8008365c54>] __vfs_read+0x60/0x11c
[<ffffff80083665dc>] vfs_read+0x8c/0x140
[<ffffff800836717c>] SyS_read+0x6c/0xcc
[<ffffff8008202cb8>] __sys_trace_return+0x0/0x4
[<ffffffffffffffff>] 0xffffffffffffffff

In some other architectures(ARM64):
[<ffffff8008209be0>] save_stack_trace_tsk+0x0/0xf0
[<ffffff80083cb3f8>] proc_pid_stack+0xac/0x12c
[<ffffff80083c7c70>] proc_single_show+0x5c/0xa8
[<ffffff800838aca8>] seq_read+0x130/0x420
[<ffffff8008365c54>] __vfs_read+0x60/0x11c
[<ffffff80083665dc>] vfs_read+0x8c/0x140
[<ffffff800836717c>] SyS_read+0x6c/0xcc
[<ffffff8008202cb8>] __sys_trace_return+0x0/0x4
[<ffffffffffffffff>] 0xffffffffffffffff

Therefore, we'd better just jump only one layer to ensure accuracy and consistency.

Signed-off-by: liucheng <liucheng32@huawei.com>
---
 arch/arm/kernel/stacktrace.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/arch/arm/kernel/stacktrace.c b/arch/arm/kernel/stacktrace.c
index 71778bb..bb3da38 100644
--- a/arch/arm/kernel/stacktrace.c
+++ b/arch/arm/kernel/stacktrace.c
@@ -125,7 +125,7 @@ static noinline void __save_stack_trace(struct task_struct *tsk,
 #endif
 	} else {
 		/* We don't want this function nor the caller */
-		data.skip += 2;
+		data.skip += 1;
 		frame.fp = (unsigned long)__builtin_frame_address(0);
 		frame.sp = current_stack_pointer;
 		frame.lr = (unsigned long)__builtin_return_address(0);
-- 
1.8.5.6


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

* [PATCH] Stacktrace in ARM32 architecture has jumped the first 2 layers, which may ignore the display of save_stack_trace_tsk.
@ 2019-05-30 15:06 ` l00383200
  0 siblings, 0 replies; 6+ messages in thread
From: l00383200 @ 2019-05-30 15:06 UTC (permalink / raw)
  To: rmk+kernel, tglx
  Cc: peterz, gregkh, linux-kernel, linux-arm-kernel, liucheng32

Without optimization, both save_stack_trace_tsk and __save_stack_trace
will have stacktrace information in ARM32.

In this situation, "data.skip += 2" operation will skip the first two layers,
which may make the stacktrace strange and different from other architectures.

A simple example is as follows:
In ARM32 architecture:
[<ffffff80083cb3f8>] proc_pid_stack+0xac/0x12c
[<ffffff80083c7c70>] proc_single_show+0x5c/0xa8
[<ffffff800838aca8>] seq_read+0x130/0x420
[<ffffff8008365c54>] __vfs_read+0x60/0x11c
[<ffffff80083665dc>] vfs_read+0x8c/0x140
[<ffffff800836717c>] SyS_read+0x6c/0xcc
[<ffffff8008202cb8>] __sys_trace_return+0x0/0x4
[<ffffffffffffffff>] 0xffffffffffffffff

In some other architectures(ARM64):
[<ffffff8008209be0>] save_stack_trace_tsk+0x0/0xf0
[<ffffff80083cb3f8>] proc_pid_stack+0xac/0x12c
[<ffffff80083c7c70>] proc_single_show+0x5c/0xa8
[<ffffff800838aca8>] seq_read+0x130/0x420
[<ffffff8008365c54>] __vfs_read+0x60/0x11c
[<ffffff80083665dc>] vfs_read+0x8c/0x140
[<ffffff800836717c>] SyS_read+0x6c/0xcc
[<ffffff8008202cb8>] __sys_trace_return+0x0/0x4
[<ffffffffffffffff>] 0xffffffffffffffff

Therefore, we'd better just jump only one layer to ensure accuracy and consistency.

Signed-off-by: liucheng <liucheng32@huawei.com>
---
 arch/arm/kernel/stacktrace.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/arch/arm/kernel/stacktrace.c b/arch/arm/kernel/stacktrace.c
index 71778bb..bb3da38 100644
--- a/arch/arm/kernel/stacktrace.c
+++ b/arch/arm/kernel/stacktrace.c
@@ -125,7 +125,7 @@ static noinline void __save_stack_trace(struct task_struct *tsk,
 #endif
 	} else {
 		/* We don't want this function nor the caller */
-		data.skip += 2;
+		data.skip += 1;
 		frame.fp = (unsigned long)__builtin_frame_address(0);
 		frame.sp = current_stack_pointer;
 		frame.lr = (unsigned long)__builtin_return_address(0);
-- 
1.8.5.6


_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

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

* Re: [PATCH] Stacktrace in ARM32 architecture has jumped the first 2 layers, which may ignore the display of save_stack_trace_tsk.
  2019-05-30 15:06 ` l00383200
@ 2019-05-30 16:22   ` Russell King - ARM Linux admin
  -1 siblings, 0 replies; 6+ messages in thread
From: Russell King - ARM Linux admin @ 2019-05-30 16:22 UTC (permalink / raw)
  To: l00383200; +Cc: tglx, peterz, gregkh, linux-arm-kernel, linux-kernel

On Thu, May 30, 2019 at 11:06:39PM +0800, l00383200 wrote:
> Without optimization, both save_stack_trace_tsk and __save_stack_trace
> will have stacktrace information in ARM32.
> 
> In this situation, "data.skip += 2" operation will skip the first two layers,
> which may make the stacktrace strange and different from other architectures.
> 
> A simple example is as follows:
> In ARM32 architecture:
> [<ffffff80083cb3f8>] proc_pid_stack+0xac/0x12c
> [<ffffff80083c7c70>] proc_single_show+0x5c/0xa8
> [<ffffff800838aca8>] seq_read+0x130/0x420
> [<ffffff8008365c54>] __vfs_read+0x60/0x11c
> [<ffffff80083665dc>] vfs_read+0x8c/0x140
> [<ffffff800836717c>] SyS_read+0x6c/0xcc
> [<ffffff8008202cb8>] __sys_trace_return+0x0/0x4
> [<ffffffffffffffff>] 0xffffffffffffffff
> 
> In some other architectures(ARM64):
> [<ffffff8008209be0>] save_stack_trace_tsk+0x0/0xf0
> [<ffffff80083cb3f8>] proc_pid_stack+0xac/0x12c
> [<ffffff80083c7c70>] proc_single_show+0x5c/0xa8
> [<ffffff800838aca8>] seq_read+0x130/0x420
> [<ffffff8008365c54>] __vfs_read+0x60/0x11c
> [<ffffff80083665dc>] vfs_read+0x8c/0x140
> [<ffffff800836717c>] SyS_read+0x6c/0xcc
> [<ffffff8008202cb8>] __sys_trace_return+0x0/0x4
> [<ffffffffffffffff>] 0xffffffffffffffff
> 
> Therefore, we'd better just jump only one layer to ensure accuracy and consistency.

Why do we want to log the function we called to save the stack trace
_in_ the stack trace?  What useful purpose does it serve?

I've always taken the attitude that if we want a stack trace from a
certain point in the function, then that's the point that the stack
trace should start.  It's entirely sensible.

> 
> Signed-off-by: liucheng <liucheng32@huawei.com>
> ---
>  arch/arm/kernel/stacktrace.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/arch/arm/kernel/stacktrace.c b/arch/arm/kernel/stacktrace.c
> index 71778bb..bb3da38 100644
> --- a/arch/arm/kernel/stacktrace.c
> +++ b/arch/arm/kernel/stacktrace.c
> @@ -125,7 +125,7 @@ static noinline void __save_stack_trace(struct task_struct *tsk,
>  #endif
>  	} else {
>  		/* We don't want this function nor the caller */
> -		data.skip += 2;
> +		data.skip += 1;
>  		frame.fp = (unsigned long)__builtin_frame_address(0);
>  		frame.sp = current_stack_pointer;
>  		frame.lr = (unsigned long)__builtin_return_address(0);
> -- 
> 1.8.5.6
> 
> 

-- 
RMK's Patch system: https://www.armlinux.org.uk/developer/patches/
FTTC broadband for 0.8mile line in suburbia: sync at 12.1Mbps down 622kbps up
According to speedtest.net: 11.9Mbps down 500kbps up

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

* Re: [PATCH] Stacktrace in ARM32 architecture has jumped the first 2 layers, which may ignore the display of save_stack_trace_tsk.
@ 2019-05-30 16:22   ` Russell King - ARM Linux admin
  0 siblings, 0 replies; 6+ messages in thread
From: Russell King - ARM Linux admin @ 2019-05-30 16:22 UTC (permalink / raw)
  To: l00383200; +Cc: peterz, gregkh, tglx, linux-kernel, linux-arm-kernel

On Thu, May 30, 2019 at 11:06:39PM +0800, l00383200 wrote:
> Without optimization, both save_stack_trace_tsk and __save_stack_trace
> will have stacktrace information in ARM32.
> 
> In this situation, "data.skip += 2" operation will skip the first two layers,
> which may make the stacktrace strange and different from other architectures.
> 
> A simple example is as follows:
> In ARM32 architecture:
> [<ffffff80083cb3f8>] proc_pid_stack+0xac/0x12c
> [<ffffff80083c7c70>] proc_single_show+0x5c/0xa8
> [<ffffff800838aca8>] seq_read+0x130/0x420
> [<ffffff8008365c54>] __vfs_read+0x60/0x11c
> [<ffffff80083665dc>] vfs_read+0x8c/0x140
> [<ffffff800836717c>] SyS_read+0x6c/0xcc
> [<ffffff8008202cb8>] __sys_trace_return+0x0/0x4
> [<ffffffffffffffff>] 0xffffffffffffffff
> 
> In some other architectures(ARM64):
> [<ffffff8008209be0>] save_stack_trace_tsk+0x0/0xf0
> [<ffffff80083cb3f8>] proc_pid_stack+0xac/0x12c
> [<ffffff80083c7c70>] proc_single_show+0x5c/0xa8
> [<ffffff800838aca8>] seq_read+0x130/0x420
> [<ffffff8008365c54>] __vfs_read+0x60/0x11c
> [<ffffff80083665dc>] vfs_read+0x8c/0x140
> [<ffffff800836717c>] SyS_read+0x6c/0xcc
> [<ffffff8008202cb8>] __sys_trace_return+0x0/0x4
> [<ffffffffffffffff>] 0xffffffffffffffff
> 
> Therefore, we'd better just jump only one layer to ensure accuracy and consistency.

Why do we want to log the function we called to save the stack trace
_in_ the stack trace?  What useful purpose does it serve?

I've always taken the attitude that if we want a stack trace from a
certain point in the function, then that's the point that the stack
trace should start.  It's entirely sensible.

> 
> Signed-off-by: liucheng <liucheng32@huawei.com>
> ---
>  arch/arm/kernel/stacktrace.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/arch/arm/kernel/stacktrace.c b/arch/arm/kernel/stacktrace.c
> index 71778bb..bb3da38 100644
> --- a/arch/arm/kernel/stacktrace.c
> +++ b/arch/arm/kernel/stacktrace.c
> @@ -125,7 +125,7 @@ static noinline void __save_stack_trace(struct task_struct *tsk,
>  #endif
>  	} else {
>  		/* We don't want this function nor the caller */
> -		data.skip += 2;
> +		data.skip += 1;
>  		frame.fp = (unsigned long)__builtin_frame_address(0);
>  		frame.sp = current_stack_pointer;
>  		frame.lr = (unsigned long)__builtin_return_address(0);
> -- 
> 1.8.5.6
> 
> 

-- 
RMK's Patch system: https://www.armlinux.org.uk/developer/patches/
FTTC broadband for 0.8mile line in suburbia: sync at 12.1Mbps down 622kbps up
According to speedtest.net: 11.9Mbps down 500kbps up

_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

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

* Re: [PATCH] Stacktrace in ARM32 architecture has jumped the first 2 layers, which may ignore the display of save_stack_trace_tsk.
  2019-05-30 16:22   ` Russell King - ARM Linux admin
@ 2019-05-31  8:27     ` Peter Zijlstra
  -1 siblings, 0 replies; 6+ messages in thread
From: Peter Zijlstra @ 2019-05-31  8:27 UTC (permalink / raw)
  To: Russell King - ARM Linux admin
  Cc: l00383200, tglx, gregkh, linux-arm-kernel, linux-kernel

On Thu, May 30, 2019 at 05:22:19PM +0100, Russell King - ARM Linux admin wrote:
> On Thu, May 30, 2019 at 11:06:39PM +0800, l00383200 wrote:
> > Without optimization, both save_stack_trace_tsk and __save_stack_trace
> > will have stacktrace information in ARM32.
> > 
> > In this situation, "data.skip += 2" operation will skip the first two layers,
> > which may make the stacktrace strange and different from other architectures.
> > 
> > A simple example is as follows:
> > In ARM32 architecture:
> > [<ffffff80083cb3f8>] proc_pid_stack+0xac/0x12c
> > [<ffffff80083c7c70>] proc_single_show+0x5c/0xa8
> > [<ffffff800838aca8>] seq_read+0x130/0x420
> > [<ffffff8008365c54>] __vfs_read+0x60/0x11c
> > [<ffffff80083665dc>] vfs_read+0x8c/0x140
> > [<ffffff800836717c>] SyS_read+0x6c/0xcc
> > [<ffffff8008202cb8>] __sys_trace_return+0x0/0x4
> > [<ffffffffffffffff>] 0xffffffffffffffff
> > 
> > In some other architectures(ARM64):
> > [<ffffff8008209be0>] save_stack_trace_tsk+0x0/0xf0
> > [<ffffff80083cb3f8>] proc_pid_stack+0xac/0x12c
> > [<ffffff80083c7c70>] proc_single_show+0x5c/0xa8
> > [<ffffff800838aca8>] seq_read+0x130/0x420
> > [<ffffff8008365c54>] __vfs_read+0x60/0x11c
> > [<ffffff80083665dc>] vfs_read+0x8c/0x140
> > [<ffffff800836717c>] SyS_read+0x6c/0xcc
> > [<ffffff8008202cb8>] __sys_trace_return+0x0/0x4
> > [<ffffffffffffffff>] 0xffffffffffffffff
> > 
> > Therefore, we'd better just jump only one layer to ensure accuracy and consistency.
> 
> Why do we want to log the function we called to save the stack trace
> _in_ the stack trace?  What useful purpose does it serve?
> 
> I've always taken the attitude that if we want a stack trace from a
> certain point in the function, then that's the point that the stack
> trace should start.  It's entirely sensible.

Agreed, also the .skip interface sucks and is slated for replacement
(whenever we get around to it).

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

* Re: [PATCH] Stacktrace in ARM32 architecture has jumped the first 2 layers, which may ignore the display of save_stack_trace_tsk.
@ 2019-05-31  8:27     ` Peter Zijlstra
  0 siblings, 0 replies; 6+ messages in thread
From: Peter Zijlstra @ 2019-05-31  8:27 UTC (permalink / raw)
  To: Russell King - ARM Linux admin
  Cc: gregkh, tglx, l00383200, linux-arm-kernel, linux-kernel

On Thu, May 30, 2019 at 05:22:19PM +0100, Russell King - ARM Linux admin wrote:
> On Thu, May 30, 2019 at 11:06:39PM +0800, l00383200 wrote:
> > Without optimization, both save_stack_trace_tsk and __save_stack_trace
> > will have stacktrace information in ARM32.
> > 
> > In this situation, "data.skip += 2" operation will skip the first two layers,
> > which may make the stacktrace strange and different from other architectures.
> > 
> > A simple example is as follows:
> > In ARM32 architecture:
> > [<ffffff80083cb3f8>] proc_pid_stack+0xac/0x12c
> > [<ffffff80083c7c70>] proc_single_show+0x5c/0xa8
> > [<ffffff800838aca8>] seq_read+0x130/0x420
> > [<ffffff8008365c54>] __vfs_read+0x60/0x11c
> > [<ffffff80083665dc>] vfs_read+0x8c/0x140
> > [<ffffff800836717c>] SyS_read+0x6c/0xcc
> > [<ffffff8008202cb8>] __sys_trace_return+0x0/0x4
> > [<ffffffffffffffff>] 0xffffffffffffffff
> > 
> > In some other architectures(ARM64):
> > [<ffffff8008209be0>] save_stack_trace_tsk+0x0/0xf0
> > [<ffffff80083cb3f8>] proc_pid_stack+0xac/0x12c
> > [<ffffff80083c7c70>] proc_single_show+0x5c/0xa8
> > [<ffffff800838aca8>] seq_read+0x130/0x420
> > [<ffffff8008365c54>] __vfs_read+0x60/0x11c
> > [<ffffff80083665dc>] vfs_read+0x8c/0x140
> > [<ffffff800836717c>] SyS_read+0x6c/0xcc
> > [<ffffff8008202cb8>] __sys_trace_return+0x0/0x4
> > [<ffffffffffffffff>] 0xffffffffffffffff
> > 
> > Therefore, we'd better just jump only one layer to ensure accuracy and consistency.
> 
> Why do we want to log the function we called to save the stack trace
> _in_ the stack trace?  What useful purpose does it serve?
> 
> I've always taken the attitude that if we want a stack trace from a
> certain point in the function, then that's the point that the stack
> trace should start.  It's entirely sensible.

Agreed, also the .skip interface sucks and is slated for replacement
(whenever we get around to it).

_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

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

end of thread, other threads:[~2019-05-31  8:27 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-05-30 15:06 [PATCH] Stacktrace in ARM32 architecture has jumped the first 2 layers, which may ignore the display of save_stack_trace_tsk l00383200
2019-05-30 15:06 ` l00383200
2019-05-30 16:22 ` Russell King - ARM Linux admin
2019-05-30 16:22   ` Russell King - ARM Linux admin
2019-05-31  8:27   ` Peter Zijlstra
2019-05-31  8:27     ` Peter Zijlstra

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.