Re: [PATCH] "volatile considered harmful", take 3



Satyam Sharma wrote:

Because volatile is ill-defined? Or actually, *undefined* (well,
implementation-defined is as good as that)? It's *so* _vague_,
one doesn't _feel_ like using it at all!


Sorry, that's just utter crap. Linux isn't written in some mythical C
which only exists in standard document, it is written in a particular
subset of GNU C. "volatile" is well enough defined in that context, it
is just frequently misused.

We already have a complete API containing optimization barriers,
load/store/full memory barriers. With well-defined and
well-understood semantics. Just ... _why_ use volatile?

See below.

It will _always_ work. In fact you can't really say the same for
volatile. We already assume the compiler _actually_ took some
pains to stuff meaning into C's (lack of) definition of volatile and
implement it -- but in what sense, nobody knows (the C standard
doesn't, so what are we).

It will always work within the context of GNU C.

more heavy-handed as it's disabling *all* optimization such as loop
invariants across the barrier.

This is a legitimate criticism, I agree.

There you have it.

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



Relevant Pages

  • Re: [PATCH] "volatile considered harmful", take 3
    ... _is_ defined, after all) in the context of GNU C, and if you're saying ... that the kernel is and should _continue_ to ... that's your opinion and I would not disagree with you. ... volatile wherever possible (which includes the case originally ...
    (Linux-Kernel)
  • Re: mutex question
    ... utility of the volatile keyword. ... You disputed somebody else's statements "about the utility of the volatile ... standard cannot be demonstrated if the standard is not cited. ... I do not need any context to talk about the sufficiency of a volatile ...
    (microsoft.public.win32.programmer.kernel)
  • Re: hashtable - thread safety clarification
    ... "You can only declare a variable referencing the Hashtable as volatile. ... But, the point of my post was to address the specific question, not to give a complete enumeration of everything that "volatile" does. ... In context, my statement was precise, to the point, and correct. ...
    (microsoft.public.dotnet.languages.csharp)
  • Re: mutex question
    ... utility of the volatile keyword. ... standard cannot be demonstrated if the standard is not cited. ... I do not need any context to talk about the sufficiency of a volatile ...
    (microsoft.public.win32.programmer.kernel)
  • Re: hashtable - thread safety clarification
    ... "You can only declare a variable referencing the Hashtable as volatile. ... But, the point of my post was to address the specific question, not to give a complete enumeration of everything that "volatile" does. ... In context, my statement was precise, to the point, and correct. ...
    (microsoft.public.dotnet.languages.csharp)