lkml.org 
[lkml]   [2006]   [Jul]   [7]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
    /
    Date
    From
    SubjectRe: [patch] spinlocks: remove 'volatile'


    On Fri, 7 Jul 2006, Linus Torvalds wrote:
    >
    > It still makes a difference for code generation, OF COURSE. But it's the
    > wrong thing to use.

    And if you don't realize that my argument wasn't "bait-and-switch", it's
    exactly the same thing. You pointed out a place where "volatile" would
    make the code "work".

    AND I POINTED OUT THAT EVEN IN YOUR TRIVIAL EXAMPLE, VOLATILE WAS
    ACTUALLY THE WRONG THING TO DO.

    And that's _exactly_ because the language environment (in this case the
    CPU itself) has evolved past the point it was 30 years ago.

    And my point is that this is _always_ true. There are basically no valid
    uses where you can use "volatile" today, where there isn't some reason why
    you _should_ have done it another way entirely. Either you should have
    used proper locking, or you should have used the proper IO accessor
    functions, or you should have used something like "cpu_relax()", OR ANY
    NUMBER OF OTHER MECHANISMS.

    (I did give a few examples of where "volatile" can be valid, but they are
    very limited)

    Yes, "volatile" is convenient - at the cost of making the compiler
    generate crap code even when it shouldn't need to. Yes, "volatile"
    sometimes allows you to be lazy and not do the proper thing. Yes,
    "volatile" can hide bugs when you _tried_ to do the proper thing but
    screwed up.

    But can't you see that _none_ of those 'Yes, "volatile" ...' actually
    means that you should _use_ "volatile".

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

    \
     
     \ /
      Last update: 2009-11-18 23:46    [W:0.023 / U:30.444 seconds]
    ©2003-2016 Jasper Spaans. hosted at Digital OceanAdvertise on this site