lkml.org 
[lkml]   [2012]   [Jul]   [25]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
    /
    Date
    From
    SubjectRe: [RFC] page-table walkers vs memory order
    On Wed, 25 Jul 2012, Paul E. McKenney wrote:
    > On Tue, Jul 24, 2012 at 02:51:05PM -0700, Hugh Dickins wrote:
    > >
    > > I'm totally unclear whether the kernel ever gets built with these
    > > 'creative' compilers that you refer to. Is ACCESS_ONCE() a warning
    > > of where some future compiler would be permitted to mess with our
    > > assumptions? Or is it actually saving us already today? Would we
    > > know? Could there be a boottime test that would tell us? Is it
    > > likely that a future compiler would have an "--access_once"
    > > option that the kernel build would want to turn on?
    >
    > The problem is that, unless you tell it otherwise, the compiler is
    > permitted to assume that the code that it is generating is the only thing
    > active in that address space at that time. So the compiler might know
    > that it already has a perfectly good copy of that value somewhere in
    > its registers, or it might decide to fetch the value twice rather than
    > once due to register pressure, either of which can be fatal in SMP code.
    > And then there are more aggressive optimizations as well.
    >
    > ACCESS_ONCE() is a way of telling the compiler to access the value
    > once, regardless of what cute single-threaded optimizations that it
    > otherwise might want to apply.

    Right, but you say "might": I have never heard it asserted, that we do
    build the kernel with a compiler which actually makes such optimizations.

    There's a lot of other surprising things which a compiler is permitted
    to do, but we would simply not use such a compiler to build the kernel.

    Does some version of gcc, under the options which we insist upon,
    make such optimizations on any of the architectures which we support?

    Or is there some other compiler in use on the kernel, which makes
    such optimizations? It seems a long time since I heard of building
    the kernel with icc. clang?

    I don't mind the answer "Yes, you idiot" - preferably with an example
    or two of which compiler and which piece of code it has bitten us on.
    I don't mind the answer "We just don't know" if that's the case.

    But I'd like a better idea of how much to worry: is ACCESS_ONCE
    demonstrably needed today, or rather future-proofing and documentation?

    Thanks,
    Hugh


    \
     
     \ /
      Last update: 2012-07-25 23:21    [W:4.153 / U:0.140 seconds]
    ©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site