Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1603422 > unrolled thread

[PATCH] powerpc: fix /proc/self/stack

Started byThadeu Lima de Souza Cascardo <cascardo@canonical.com>
First post2017-03-17 17:00 +0100
Last post2017-03-22 12:20 +0100
Articles 2 — 2 participants

Back to article view | Back to linux.kernel


Contents

  [PATCH] powerpc: fix /proc/self/stack Thadeu Lima de Souza Cascardo <cascardo@canonical.com> - 2017-03-17 17:00 +0100
    Re: [PATCH] powerpc: fix /proc/self/stack Michael Ellerman <mpe@ellerman.id.au> - 2017-03-22 12:20 +0100

#1603422 — [PATCH] powerpc: fix /proc/self/stack

FromThadeu Lima de Souza Cascardo <cascardo@canonical.com>
Date2017-03-17 17:00 +0100
Subject[PATCH] powerpc: fix /proc/self/stack
Message-ID<tm2sh-kO-1@gated-at.bofh.it>
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

[toc] | [next] | [standalone]


#1606378

FromMichael Ellerman <mpe@ellerman.id.au>
Date2017-03-22 12:20 +0100
Message-ID<tnMt4-1zh-25@gated-at.bofh.it>
In reply to#1603422
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

[toc] | [prev] | [standalone]


Back to top | Article view | linux.kernel


csiph-web