linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] ftrace/jprobes/s390: Fix conflict between jprobes and function graph tracing
@ 2016-07-18 13:26 Jiri Olsa
  2016-07-28 18:39 ` Steven Rostedt
  0 siblings, 1 reply; 4+ messages in thread
From: Jiri Olsa @ 2016-07-18 13:26 UTC (permalink / raw)
  To: Steven Rostedt
  Cc: lkml, Ingo Molnar, Michael Grundy, Martin Schwidefsky, Masami Hiramatsu

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.

Signed-off-by: Jiri Olsa <jolsa@kernel.org>
---
 arch/s390/kernel/kprobes.c | 12 ++++++++++++
 1 file changed, 12 insertions(+)

diff --git a/arch/s390/kernel/kprobes.c b/arch/s390/kernel/kprobes.c
index 250f5972536a..dd6306c51bd6 100644
--- a/arch/s390/kernel/kprobes.c
+++ b/arch/s390/kernel/kprobes.c
@@ -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.4.11

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

* Re: [PATCH] ftrace/jprobes/s390: Fix conflict between jprobes and function graph tracing
  2016-07-18 13:26 [PATCH] ftrace/jprobes/s390: Fix conflict between jprobes and function graph tracing Jiri Olsa
@ 2016-07-28 18:39 ` Steven Rostedt
  2016-07-31 12:21   ` Jiri Olsa
  0 siblings, 1 reply; 4+ messages in thread
From: Steven Rostedt @ 2016-07-28 18:39 UTC (permalink / raw)
  To: Jiri Olsa
  Cc: lkml, Ingo Molnar, Michael Grundy, Martin Schwidefsky, Masami Hiramatsu

On Mon, 18 Jul 2016 15:26:41 +0200
Jiri Olsa <jolsa@kernel.org> 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.

Acked-by: Steven Rostedt <rostedt@goodmis.org>

-- Steve

> 
> Signed-off-by: Jiri Olsa <jolsa@kernel.org>
> ---
>  arch/s390/kernel/kprobes.c | 12 ++++++++++++
>  1 file changed, 12 insertions(+)
> 
> diff --git a/arch/s390/kernel/kprobes.c b/arch/s390/kernel/kprobes.c
> index 250f5972536a..dd6306c51bd6 100644
> --- a/arch/s390/kernel/kprobes.c
> +++ b/arch/s390/kernel/kprobes.c
> @@ -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 */

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

* Re: [PATCH] ftrace/jprobes/s390: Fix conflict between jprobes and function graph tracing
  2016-07-28 18:39 ` Steven Rostedt
@ 2016-07-31 12:21   ` Jiri Olsa
  2016-07-31 13:25     ` Martin Schwidefsky
  0 siblings, 1 reply; 4+ messages in thread
From: Jiri Olsa @ 2016-07-31 12:21 UTC (permalink / raw)
  To: Steven Rostedt
  Cc: Jiri Olsa, lkml, Ingo Molnar, Michael Grundy, Martin Schwidefsky,
	Masami Hiramatsu, linux-s390, Heiko Carstens

On Thu, Jul 28, 2016 at 02:39:33PM -0400, Steven Rostedt wrote:
> On Mon, 18 Jul 2016 15:26:41 +0200
> Jiri Olsa <jolsa@kernel.org> 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.

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

I can repost if needed

thanks,
jirka

> 
> Acked-by: Steven Rostedt <rostedt@goodmis.org>
> 
> -- Steve
> 
> > 
> > Signed-off-by: Jiri Olsa <jolsa@kernel.org>
> > ---
> >  arch/s390/kernel/kprobes.c | 12 ++++++++++++
> >  1 file changed, 12 insertions(+)
> > 
> > diff --git a/arch/s390/kernel/kprobes.c b/arch/s390/kernel/kprobes.c
> > index 250f5972536a..dd6306c51bd6 100644
> > --- a/arch/s390/kernel/kprobes.c
> > +++ b/arch/s390/kernel/kprobes.c
> > @@ -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 */
> 

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

* Re: [PATCH] ftrace/jprobes/s390: Fix conflict between jprobes and function graph tracing
  2016-07-31 12:21   ` Jiri Olsa
@ 2016-07-31 13:25     ` Martin Schwidefsky
  0 siblings, 0 replies; 4+ messages in thread
From: Martin Schwidefsky @ 2016-07-31 13:25 UTC (permalink / raw)
  To: Jiri Olsa
  Cc: Steven Rostedt, Jiri Olsa, lkml, Ingo Molnar, Michael Grundy,
	Masami Hiramatsu, linux-s390, Heiko Carstens

On Sun, 31 Jul 2016 14:21:14 +0200
Jiri Olsa <jolsa@redhat.com> wrote:

> On Thu, Jul 28, 2016 at 02:39:33PM -0400, Steven Rostedt wrote:
> > On Mon, 18 Jul 2016 15:26:41 +0200
> > Jiri Olsa <jolsa@kernel.org> 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.
> 
> 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.

-- 
blue skies,
   Martin.

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

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

end of thread, other threads:[~2016-07-31 13:52 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-07-18 13:26 [PATCH] ftrace/jprobes/s390: Fix conflict between jprobes and function graph tracing Jiri Olsa
2016-07-28 18:39 ` Steven Rostedt
2016-07-31 12:21   ` Jiri Olsa
2016-07-31 13:25     ` Martin Schwidefsky

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).