All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] stacktrace: don't skip first entry on noncurrent tasks
@ 2019-10-25  6:52 Jiri Slaby
  2019-10-25 14:21 ` Josh Poimboeuf
  0 siblings, 1 reply; 7+ messages in thread
From: Jiri Slaby @ 2019-10-25  6:52 UTC (permalink / raw)
  To: tglx; +Cc: linux-kernel, Jiri Slaby, Josh Poimboeuf

When doing cat /proc/<PID>/stack, the output is missing the first entry.
When the current code walks the stack starting in stack_trace_save_tsk,
it skips all scheduler functions (that's OK) plus one more function. But
this one function should be skipped only for the 'current' task as it is
stack_trace_save_tsk proper.

The original code (before the common infrastructure) skipped one
function only for the 'current' task -- see save_stack_trace_tsk before
3599fe12a125. So do so also in the new infrastructure now.

Signed-off-by: Jiri Slaby <jslaby@suse.cz>
Fixes: 214d8ca6ee85 ("stacktrace: Provide common infrastructure")
Cc: Thomas Gleixner <tglx@linutronix.de>
Cc: Josh Poimboeuf <jpoimboe@redhat.com>
---
 kernel/stacktrace.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/kernel/stacktrace.c b/kernel/stacktrace.c
index 6d1f68b7e528..d06a2e4d0142 100644
--- a/kernel/stacktrace.c
+++ b/kernel/stacktrace.c
@@ -141,7 +141,8 @@ unsigned int stack_trace_save_tsk(struct task_struct *tsk, unsigned long *store,
 	struct stacktrace_cookie c = {
 		.store	= store,
 		.size	= size,
-		.skip	= skipnr + 1,
+		/* skip this function if they are tracing us */
+		.skip	= skipnr + !!(current == tsk),
 	};
 
 	if (!try_get_task_stack(tsk))
-- 
2.23.0


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

* Re: [PATCH] stacktrace: don't skip first entry on noncurrent tasks
  2019-10-25  6:52 [PATCH] stacktrace: don't skip first entry on noncurrent tasks Jiri Slaby
@ 2019-10-25 14:21 ` Josh Poimboeuf
  2019-10-29  7:19   ` [PATCH v2] " Jiri Slaby
  0 siblings, 1 reply; 7+ messages in thread
From: Josh Poimboeuf @ 2019-10-25 14:21 UTC (permalink / raw)
  To: Jiri Slaby; +Cc: tglx, linux-kernel

On Fri, Oct 25, 2019 at 08:52:26AM +0200, Jiri Slaby wrote:
> When doing cat /proc/<PID>/stack, the output is missing the first entry.
> When the current code walks the stack starting in stack_trace_save_tsk,
> it skips all scheduler functions (that's OK) plus one more function. But
> this one function should be skipped only for the 'current' task as it is
> stack_trace_save_tsk proper.
> 
> The original code (before the common infrastructure) skipped one
> function only for the 'current' task -- see save_stack_trace_tsk before
> 3599fe12a125. So do so also in the new infrastructure now.
> 
> Signed-off-by: Jiri Slaby <jslaby@suse.cz>
> Fixes: 214d8ca6ee85 ("stacktrace: Provide common infrastructure")
> Cc: Thomas Gleixner <tglx@linutronix.de>
> Cc: Josh Poimboeuf <jpoimboe@redhat.com>
> ---
>  kernel/stacktrace.c | 3 ++-
>  1 file changed, 2 insertions(+), 1 deletion(-)
> 
> diff --git a/kernel/stacktrace.c b/kernel/stacktrace.c
> index 6d1f68b7e528..d06a2e4d0142 100644
> --- a/kernel/stacktrace.c
> +++ b/kernel/stacktrace.c
> @@ -141,7 +141,8 @@ unsigned int stack_trace_save_tsk(struct task_struct *tsk, unsigned long *store,
>  	struct stacktrace_cookie c = {
>  		.store	= store,
>  		.size	= size,
> -		.skip	= skipnr + 1,
> +		/* skip this function if they are tracing us */
> +		.skip	= skipnr + !!(current == tsk),
>  	};
>  
>  	if (!try_get_task_stack(tsk))

I think a similar change is needed for the other !CONFIG_ARCH_STACKWALK
version of stack_trace_save_tsk() in that file?

-- 
Josh


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

* [PATCH v2] stacktrace: don't skip first entry on noncurrent tasks
  2019-10-25 14:21 ` Josh Poimboeuf
@ 2019-10-29  7:19   ` Jiri Slaby
  2019-10-29 13:35     ` Josh Poimboeuf
                       ` (2 more replies)
  0 siblings, 3 replies; 7+ messages in thread
From: Jiri Slaby @ 2019-10-29  7:19 UTC (permalink / raw)
  To: tglx; +Cc: linux-kernel, Jiri Slaby, Josh Poimboeuf

When doing cat /proc/<PID>/stack, the output is missing the first entry.
When the current code walks the stack starting in stack_trace_save_tsk,
it skips all scheduler functions (that's OK) plus one more function. But
this one function should be skipped only for the 'current' task as it is
stack_trace_save_tsk proper.

The original code (before the common infrastructure) skipped one
function only for the 'current' task -- see save_stack_trace_tsk before
3599fe12a125. So do so also in the new infrastructure now.

Signed-off-by: Jiri Slaby <jslaby@suse.cz>
Fixes: 214d8ca6ee85 ("stacktrace: Provide common infrastructure")
Cc: Thomas Gleixner <tglx@linutronix.de>
Cc: Josh Poimboeuf <jpoimboe@redhat.com>
---

Notes:
    [v2] add the same for the !CONFIG_ARCH_STACKWALK case

 kernel/stacktrace.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/kernel/stacktrace.c b/kernel/stacktrace.c
index 6d1f68b7e528..48703b252434 100644
--- a/kernel/stacktrace.c
+++ b/kernel/stacktrace.c
@@ -141,7 +141,8 @@ unsigned int stack_trace_save_tsk(struct task_struct *tsk, unsigned long *store,
 	struct stacktrace_cookie c = {
 		.store	= store,
 		.size	= size,
-		.skip	= skipnr + 1,
+		/* skip this function if they are tracing us */
+		.skip	= skipnr + !!(current == tsk),
 	};
 
 	if (!try_get_task_stack(tsk))
@@ -298,7 +299,8 @@ unsigned int stack_trace_save_tsk(struct task_struct *task,
 	struct stack_trace trace = {
 		.entries	= store,
 		.max_entries	= size,
-		.skip		= skipnr + 1,
+		/* skip this function if they are tracing us */
+		.skip	= skipnr + !!(current == tsk),
 	};
 
 	save_stack_trace_tsk(task, &trace);
-- 
2.23.0


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

* Re: [PATCH v2] stacktrace: don't skip first entry on noncurrent tasks
  2019-10-29  7:19   ` [PATCH v2] " Jiri Slaby
@ 2019-10-29 13:35     ` Josh Poimboeuf
  2019-10-30  6:09     ` Jiri Slaby
  2019-10-30  7:25     ` [PATCH v3] " Jiri Slaby
  2 siblings, 0 replies; 7+ messages in thread
From: Josh Poimboeuf @ 2019-10-29 13:35 UTC (permalink / raw)
  To: Jiri Slaby; +Cc: tglx, linux-kernel

On Tue, Oct 29, 2019 at 08:19:44AM +0100, Jiri Slaby wrote:
> When doing cat /proc/<PID>/stack, the output is missing the first entry.
> When the current code walks the stack starting in stack_trace_save_tsk,
> it skips all scheduler functions (that's OK) plus one more function. But
> this one function should be skipped only for the 'current' task as it is
> stack_trace_save_tsk proper.
> 
> The original code (before the common infrastructure) skipped one
> function only for the 'current' task -- see save_stack_trace_tsk before
> 3599fe12a125. So do so also in the new infrastructure now.
> 
> Signed-off-by: Jiri Slaby <jslaby@suse.cz>
> Fixes: 214d8ca6ee85 ("stacktrace: Provide common infrastructure")
> Cc: Thomas Gleixner <tglx@linutronix.de>
> Cc: Josh Poimboeuf <jpoimboe@redhat.com>
> ---
> 
> Notes:
>     [v2] add the same for the !CONFIG_ARCH_STACKWALK case

Acked-by: Josh Poimboeuf <jpoimboe@redhat.com>

-- 
Josh


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

* Re: [PATCH v2] stacktrace: don't skip first entry on noncurrent tasks
  2019-10-29  7:19   ` [PATCH v2] " Jiri Slaby
  2019-10-29 13:35     ` Josh Poimboeuf
@ 2019-10-30  6:09     ` Jiri Slaby
  2019-10-30  7:25     ` [PATCH v3] " Jiri Slaby
  2 siblings, 0 replies; 7+ messages in thread
From: Jiri Slaby @ 2019-10-30  6:09 UTC (permalink / raw)
  To: tglx; +Cc: linux-kernel, Josh Poimboeuf

On 29. 10. 19, 8:19, Jiri Slaby wrote:
> --- a/kernel/stacktrace.c
> +++ b/kernel/stacktrace.c
> @@ -298,7 +299,8 @@ unsigned int stack_trace_save_tsk(struct task_struct *task,

Argh, "task" here and:

>  	struct stack_trace trace = {
>  		.entries	= store,
>  		.max_entries	= size,
> -		.skip		= skipnr + 1,
> +		/* skip this function if they are tracing us */
> +		.skip	= skipnr + !!(current == tsk),

"tsk" here. Scratch this one.

thanks,
-- 
js
suse labs

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

* [PATCH v3] stacktrace: don't skip first entry on noncurrent tasks
  2019-10-29  7:19   ` [PATCH v2] " Jiri Slaby
  2019-10-29 13:35     ` Josh Poimboeuf
  2019-10-30  6:09     ` Jiri Slaby
@ 2019-10-30  7:25     ` Jiri Slaby
  2019-11-04 20:24       ` [tip: core/urgent] stacktrace: Don't " tip-bot2 for Jiri Slaby
  2 siblings, 1 reply; 7+ messages in thread
From: Jiri Slaby @ 2019-10-30  7:25 UTC (permalink / raw)
  To: tglx; +Cc: linux-kernel, Jiri Slaby, Michal Suchanek, Josh Poimboeuf

When doing cat /proc/<PID>/stack, the output is missing the first entry.
When the current code walks the stack starting in stack_trace_save_tsk,
it skips all scheduler functions (that's OK) plus one more function. But
this one function should be skipped only for the 'current' task as it is
stack_trace_save_tsk proper.

The original code (before the common infrastructure) skipped one
function only for the 'current' task -- see save_stack_trace_tsk before
3599fe12a125. So do so also in the new infrastructure now.

Signed-off-by: Jiri Slaby <jslaby@suse.cz>
Fixes: 214d8ca6ee85 ("stacktrace: Provide common infrastructure")
Tested-by: Michal Suchanek <msuchanek@suse.de>
Acked-by: Josh Poimboeuf <jpoimboe@redhat.com>
Cc: Thomas Gleixner <tglx@linutronix.de>
---

Notes:
    [v2] add the same for the !ARCH_STACKWALK case
    
    [v3] fix build on !ARCH_STACKWALK

 kernel/stacktrace.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/kernel/stacktrace.c b/kernel/stacktrace.c
index 6d1f68b7e528..c9ea7eb2cb1a 100644
--- a/kernel/stacktrace.c
+++ b/kernel/stacktrace.c
@@ -141,7 +141,8 @@ unsigned int stack_trace_save_tsk(struct task_struct *tsk, unsigned long *store,
 	struct stacktrace_cookie c = {
 		.store	= store,
 		.size	= size,
-		.skip	= skipnr + 1,
+		/* skip this function if they are tracing us */
+		.skip	= skipnr + !!(current == tsk),
 	};
 
 	if (!try_get_task_stack(tsk))
@@ -298,7 +299,8 @@ unsigned int stack_trace_save_tsk(struct task_struct *task,
 	struct stack_trace trace = {
 		.entries	= store,
 		.max_entries	= size,
-		.skip		= skipnr + 1,
+		/* skip this function if they are tracing us */
+		.skip	= skipnr + !!(current == task),
 	};
 
 	save_stack_trace_tsk(task, &trace);
-- 
2.23.0


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

* [tip: core/urgent] stacktrace: Don't skip first entry on noncurrent tasks
  2019-10-30  7:25     ` [PATCH v3] " Jiri Slaby
@ 2019-11-04 20:24       ` tip-bot2 for Jiri Slaby
  0 siblings, 0 replies; 7+ messages in thread
From: tip-bot2 for Jiri Slaby @ 2019-11-04 20:24 UTC (permalink / raw)
  To: linux-tip-commits
  Cc: Jiri Slaby, Thomas Gleixner, Michal Suchanek, Josh Poimboeuf,
	Ingo Molnar, Borislav Petkov, linux-kernel

The following commit has been merged into the core/urgent branch of tip:

Commit-ID:     b0c51f158455e31d5024100cf3580fcd88214b0e
Gitweb:        https://git.kernel.org/tip/b0c51f158455e31d5024100cf3580fcd88214b0e
Author:        Jiri Slaby <jslaby@suse.cz>
AuthorDate:    Wed, 30 Oct 2019 08:25:45 +01:00
Committer:     Thomas Gleixner <tglx@linutronix.de>
CommitterDate: Mon, 04 Nov 2019 21:19:25 +01:00

stacktrace: Don't skip first entry on noncurrent tasks

When doing cat /proc/<PID>/stack, the output is missing the first entry.
When the current code walks the stack starting in stack_trace_save_tsk,
it skips all scheduler functions (that's OK) plus one more function. But
this one function should be skipped only for the 'current' task as it is
stack_trace_save_tsk proper.

The original code (before the common infrastructure) skipped one
function only for the 'current' task -- see save_stack_trace_tsk before
3599fe12a125. So do so also in the new infrastructure now.

Fixes: 214d8ca6ee85 ("stacktrace: Provide common infrastructure")
Signed-off-by: Jiri Slaby <jslaby@suse.cz>
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Tested-by: Michal Suchanek <msuchanek@suse.de>
Acked-by: Josh Poimboeuf <jpoimboe@redhat.com>
Link: https://lkml.kernel.org/r/20191030072545.19462-1-jslaby@suse.cz

---
 kernel/stacktrace.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/kernel/stacktrace.c b/kernel/stacktrace.c
index 6d1f68b..c9ea7eb 100644
--- a/kernel/stacktrace.c
+++ b/kernel/stacktrace.c
@@ -141,7 +141,8 @@ unsigned int stack_trace_save_tsk(struct task_struct *tsk, unsigned long *store,
 	struct stacktrace_cookie c = {
 		.store	= store,
 		.size	= size,
-		.skip	= skipnr + 1,
+		/* skip this function if they are tracing us */
+		.skip	= skipnr + !!(current == tsk),
 	};
 
 	if (!try_get_task_stack(tsk))
@@ -298,7 +299,8 @@ unsigned int stack_trace_save_tsk(struct task_struct *task,
 	struct stack_trace trace = {
 		.entries	= store,
 		.max_entries	= size,
-		.skip		= skipnr + 1,
+		/* skip this function if they are tracing us */
+		.skip	= skipnr + !!(current == task),
 	};
 
 	save_stack_trace_tsk(task, &trace);

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

end of thread, other threads:[~2019-11-04 20:24 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-10-25  6:52 [PATCH] stacktrace: don't skip first entry on noncurrent tasks Jiri Slaby
2019-10-25 14:21 ` Josh Poimboeuf
2019-10-29  7:19   ` [PATCH v2] " Jiri Slaby
2019-10-29 13:35     ` Josh Poimboeuf
2019-10-30  6:09     ` Jiri Slaby
2019-10-30  7:25     ` [PATCH v3] " Jiri Slaby
2019-11-04 20:24       ` [tip: core/urgent] stacktrace: Don't " tip-bot2 for Jiri Slaby

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.