linuxppc-dev.lists.ozlabs.org archive mirror
 help / color / mirror / Atom feed
* Re: [PATCH 2/4] libata-core.c: add another IRQ calls
@ 2007-01-17  9:24 Mikael Pettersson
  2007-01-17 16:49 ` Jeff Garzik
  0 siblings, 1 reply; 8+ messages in thread
From: Mikael Pettersson @ 2007-01-17  9:24 UTC (permalink / raw)
  To: alan, benh, jeff; +Cc: arnd, linuxppc-dev, linux-ide, paulus

On Tue, 16 Jan 2007 17:04:27 -0500, Jeff Garzik wrote:
>Alan wrote:
>> Jeff - at some point we could eliminate a lot of the NULL checks like
>> these by having the registration code fill in the defaults where
>> appropriate ?
>
>libata policy up until this point has been to require all drivers fill 
>in the hook, either with the commonly-used default, or with their own 
>variant.  Thus, no NULL checks for required hooks, and you get an oops 
>if you fail this requirement.  I like that better than defaults buried 
>inside libata-core, where it is easier for programmers to forget them.
>
>But actually, it's an open question for the compiler guys whether this 
>case is preferred:
>
>	if (ap->ops->hook)
>		ap->ops->hook(foo, bar);
>	else
>		commonly_used_default(foo, bar);
>
>or this:
>
>	ap->ops->hook(foo, bar);
>
>With advanced branch prediction in modern CPUs, ISTR the first case may 
>be worth considering, even with the branch.

Indirect function calls incur at least two main costs:
- the 'call *' instruction itself suffers from poor branch
  prediction unless the HW is clever and the call patterns
  are highly biased -- most machines have worse branch
  predictors for indirect jumps than for direct jumps
- the compiler must generate code for setting up parameters
  and spilling the caller's registers, and for reloading the
  caller's registers after the call

If there is a highly common case, the code for that case
is available, and the code is cheap to execute (doesn't
require too many additional variables), then having an
explicit test + inline code is preferred. If any of these
conditions isn't met, then I wouldn't bother converting
the call to the if/inline/call combo.

There are compilers for OOP languages that routinely use
rewrites like the one above in order to optimise method calls.

/Mikael

^ permalink raw reply	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2007-01-25  3:46 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2007-01-17  9:24 [PATCH 2/4] libata-core.c: add another IRQ calls Mikael Pettersson
2007-01-17 16:49 ` Jeff Garzik
2007-01-17 20:31   ` Mikael Pettersson
2007-01-18  0:55     ` Akira Iguchi
     [not found]     ` <200701180055.l0I0tl6M021051@toshiba.co.jp>
2007-01-18  1:29       ` [PATCH] driver/ata: PATA driver for Celleb Akira Iguchi
2007-01-25  1:17       ` [PATCH 2/4] libata-core.c: add another IRQ calls Jeff Garzik
     [not found]       ` <200701180129.l0I1TL48013407@toshiba.co.jp>
2007-01-25  1:20         ` [PATCH] driver/ata: PATA driver for Celleb Jeff Garzik
2007-01-25  3:45           ` Benjamin Herrenschmidt

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).