OK, sure, that's fine. Better than barrier() in some respects, too.
Namely, 1) volatile is portable C; barrier() isn't (not that that's
much of an issue for compiling Linux), and 2) volatile can be
specific to a variable, unlike the indiscriminate barrier(), which
forces a reload of everything that might be cached (OK, not a big
deal for IA32, but nontrivial for many-register architectures). One
could imagine a more specific barrier(jiffies) syntax, I suppose, but
the volatile cast is nice, restricting the effect not only to the
single variable but to the single reference to a single variable.
>For example, if you fix the code by adding an explicit barrier(), people
>see that (a) you're aware of the fact that you expect the values to change
>and (b) they see that it is taken care of.
>
>In contrast, if your data structure is marked volatile, how is anybody
>reading the code every going to be sure that the code is correct? You have
>to look at the header file defining all the data structures. That kind of
>thing is NOT GOOD.
-- /Jonathan Lundell. - 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/