public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Jeff Garzik <jeff@garzik.org>
To: Linux Kernel Mailing List <linux-kernel@vger.kernel.org>
Cc: Andrew Morton <akpm@linux-foundation.org>,
	Linus Torvalds <torvalds@linux-foundation.org>,
	suparna@in.ibm.com, Ingo Molnar <mingo@elte.hu>
Subject: Re: aio is unlikely
Date: Wed, 09 May 2007 18:06:58 -0400	[thread overview]
Message-ID: <46424602.3090404@garzik.org> (raw)
In-Reply-To: <200705092101.l49L1CF1023363@hera.kernel.org>

Linux Kernel Mailing List wrote:
> Gitweb:     http://git.kernel.org/git/?p=linux/kernel/git/torvalds/linux-2.6.git;a=commit;h=b8522ead3534c6cd06752b47a3bc380956191a2a
> Commit:     b8522ead3534c6cd06752b47a3bc380956191a2a
> Parent:     b41eeef14d7c73af6d16c7d02b7a939082a137ff
> Author:     Andrew Morton <akpm@osdl.org>
> AuthorDate: Wed May 9 02:34:58 2007 -0700
> Committer:  Linus Torvalds <torvalds@woody.linux-foundation.org>
> CommitDate: Wed May 9 12:30:54 2007 -0700
> 
>     aio is unlikely
>     
>     Stick an unlikely() around is_aio(): I assert that most IO is synchronous.
>     
>     Cc: Suparna Bhattacharya <suparna@in.ibm.com>
>     Cc: Ingo Molnar <mingo@elte.hu>
>     Cc: Benjamin LaHaise <bcrl@kvack.org>
>     Cc: Zach Brown <zach.brown@oracle.com>
>     Cc: Ulrich Drepper <drepper@redhat.com>
>     Cc: Christoph Hellwig <hch@lst.de>
>     Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
>     Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
> ---
>  include/linux/aio.h |    3 ++-
>  1 files changed, 2 insertions(+), 1 deletions(-)
> 
> diff --git a/include/linux/aio.h b/include/linux/aio.h
> index a30ef13..43dc2eb 100644
> --- a/include/linux/aio.h
> +++ b/include/linux/aio.h
> @@ -226,7 +226,8 @@ int FASTCALL(io_submit_one(struct kioctx *ctx, struct iocb __user *user_iocb,
>  		__put_ioctx(kioctx);					\
>  } while (0)
>  
> -#define in_aio() !is_sync_wait(current->io_wait)
> +#define in_aio() (unlikely(!is_sync_wait(current->io_wait)))

Please revert.  Workload-dependent "likelihood" should not cause 
programmers to add such markers.

This is a common misunderstanding about unlikely() and likely().  The 
branch prediction used for each assumes 99% unlikely or 99% likely, 
which is not true at all for workload-dependent code.

Even if only 1% of Linux users use AIO, for that 1%, the 'unlikely' 
marker causes repeated branch mispredictions.

likely() and unlikely() should be used for cases where code is 
likely/unlikely for EVERYBODY.

	Jeff



       reply	other threads:[~2007-05-09 22:07 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <200705092101.l49L1CF1023363@hera.kernel.org>
2007-05-09 22:06 ` Jeff Garzik [this message]
2007-05-09 22:18   ` aio is unlikely Andrew Morton
2007-05-09 22:37     ` Jeff Garzik
2007-05-18 20:49     ` Alex Volkov
2007-05-18 21:06       ` Andrew Morton
2007-05-18 21:11         ` Jeff Garzik
2007-05-18 21:54         ` Phillip Susi
2007-05-18 22:12           ` Andrew Morton
2007-05-18 22:37             ` Jeff Garzik
2007-05-19  3:43               ` Nick Piggin
2007-05-19  3:50                 ` Jeff Garzik
2007-05-18 21:30       ` Bernd Eckenfels

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=46424602.3090404@garzik.org \
    --to=jeff@garzik.org \
    --cc=akpm@linux-foundation.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mingo@elte.hu \
    --cc=suparna@in.ibm.com \
    --cc=torvalds@linux-foundation.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