linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] powerpc: fix /proc/self/stack
@ 2017-03-17 15:59 Thadeu Lima de Souza Cascardo
  2017-03-22 11:03 ` Michael Ellerman
  2017-03-27 19:32 ` [PATCH v2] powerpc: make /proc/self/stack always print the current stack Thadeu Lima de Souza Cascardo
  0 siblings, 2 replies; 4+ messages in thread
From: Thadeu Lima de Souza Cascardo @ 2017-03-17 15:59 UTC (permalink / raw)
  To: linuxppc-dev
  Cc: linux-kernel, Michael Ellerman, Paul Mackerras, Benjamin Herrenschmidt

For the current task, the kernel stack would only tell the last time the
process was rescheduled, if ever. Use the current stack pointer for the
current task.

This is also consistent with some other architectures.

Signed-off-by: Thadeu Lima de Souza Cascardo <cascardo@canonical.com>
---
 arch/powerpc/kernel/stacktrace.c | 7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)

diff --git a/arch/powerpc/kernel/stacktrace.c b/arch/powerpc/kernel/stacktrace.c
index 6671195..2446066 100644
--- a/arch/powerpc/kernel/stacktrace.c
+++ b/arch/powerpc/kernel/stacktrace.c
@@ -59,7 +59,12 @@ EXPORT_SYMBOL_GPL(save_stack_trace);
 
 void save_stack_trace_tsk(struct task_struct *tsk, struct stack_trace *trace)
 {
-	save_context_stack(trace, tsk->thread.ksp, tsk, 0);
+	unsigned long sp = tsk->thread.ksp;
+
+	if (tsk == current)
+		sp = current_stack_pointer();
+
+	save_context_stack(trace, sp, tsk, 0);
 }
 EXPORT_SYMBOL_GPL(save_stack_trace_tsk);
 
-- 
2.9.3

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

* Re: [PATCH] powerpc: fix /proc/self/stack
  2017-03-17 15:59 [PATCH] powerpc: fix /proc/self/stack Thadeu Lima de Souza Cascardo
@ 2017-03-22 11:03 ` Michael Ellerman
  2017-03-27 19:32 ` [PATCH v2] powerpc: make /proc/self/stack always print the current stack Thadeu Lima de Souza Cascardo
  1 sibling, 0 replies; 4+ messages in thread
From: Michael Ellerman @ 2017-03-22 11:03 UTC (permalink / raw)
  To: Thadeu Lima de Souza Cascardo, linuxppc-dev
  Cc: linux-kernel, Paul Mackerras, Benjamin Herrenschmidt

Thadeu Lima de Souza Cascardo <cascardo@canonical.com> writes:

> For the current task, the kernel stack would only tell the last time the
> process was rescheduled, if ever. Use the current stack pointer for the
> current task.

You say "fix" in the subject, but is it a bug, or just an enhancement?

> This is also consistent with some other architectures.

Such as .. arm64 and x86 (though it's buried in the unwind code).

> diff --git a/arch/powerpc/kernel/stacktrace.c b/arch/powerpc/kernel/stacktrace.c
> index 6671195..2446066 100644
> --- a/arch/powerpc/kernel/stacktrace.c
> +++ b/arch/powerpc/kernel/stacktrace.c
> @@ -59,7 +59,12 @@ EXPORT_SYMBOL_GPL(save_stack_trace);
>  
>  void save_stack_trace_tsk(struct task_struct *tsk, struct stack_trace *trace)
>  {
> -	save_context_stack(trace, tsk->thread.ksp, tsk, 0);
> +	unsigned long sp = tsk->thread.ksp;
> +
> +	if (tsk == current)
> +		sp = current_stack_pointer();
	else
		sp = tsk->thread.ksp;

Would be clearer IMHO.

> +
> +	save_context_stack(trace, sp, tsk, 0);
>  }
>  EXPORT_SYMBOL_GPL(save_stack_trace_tsk);
>  
> -- 
> 2.9.3


cheers

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

* [PATCH v2] powerpc: make /proc/self/stack always print the current stack
  2017-03-17 15:59 [PATCH] powerpc: fix /proc/self/stack Thadeu Lima de Souza Cascardo
  2017-03-22 11:03 ` Michael Ellerman
@ 2017-03-27 19:32 ` Thadeu Lima de Souza Cascardo
  2017-03-31 12:33   ` [v2] " Michael Ellerman
  1 sibling, 1 reply; 4+ messages in thread
From: Thadeu Lima de Souza Cascardo @ 2017-03-27 19:32 UTC (permalink / raw)
  To: linuxppc-dev
  Cc: linux-kernel, Paul Mackerras, Benjamin Herrenschmidt, Michael Ellerman

For the current task, the kernel stack would only tell the last time the
process was rescheduled, if ever. Use the current stack pointer for the
current task.

Otherwise, every once in a while, the stacktrace printed when reading
/proc/self/stack would look like the process is running in userspace,
while it's not, which some may consider as a bug.

This is also consistent with some other architectures, like x86 and arm,
at least.

Signed-off-by: Thadeu Lima de Souza Cascardo <cascardo@canonical.com>
---
 arch/powerpc/kernel/stacktrace.c | 9 ++++++++-
 1 file changed, 8 insertions(+), 1 deletion(-)

diff --git a/arch/powerpc/kernel/stacktrace.c b/arch/powerpc/kernel/stacktrace.c
index 6671195..d534ed9 100644
--- a/arch/powerpc/kernel/stacktrace.c
+++ b/arch/powerpc/kernel/stacktrace.c
@@ -59,7 +59,14 @@ EXPORT_SYMBOL_GPL(save_stack_trace);
 
 void save_stack_trace_tsk(struct task_struct *tsk, struct stack_trace *trace)
 {
-	save_context_stack(trace, tsk->thread.ksp, tsk, 0);
+	unsigned long sp;
+
+	if (tsk == current)
+		sp = current_stack_pointer();
+	else
+		sp = tsk->thread.ksp;
+
+	save_context_stack(trace, sp, tsk, 0);
 }
 EXPORT_SYMBOL_GPL(save_stack_trace_tsk);
 
-- 
2.9.3

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

* Re: [v2] powerpc: make /proc/self/stack always print the current stack
  2017-03-27 19:32 ` [PATCH v2] powerpc: make /proc/self/stack always print the current stack Thadeu Lima de Souza Cascardo
@ 2017-03-31 12:33   ` Michael Ellerman
  0 siblings, 0 replies; 4+ messages in thread
From: Michael Ellerman @ 2017-03-31 12:33 UTC (permalink / raw)
  To: Thadeu Lima de Souza Cascardo, linuxppc-dev; +Cc: Paul Mackerras, linux-kernel

On Mon, 2017-03-27 at 19:32:33 UTC, Thadeu Lima de Souza Cascardo wrote:
> For the current task, the kernel stack would only tell the last time the
> process was rescheduled, if ever. Use the current stack pointer for the
> current task.
> 
> Otherwise, every once in a while, the stacktrace printed when reading
> /proc/self/stack would look like the process is running in userspace,
> while it's not, which some may consider as a bug.
> 
> This is also consistent with some other architectures, like x86 and arm,
> at least.
> 
> Signed-off-by: Thadeu Lima de Souza Cascardo <cascardo@canonical.com>

Applied to powerpc next, thanks.

https://git.kernel.org/powerpc/c/4f9b514b765a3057341f3236c94877

cheers

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

end of thread, other threads:[~2017-03-31 12:34 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-03-17 15:59 [PATCH] powerpc: fix /proc/self/stack Thadeu Lima de Souza Cascardo
2017-03-22 11:03 ` Michael Ellerman
2017-03-27 19:32 ` [PATCH v2] powerpc: make /proc/self/stack always print the current stack Thadeu Lima de Souza Cascardo
2017-03-31 12:33   ` [v2] " Michael Ellerman

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).