All of lore.kernel.org
 help / color / mirror / Atom feed
From: Steven Rostedt <rostedt@goodmis.org>
To: wuzhangjin@gmail.com
Cc: linux-mips@linux-mips.org, linux-kernel@vger.kernel.org,
	Thomas Gleixner <tglx@linutronix.de>,
	Ralf Baechle <ralf@linux-mips.org>,
	Nicholas Mc Guire <der.herr@hofr.at>,
	Richard Sandiford <rdsandiford@googlemail.com>,
	David Daney <ddaney@caviumnetworks.com>,
	Adam Nemet <anemet@caviumnetworks.com>,
	Patrik Kluba <kpajko79@gmail.com>
Subject: Re: [PATCH -v5 10/11] tracing: add function graph tracer support for MIPS
Date: Mon, 26 Oct 2009 13:11:19 -0400	[thread overview]
Message-ID: <1256577079.26028.332.camel@gandalf.stny.rr.com> (raw)
In-Reply-To: <1256576225.5642.244.camel@falcon>

On Tue, 2009-10-27 at 00:57 +0800, Wu Zhangjin wrote:

> > I would be even more paranoid, and make sure each of those stores, store
> > into sp.
> 
> get it :-)
> 
> (I need to be more paranoid too, otherwise, Steven will not accept my
> patches!)

Sure I would accept them. I don't know of any MIPS boxes that Linus
runs. So I'm not afraid of crashing his boxes with these patches ;-)

> > > 
> > > We need to really stop before ftrace_push_return_trace to avoid messing
> > > with the stack :-) but if we have stopped the tracer, is it important to
> > > mess with the stack or not?
> > 
> > The ftrace_push_return_trace does not test if the trace stopped, that is
> > expected to be done by the caller. If you mess with the stack set up,
> > you will crash the box. Remember, before the failure, you could have
> > already replaced return jumps. Those will still be falling back to the
> > return_to_handler. If you mess with the stack, but don't update the
> > return, the other returns will be out of sync and call the wrong return
> > address.
> > 
> 
> As you can see, after stopping the function graph tracer(here the function is non-leaf)
> with ftrace_graph_stop() in ftrace_get_parent_addr(), I return the old parent_addr,
> this is only the stack address in the stack space of ftrace_graph_caller, which means
> that, I never touch the real stack address of the non-leaf function, and it will not trap
> into the return_to_handler hooker 'Cause the non-leaf function will load it's own normal
> return address from it's own stack, and then just return back normally.

But then you should not be calling the push function. That will still
push onto the graph stack.

The function graph tracer keeps a separate return stack
(current->ret_stack). This is what holds the return addresses.


(normal operation)

func1
  jalr _mcount
 
           push ra onto ret_stack
           replace ra with return_to_handler

  jr ra  --> return_to_handler


return_to_handler

   pop ret_stack, have original ra
   jr original_ra


Now what happens if we fail a call but still push to ret_stack

func1
  jalr _mcount

         (success)
          push ra onto ret_stack
          replace ra with return_to_handler

  jalr func2

    func2
      jalr _mcount

          (failed)
          push ra onto ret_stack  <<-- this is wrong!
          keep original ra

      jr ra << does not call tracer function!!!

  jr ra  << goes to return_to_handler


return_to_handler

   pop ra from ret_stack <<--- has func2 ra not func1 ra!!

jr func1_ra

**** CRASH ****

Make sense?

-- Steve

   


  reply	other threads:[~2009-10-26 17:11 UTC|newest]

Thread overview: 37+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-10-25 15:16 [PATCH -v5 00/11] ftrace for MIPS Wu Zhangjin
     [not found] ` <cover.1256483735.git.wuzhangjin@gmail.com>
2009-10-25 15:16   ` [PATCH -v5 01/11] tracing: convert trace_clock_local() as weak function Wu Zhangjin
2009-10-25 15:16   ` [PATCH -v5 02/11] MIPS: add mips_timecounter_read() to get high precision timestamp Wu Zhangjin
2009-10-26 14:01     ` Steven Rostedt
2009-10-26 14:25       ` Wu Zhangjin
2009-10-26 14:34         ` Steven Rostedt
2009-10-26 14:42           ` Wu Zhangjin
2009-10-25 15:16   ` [PATCH -v5 03/11] tracing: add MIPS specific trace_clock_local() Wu Zhangjin
2009-10-25 15:16   ` [PATCH -v5 04/11] tracing: add static function tracer support for MIPS Wu Zhangjin
2009-10-25 15:16   ` [PATCH -v5 05/11] tracing: enable HAVE_FUNCTION_TRACE_MCOUNT_TEST " Wu Zhangjin
2009-10-25 15:16   ` [PATCH -v5 06/11] tracing: add an endian argument to scripts/recordmcount.pl Wu Zhangjin
2009-10-25 15:16   ` [PATCH -v5 07/11] tracing: add dynamic function tracer support for MIPS Wu Zhangjin
2009-10-25 15:16   ` [PATCH -v5 08/11] tracing: not trace mips_timecounter_init() in MIPS Wu Zhangjin
2009-10-26  0:27     ` Frederic Weisbecker
2009-10-26  0:27       ` Frederic Weisbecker
2009-10-26  9:42       ` Wu Zhangjin
2009-11-02 21:43         ` Frederic Weisbecker
2009-11-03  1:34           ` Wu Zhangjin
2009-11-09  4:31           ` Wu Zhangjin
2009-11-09 11:53             ` Frederic Weisbecker
2009-11-09 12:08               ` Wu Zhangjin
2009-11-09 12:54             ` Steven Rostedt
2009-11-09 14:35               ` Wu Zhangjin
2009-10-25 15:17   ` [PATCH -v5 09/11] tracing: add IRQENTRY_EXIT for MIPS Wu Zhangjin
2009-10-26  0:36     ` Frederic Weisbecker
2009-10-26  7:26       ` Wu Zhangjin
2009-10-27 17:39         ` Frederic Weisbecker
2009-10-27 17:46           ` Frederic Weisbecker
2009-10-25 15:17   ` [PATCH -v5 10/11] tracing: add function graph tracer support " Wu Zhangjin
2009-10-26 15:13     ` Steven Rostedt
2009-10-26 16:11       ` Wu Zhangjin
2009-10-26 16:32         ` Steven Rostedt
2009-10-26 16:57           ` Wu Zhangjin
2009-10-26 17:11             ` Steven Rostedt [this message]
2009-10-25 15:17   ` [PATCH -v5 11/11] tracing: add dynamic function graph tracer " Wu Zhangjin
2009-10-26  1:13   ` [PATCH -v5 10/11] tracing: add function graph tracer support " Wu Zhangjin
2009-10-26  0:42 ` [PATCH -v5 00/11] ftrace " Frederic Weisbecker

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1256577079.26028.332.camel@gandalf.stny.rr.com \
    --to=rostedt@goodmis.org \
    --cc=anemet@caviumnetworks.com \
    --cc=ddaney@caviumnetworks.com \
    --cc=der.herr@hofr.at \
    --cc=kpajko79@gmail.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mips@linux-mips.org \
    --cc=ralf@linux-mips.org \
    --cc=rdsandiford@googlemail.com \
    --cc=tglx@linutronix.de \
    --cc=wuzhangjin@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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.