lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Message-ID: <46424602.3090404@garzik.org>
Date:	Wed, 09 May 2007 18:06:58 -0400
From:	Jeff Garzik <jeff@...zik.org>
To:	Linux Kernel Mailing List <linux-kernel@...r.kernel.org>
CC:	Andrew Morton <akpm@...ux-foundation.org>,
	Linus Torvalds <torvalds@...ux-foundation.org>,
	suparna@...ibm.com, Ingo Molnar <mingo@...e.hu>
Subject: Re: aio is unlikely

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@...l.org>
> AuthorDate: Wed May 9 02:34:58 2007 -0700
> Committer:  Linus Torvalds <torvalds@...dy.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@...ibm.com>
>     Cc: Ingo Molnar <mingo@...e.hu>
>     Cc: Benjamin LaHaise <bcrl@...ck.org>
>     Cc: Zach Brown <zach.brown@...cle.com>
>     Cc: Ulrich Drepper <drepper@...hat.com>
>     Cc: Christoph Hellwig <hch@....de>
>     Signed-off-by: Andrew Morton <akpm@...ux-foundation.org>
>     Signed-off-by: Linus Torvalds <torvalds@...ux-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


-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ