All of lore.kernel.org
 help / color / mirror / Atom feed
From: Frederic Weisbecker <fweisbec@gmail.com>
To: Mike Frysinger <vapier.adi@gmail.com>
Cc: Steven Rostedt <rostedt@goodmis.org>, linux-kernel@vger.kernel.org
Subject: Re: [PATCH v3] ftrace: document basic ftracer/ftracer graph needs
Date: Sun, 14 Jun 2009 04:24:28 +0200	[thread overview]
Message-ID: <20090614022427.GE5986@nowhere> (raw)
In-Reply-To: <8bd0f97a0906131852r255a30a5p1d602a6eb7778ff4@mail.gmail.com>

On Sat, Jun 13, 2009 at 09:52:18PM -0400, Mike Frysinger wrote:
> On Sat, Jun 13, 2009 at 21:24, Frederic Weisbecker wrote:
> > On Sat, Jun 13, 2009 at 08:21:53PM -0400, Mike Frysinger wrote:
> >> +HAVE_FUNCTION_GRAPH_TRACER
> >
> > Should be HAVE_FUNCTION_TRACER, right?
> 
> yes
> 
> > There is one crucial missing thing, I mean "save all state needed by the ABI"
> > can be more detailed. do_trace _must_
> > save the scratch and argument registers to the stack because
> > the traced function may have parameters passed by registers,
> > initialized things on scratch registers, and this state
> > must be left intact before calling ftrace_trace_function()
> 
> parameters passed by registers, yes, but as for scratch registers,
> that depends on the toolchain and where the mcount invocation occurs.
> if it's before the function prolog, then no, it doesnt need to worry
> about any scratch registers.  if it's after, then yes, it probably
> needs to worry about those things.  but this is why i have a paragraph
> saying "go read your abi documentation" and review glibc.



Ok, then in this case, just talk about it as a constraint that
may be or not handled by the arch specific mcount.

It's really a prerequisite to check on every archs so I think
it's worth showing this mandatory stage in the recipe.


 
> >> +For information on how to implement prepare_ftrace_return(), simply look at
> >> +the x86 version.  The only architecture-specific piece in it is the setup of
> >> +the fault recovery table (the asm(...) code).  The rest should be the same
> >> +across architectures.
> >> +
> >> +Here is the pseudo code for the new return_to_handler assembly function.  Note
> >> +that the ABI that applies here is different from what applies to the mcount
> >> +code.  Here you are returning from a function, so you might be able to skimp
> >> +on things saved/restored.
> >
> > It would be nice to add details about that, especially about a constant rule:
> > return_to_handler must save/restore the return value of the current exiting
> > function around ftrace_return_to_handler call.
> >
> > And this return value might be stored in more than one register for
> > 64 bits return values.
> >
> > But we don't need to save/restore the other scratch  registers because the
> > traced function is exiting and won't need anymore values stored in them.
> 
> i'm not familiar with other architectures and crazy shit that might go
> down here which is why i kind of skimped on details.  for the Blackfin
> port, i know what i have to do -- just save/restore the return
> registers (r0 for 32bits, +r1 for 64bits, +p0 for >64bits).  but i
> purposefully tried to avoid ABI details because i dont want this
> turning into "on <arch>, do <whole bunch of details>, on <arch2>, do
> <whole bunch of details>, ....".



That's not what I'm suggesting.
As I explained above, it's about a generic and cross arch constraint.

The details of implementation are only a concern for the developer.


> 
> the scratch register is more because the exit code is coming after the
> function epilog rather than "exiting it" ...


Yeah, that's what I meant by "exiting" :)


> 
> i dont mind adding tips, but the last thing i want is people
> complaining that they did what the docs said and now things crashed
> because they didnt fully grasp the "it's your ABI, so it's your
> problem".



I'm only talking about generic rules here. Every ABI has conventions
about calls, scratch registers, etc...

But here we are using tracing code in very fragile paths that have
common constraints on every archs. Those constraints concern
common properties of every CPU, the implementation which implement
these constraints is only a concern of the arch developer.


> > Also, we had some problems with return_to_handler in x86-64.
> > We needed to allocate a large stack room (0x80 bytes) before calling
> > ftrace_return_to_handler(). The funny thing is that we still don't know
> > why we needed to do that, but omitting that resulted in crashes :-)
> 
> without knowing anything about x86-64 treating of the stack, it does
> seem weird.  with the Blackfin arch, the called function is
> responsible for allocating its own space.


That's also what does x86, really that's a mystery..


> >> +HAVE_FTRACE_SYSCALLS
> >> +---------------------
> >> +
> >> +<details to be filled>
> >
> > This part doesn't need more for now because it may change soon
> > since the syscall tracing is currently reworked.
> > We'll fill it once it reaches a more established state.
> >
> >> +HAVE_DYNAMIC_FTRACE
> >> +---------------------
> >> +
> >> +<details to be filled>
> >
> > But this part is important :)
> 
> i filled in what i could reverse engineer ... and these two bits
> looked way more complicated than was worth me trying to figure out.
> these are what i'd be interested in next though.
> -mike


Never mind, this documentation can be filled through several iterations.
This patch already provides very useful explanations.

Thanks,
Frederic.


  reply	other threads:[~2009-06-14  2:24 UTC|newest]

Thread overview: 42+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-06-10  8:48 [PATCH 1/2] ftrace.txt: fix typo in function grapher name Mike Frysinger
2009-06-10  8:48 ` [PATCH 2/2] ftrace: document basic ftracer/ftracer graph needs Mike Frysinger
2009-06-10 17:04   ` Steven Rostedt
2009-06-10 18:31     ` Mike Frysinger
2009-06-10 18:45       ` Steven Rostedt
2009-06-10 19:07         ` Mike Frysinger
2009-06-10 19:11           ` Steven Rostedt
2009-06-10 19:19             ` Mike Frysinger
2009-06-10 19:34               ` Steven Rostedt
2009-06-10 19:45                 ` Mike Frysinger
2009-06-10 18:56   ` Steven Rostedt
2009-06-10 20:52   ` [PATCH 2/2 v2] " Mike Frysinger
2009-06-12  8:10     ` Mike Frysinger
2009-06-13 22:24       ` Frederic Weisbecker
2009-06-14  0:21         ` [PATCH v3] " Mike Frysinger
2009-06-14  1:24           ` Frederic Weisbecker
2009-06-14  1:52             ` Mike Frysinger
2009-06-14  2:24               ` Frederic Weisbecker [this message]
2009-06-14  3:05             ` [PATCH v4] " Mike Frysinger
2009-06-14 13:35               ` Frederic Weisbecker
2009-06-23 12:30               ` Mike Frysinger
2009-06-23 13:43                 ` Ingo Molnar
2009-09-14  1:54                   ` Mike Frysinger
2009-09-14  2:35                     ` Steven Rostedt
2009-09-14 19:48               ` Steven Rostedt
2009-09-14 20:21                 ` Mike Frysinger
2009-09-14 20:53                   ` Steven Rostedt
2009-09-14 21:01                     ` Mike Frysinger
2009-09-14 21:20                       ` Steven Rostedt
2009-09-14 21:30                         ` Mike Frysinger
2009-09-14 21:41                           ` Steven Rostedt
2009-09-14 20:28                 ` Frederic Weisbecker
2009-09-15  0:10                 ` [PATCH v5] " Mike Frysinger
2009-09-15  1:48                   ` [PATCH] [GIT PULL] " Steven Rostedt
2009-09-17  7:47                   ` [tip:tracing/core] ftrace: document function and function graph implementation tip-bot for Mike Frysinger
2009-06-14 15:10     ` [PATCH 2/2 v2] ftrace: document basic ftracer/ftracer graph needs Wu Zhangjin
2009-06-14 15:45       ` Mike Frysinger
2009-06-14 16:09         ` Wu Zhangjin
2009-06-15  6:25           ` Mike Frysinger
2009-06-10 17:02 ` [PATCH 1/2] ftrace.txt: fix typo in function grapher name Steven Rostedt
2009-06-10 17:08 ` [PATCH][GIT PULL] ftrace/documentation: " Steven Rostedt
2009-06-10 22:33 ` [tip:tracing/core] " tip-bot for Mike Frysinger

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=20090614022427.GE5986@nowhere \
    --to=fweisbec@gmail.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=rostedt@goodmis.org \
    --cc=vapier.adi@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.