From: David Chinner <dgc@sgi.com>
To: Andi Kleen <andi@firstfloor.org>
Cc: David Chinner <dgc@sgi.com>, Eric Sandeen <sandeen@sandeen.net>,
Timothy Shimmin <tes@sgi.com>, Niv Sardi <xaiki@cxhome.ath.cx>,
Christoph Hellwig <hch@lst.de>,
xfs@oss.sgi.com
Subject: Re: likely and unlikely was: Re: [PATCH] split xfs_ioc_xattr
Date: Tue, 22 Apr 2008 07:41:47 +1000 [thread overview]
Message-ID: <20080421214147.GP108924158@sgi.com> (raw)
In-Reply-To: <20080421075558.GC14446@one.firstfloor.org>
On Mon, Apr 21, 2008 at 09:55:58AM +0200, Andi Kleen wrote:
> On Mon, Apr 21, 2008 at 10:33:43AM +1000, David Chinner wrote:
> > On Fri, Apr 18, 2008 at 09:05:25AM -0500, Eric Sandeen wrote:
> > > ISTR that the dir2 code on Irix had tons of compiler pragmas for likely
> > > and unlikely paths, and that it actually was well-profiled and tested.
> > > Did that ever get translated into Linux hints?
> >
> > The Irix code (#pragma mips_frequency_hint [FREQUENT|NEVER|INIT])
> > only controllered physical placement of code, it never issued
> > branch hints.
>
> likely/unlikely control placement too and I think it is actually
> more important for kernel code than branch hints (which x86 doesn't
> have explictely unlike ia64, they only way to do a branch hint is to reorder
> the code) due to icache effects.
>
> i.e. a "never" block gets moved out of line,
> > while a "frequent" block is left inline. Realistically, the way
> > this is used in the Irix dir2 code is completely useless - code like
> > this:
>
> Indeed because gcc has a heuristic that early returns are considered
> unlikely:
>
> /* Branch causing function to terminate is probably not taken. */
> DEF_PREDICTOR (PRED_TREE_EARLY_RETURN, "early return (on trees)", HITRATE (61),
> 0)
>
> It's only 61%, but that should be enough.
>
> I'm somewhat surprised that MipsPro didn't have such a default heuristic
> though ...
Different heuristics. IIRC the "true" branch of the if was typically
put inline so you could implicitly code your logic to get the
compiler to do the right thing....
And with the branch delay slot, things like:
if (error)
return error;
translate into three instructions:
cmp error, r0
jne return_prelude
mov v0, error <<< BDS
Seeing as the BDS is only executed when the jump occurs and v0 holds
the function return value, there's no out of line code to bother
hinting about....
Cheers,
Dave.
--
Dave Chinner
Principal Engineer
SGI Australian Software Group
prev parent reply other threads:[~2008-04-21 21:41 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2008-03-19 20:40 [PATCH] split xfs_ioc_xattr Christoph Hellwig
2008-04-14 3:14 ` Niv Sardi
2008-04-14 3:29 ` Christoph Hellwig
2008-04-16 3:47 ` Niv Sardi
2008-04-16 6:37 ` David Chinner
2008-04-16 7:06 ` Timothy Shimmin
2008-04-16 7:29 ` Andi Kleen
2008-04-18 7:06 ` likely and unlikely was: " Timothy Shimmin
2008-04-18 13:34 ` Andi Kleen
2008-04-18 14:05 ` Eric Sandeen
2008-04-21 0:33 ` David Chinner
2008-04-21 7:55 ` Andi Kleen
2008-04-21 21:41 ` David Chinner [this message]
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=20080421214147.GP108924158@sgi.com \
--to=dgc@sgi.com \
--cc=andi@firstfloor.org \
--cc=hch@lst.de \
--cc=sandeen@sandeen.net \
--cc=tes@sgi.com \
--cc=xaiki@cxhome.ath.cx \
--cc=xfs@oss.sgi.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox