From: Jeremy Fitzhardinge <jeremy@goop.org>
To: Steven Rostedt <rostedt@goodmis.org>
Cc: Mathieu Desnoyers <mathieu.desnoyers@polymtl.ca>,
Ingo Molnar <mingo@elte.hu>, LKML <linux-kernel@vger.kernel.org>,
"Paul E. McKenney" <paulmck@linux.vnet.ibm.com>,
Andrew Morton <akpm@linux-foundation.org>,
Christoph Hellwig <hch@lst.de>,
Arjan van de Ven <arjan@infradead.org>
Subject: Re: [patch 2/3] RCU move trace defines to rcupdate_types.h
Date: Fri, 17 Apr 2009 10:09:46 -0700 [thread overview]
Message-ID: <49E8B7DA.4050504@goop.org> (raw)
In-Reply-To: <alpine.DEB.2.00.0904171234400.14919@gandalf.stny.rr.com>
Steven Rostedt wrote:
> I was talking with Arjan about this in San Francisco. The expense of doing
> function calls. He told me (and he can correct me if I'm wrong here) that
> function calls are like branch predictions. The branch part is the fact
> that a retq is a jmp that can go to different locations. There's logic in
> the CPU to match calls with retqs to speed this up.
>
Right. The call is to a fixed address, so there's no prediction needed
at all; the CPU can immediately start fetching instructions at the call
target without missing a beat. When it hits the ret in the function,
assuming nobody has been playing games with the stack pointer or
modifying the return address on the stack, it can just look up the
return address from its cache and start fetching from there, again with
no bubbles. It should be very close to a pair of jumps, aside from one
extra memory write (for the return address on stack) - and that
shouldn't be too bad, because the chances are the cache is hot for the
stack.
> He also told me that the "mcount" retq that I do is actually more
> expensive. The logic does not expect a function to return immediately.
> (for stubs, I'm not sure that was a good design).
>
> Hence,
>
> call mcount
>
> [...]
>
> mcount:
> retq
>
>
> is expensive, compared to a call to a function that actually does
> something.
>
> Again, Arjan can correct me here, since I'm just trying to paraphrase what
> he told me.
>
Sounds reasonable; it takes a little while for the CPU to work out what
the return address will be, even though its cached, so doing an
immediate ret will cause a bubble while it sorts itself out. But that
shouldn't be an issue for the calls I'm talking about.
J
next prev parent reply other threads:[~2009-04-17 17:09 UTC|newest]
Thread overview: 17+ messages / expand[flat|nested] mbox.gz Atom feed top
2009-04-17 0:37 [patch 0/3] Tracepoints kill rcupdate header dependency (v2) mathieu.desnoyers
2009-04-17 0:37 ` [patch 1/3] rcupdate header remove whitespace mathieu.desnoyers
2009-04-17 0:37 ` [patch 2/3] RCU move trace defines to rcupdate_types.h mathieu.desnoyers
2009-04-17 1:10 ` Jeremy Fitzhardinge
2009-04-17 1:22 ` Steven Rostedt
2009-04-17 1:42 ` Mathieu Desnoyers
2009-04-17 1:47 ` Mathieu Desnoyers
2009-04-17 6:23 ` Jeremy Fitzhardinge
2009-04-17 5:57 ` Jeremy Fitzhardinge
2009-04-17 15:16 ` Mathieu Desnoyers
2009-04-17 15:26 ` Jeremy Fitzhardinge
2009-04-17 15:42 ` Mathieu Desnoyers
2009-04-17 16:14 ` Jeremy Fitzhardinge
2009-04-17 16:38 ` Steven Rostedt
2009-04-17 17:09 ` Jeremy Fitzhardinge [this message]
2009-04-17 2:38 ` [patch 2/3] RCU move trace defines to rcupdate_types.h (update) Mathieu Desnoyers
2009-04-17 0:37 ` [patch 3/3] tracepoints : remove rcupdate.h dependency mathieu.desnoyers
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=49E8B7DA.4050504@goop.org \
--to=jeremy@goop.org \
--cc=akpm@linux-foundation.org \
--cc=arjan@infradead.org \
--cc=hch@lst.de \
--cc=linux-kernel@vger.kernel.org \
--cc=mathieu.desnoyers@polymtl.ca \
--cc=mingo@elte.hu \
--cc=paulmck@linux.vnet.ibm.com \
--cc=rostedt@goodmis.org \
/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