Skip to contentSkip to conversation

ftrace/jprobes/s390: Fix conflict between jprobes and function graph tracing

PATCH Applied Jiri Olsa 4 participants 4 messages Jul 18, 2016 – Jul 31, 2016 s390

lore
Share & tools
lore

Jiri Olsa

author
#0 lore raw

PATCH 1/1 ftrace/jprobes/s390: Fix conflict between jprobes and function graph tracing

This fixes the same issue Steven already fixed for x86 in following commit:

237d28db036e ftrace/jprobes/x86: Fix conflict between jprobes and function graph tracing

It fixes the crash, that happens when function graph tracing and jprobes are used simultaneously. Please refer to above commit for details.

---
 arch/s390/kernel/kprobes.c | 12 ++++++++++++
 1 file changed, 12 insertions(+)
arch/s390/kernel/kprobes.c +12 -0
index 250f5972536a..dd6306c51bd6 100644
@@ -690,6 +690,15 @@ int setjmp_pre_handler(struct kprobe *p, struct pt_regs *regs)
 	stack = (unsigned long) regs->gprs[15];
 
 	memcpy(kcb->jprobes_stack, (void *) stack, MIN_STACK_SIZE(stack));
+
+	/*
+	 * jprobes use jprobe_return() which skips the normal return
+	 * path of the function, and this messes up the accounting of the
+	 * function graph tracer to get messed up.
+	 *
+	 * Pause function graph tracing while performing the jprobe function.
+	 */
+	pause_graph_tracing();
 	return 1;
 }
 NOKPROBE_SYMBOL(setjmp_pre_handler);
@@ -705,6 +714,9 @@ int longjmp_break_handler(struct kprobe *p, struct pt_regs *regs)
 	struct kprobe_ctlblk *kcb = get_kprobe_ctlblk();
 	unsigned long stack;
 
+	/* It's OK to start function graph tracing again */
+	unpause_graph_tracing();
+
 	stack = (unsigned long) kcb->jprobe_saved_regs.gprs[15];
 
 	/* Put the regs back */
Signature · 1 line
2.4.11
Acked-by on v1 1/1
#1 lore raw
Quoted 8 lines · On Mon, 18 Jul 2016 15:26:41 +0200 Jiri Olsa <[email protected]> wrote:

This fixes the same issue Steven already fixed for x86 in following commit:

237d28db036e ftrace/jprobes/x86: Fix conflict between jprobes and function graph tracing

It fixes the crash, that happens when function graph tracing and jprobes are used simultaneously. Please refer to above commit for details.

I'm guessing that this should go in via the s390 tree.

-- Steve

Quoted 36 lines
---
 arch/s390/kernel/kprobes.c | 12 ++++++++++++
 1 file changed, 12 insertions(+)
arch/s390/kernel/kprobes.c +12 -0
index 250f5972536a..dd6306c51bd6 100644
@@ -690,6 +690,15 @@ int setjmp_pre_handler(struct kprobe *p, struct pt_regs *regs)
 	stack = (unsigned long) regs->gprs[15];
 
 	memcpy(kcb->jprobes_stack, (void *) stack, MIN_STACK_SIZE(stack));
+
+	/*
+	 * jprobes use jprobe_return() which skips the normal return
+	 * path of the function, and this messes up the accounting of the
+	 * function graph tracer to get messed up.
+	 *
+	 * Pause function graph tracing while performing the jprobe function.
+	 */
+	pause_graph_tracing();
 	return 1;
 }
 NOKPROBE_SYMBOL(setjmp_pre_handler);
@@ -705,6 +714,9 @@ int longjmp_break_handler(struct kprobe *p, struct pt_regs *regs)
 	struct kprobe_ctlblk *kcb = get_kprobe_ctlblk();
 	unsigned long stack;
 
+	/* It's OK to start function graph tracing again */
+	unpause_graph_tracing();
+
 	stack = (unsigned long) kcb->jprobe_saved_regs.gprs[15];
 
 	/* Put the regs back */
#2 lore raw
Quoted 6 lines · Steven Rostedt
Quoted 3 lines · On Mon, 18 Jul 2016 15:26:41 +0200 Jiri Olsa <[email protected]> wrote:

This fixes the same issue Steven already fixed for x86 in following commit:

Quoted 7 lines
Quoted 5 lines

237d28db036e ftrace/jprobes/x86: Fix conflict between jprobes and function graph tracing

It fixes the crash, that happens when function graph tracing and jprobes are used simultaneously. Please refer to above commit for details.

I'm guessing that this should go in via the s390 tree.

oops, I forgot to CC s390 mailing list.. CC-ing now

I can repost if needed

thanks,
jirka

Quoted 42 lines

-- Steve

Quoted 36 lines
---
 arch/s390/kernel/kprobes.c | 12 ++++++++++++
 1 file changed, 12 insertions(+)
arch/s390/kernel/kprobes.c +12 -0
index 250f5972536a..dd6306c51bd6 100644
@@ -690,6 +690,15 @@ int setjmp_pre_handler(struct kprobe *p, struct pt_regs *regs)
 	stack = (unsigned long) regs->gprs[15];
 
 	memcpy(kcb->jprobes_stack, (void *) stack, MIN_STACK_SIZE(stack));
+
+	/*
+	 * jprobes use jprobe_return() which skips the normal return
+	 * path of the function, and this messes up the accounting of the
+	 * function graph tracer to get messed up.
+	 *
+	 * Pause function graph tracing while performing the jprobe function.
+	 */
+	pause_graph_tracing();
 	return 1;
 }
 NOKPROBE_SYMBOL(setjmp_pre_handler);
@@ -705,6 +714,9 @@ int longjmp_break_handler(struct kprobe *p, struct pt_regs *regs)
 	struct kprobe_ctlblk *kcb = get_kprobe_ctlblk();
 	unsigned long stack;
 
+	/* It's OK to start function graph tracing again */
+	unpause_graph_tracing();
+
 	stack = (unsigned long) kcb->jprobe_saved_regs.gprs[15];
 
 	/* Put the regs back */
#3 lore raw
Quoted 13 lines · On Sun, 31 Jul 2016 14:21:14 +0200 Jiri Olsa <[email protected]> wrote:
Quoted 12 lines · Steven Rostedt
Quoted 8 lines · On Mon, 18 Jul 2016 15:26:41 +0200 Jiri Olsa <[email protected]> wrote:

This fixes the same issue Steven already fixed for x86 in following commit:

237d28db036e ftrace/jprobes/x86: Fix conflict between jprobes and function graph tracing

It fixes the crash, that happens when function graph tracing and jprobes are used simultaneously. Please refer to above commit for details.

Quoted 5 lines
Quoted 1 line

I'm guessing that this should go in via the s390 tree.

oops, I forgot to CC s390 mailing list.. CC-ing now

I can repost if needed

This is not necessary. I have seen your original patch and could test it now. As expected it crashes without the patch and works find with your patch.

Applied to linux-s390. Thanks.

Signature · 4 lines
blue skies,
   Martin.

"Reality continues to ruin my life." - Calvin.