[lkml]   [2006]   [Jul]   [8]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
Messages in this thread
    SubjectRe: [patch] spinlocks: remove 'volatile'

    On Fri, 7 Jul 2006, trajce nedev wrote:
    > Incorrect. I haven't been following this thread very closely [...]

    Right. And maybe you should have followed it a bit more closely.

    We're not talking about "asm volatile", which is a totally different use
    of the same word.

    We're not talking about pointers to volatile as arguments, which can be
    required for a generic function to not complain about it's argument types.

    We're not even talking about code like

    #define writel(data, offset) \
    *(volatile int *)(offset) = (data)

    which is perfectly fine on some architectures (but realize that on other
    archtiectures, you may need a _lot_ more than a single memory access to do
    an IO write, so if you don't abstract it like the above, you're broken by

    In short, we're not talking about "volatile" in _code_. That's usually
    fine. We're talkign about "volatile" on data. IT'S WRONG.

    Btw, your spinlock (that uses "volatile") is _totally_ and _utterly_
    broken, exactly because it doesn't take things like memory ordering into
    account. In other words, your spinlock WON'T WORK. It won't actually
    protect the data accesses you have inside the spinlock.

    Which proves my point: people who think that "volatile" is good are
    usually ignorant about the real needs of the code. To do a spinlock on
    _any_ modern CPU, you need inline assembly. End of story. You need it to
    make sure that you have told the CPU the right ordering constraints,
    something that "volatile" simply does not (and _can_not) do.

    To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
    the body of a message to
    More majordomo info at
    Please read the FAQ at

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