From: Steven Rostedt <rostedt@goodmis.org>
To: Mathieu Desnoyers <mathieu.desnoyers@polymtl.ca>
Cc: linux-kernel@vger.kernel.org, Ingo Molnar <mingo@elte.hu>,
Andrew Morton <akpm@linux-foundation.org>,
Frederic Weisbecker <fweisbec@gmail.com>
Subject: Re: [PATCH 1/5] [PATCH 1/5] function-graph/x86: replace unbalanced ret with jmp
Date: Tue, 13 Oct 2009 17:10:14 -0400 [thread overview]
Message-ID: <1255468214.7113.2396.camel@gandalf.stny.rr.com> (raw)
In-Reply-To: <20091013204702.GA4533@Krystal>
On Tue, 2009-10-13 at 16:47 -0400, Mathieu Desnoyers wrote:
> * Steven Rostedt (rostedt@goodmis.org) wrote:
> > From: Steven Rostedt <srostedt@redhat.com>
> >
> > The function graph tracer replaces the return address with a hook to
> > trace the exit of the function call. This hook will finish by returning
> > to the real location the function should return to.
> >
> > But the current implementation uses a ret to jump to the real return
> > location. This causes a imbalance between calls and ret. That is
> > the original function does a call, the ret goes to the handler
> > and then the handler does a ret without a matching call.
> >
> > Although the function graph tracer itself still breaks the branch
> > predictor by replacing the original ret, by using a second ret and
> > causing an imbalance, it breaks the predictor even more.
> >
> > This patch replaces the ret with a jmp to keep the calls and ret
> > balanced. I tested this on one box and it showed a 1.7% increase in
> > performance. Another box only showed a small 0.3% increase. But no
> > box that I tested this on showed a decrease in performance by making this
> > change.
>
> This sounds exactly like what I proposed at LPC. I'm glad it shows
> actual improvements.
This is what we discussed at LPC. We both were under the assumption that
a jump would work. The question was how to make that jump without hosing
registers.
We lucked out that this is the back end of the return sequence. Where we
can still clobber callie registers. (just not the ones holding the
return code).
>
> Just to make sure I understand, the old sequence was:
>
> call fct
> call ftrace_entry
> ret to fct
> ret to ftrace_exit
> ret to caller
>
> and you now have:
>
> call fct
> call ftrace_entry
> ret to fct
> ret to ftrace_exit
> jmp to caller
>
> Am I correct ?
Almost.
What it was:
call function
function:
call mcount
mcount:
call ftrace_entry
ftrace_entry:
mess up with return code of caller
ret
ret
[function code]
ret to ftrace_exit
ftrace_exit:
get real return
ret to original
So for the function we have 3 calls and 4 rets
Now we have:
What it was:
call function
function:
call mcount
mcount:
call ftrace_entry
ftrace_entry:
mess up with return code of caller
ret
ret
[function code]
ret to ftrace_exit
ftrace_exit:
get real return
jmp to original
Now we have 3 calls and 3 rets
Note the first call still does not match the ret, but we don't do two
rets anymore.
-- Steve
next prev parent reply other threads:[~2009-10-13 21:12 UTC|newest]
Thread overview: 20+ messages / expand[flat|nested] mbox.gz Atom feed top
2009-10-13 20:33 [PATCH 0/5] [GIT PULL][2.6.33] tracing: various updates Steven Rostedt
2009-10-13 20:33 ` [PATCH 1/5] [PATCH 1/5] function-graph/x86: replace unbalanced ret with jmp Steven Rostedt
2009-10-13 20:47 ` Mathieu Desnoyers
2009-10-13 21:10 ` Steven Rostedt [this message]
2009-10-13 21:21 ` Mathieu Desnoyers
2009-10-13 21:26 ` Steven Rostedt
2009-10-13 22:32 ` Mathieu Desnoyers
2009-10-13 21:02 ` Frederic Weisbecker
2009-10-13 21:12 ` Steven Rostedt
2009-10-13 22:26 ` Frederic Weisbecker
2009-10-14 6:58 ` [tip:tracing/core] function-graph/x86: Replace " tip-bot for Steven Rostedt
2009-10-13 20:33 ` [PATCH 2/5] [PATCH 2/5] tracing: export symbols for kernel lock tracepoints Steven Rostedt
2009-10-13 20:43 ` Frederic Weisbecker
2009-10-13 21:14 ` Steven Rostedt
2009-10-13 20:33 ` [PATCH 3/5] [PATCH 3/5] tracing: support multiple pids in set_pid_ftrace file Steven Rostedt
2009-10-14 6:58 ` [tip:tracing/core] tracing: Support " tip-bot for jolsa@redhat.com
2009-10-13 20:33 ` [PATCH 4/5] [PATCH 4/5] tracing: enable records during the module load Steven Rostedt
2009-10-14 6:59 ` [tip:tracing/core] tracing: Enable " tip-bot for Jiri Olsa
2009-10-13 20:33 ` [PATCH 5/5] [PATCH 5/5] tracing: enabling "__cold" functions Steven Rostedt
2009-10-14 6:59 ` [tip:tracing/core] tracing: Enable " tip-bot for Jiri Olsa
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=1255468214.7113.2396.camel@gandalf.stny.rr.com \
--to=rostedt@goodmis.org \
--cc=akpm@linux-foundation.org \
--cc=fweisbec@gmail.com \
--cc=linux-kernel@vger.kernel.org \
--cc=mathieu.desnoyers@polymtl.ca \
--cc=mingo@elte.hu \
/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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®