Re: [patch] spinlocks: remove 'volatile'

Chase Venters
2006-07-08T20:47:33Z

On Saturday 08 July 2006 15:40, Chase Venters wrote:
> You need the barrier for both the CPU and the compiler. The CPU barrier
> comes from an instruction like '*fence' on x86 (or a locked bus op), while
> the compiler barrier comes from the memory clobber. Because the spinlocks
> already _must_ have both of these (including the other constraints in the
> inline asm), 'volatile' on the spinlock ctr is useless.

Btw, perhaps what is going on here is a misunderstanding of
terminology? "Barrier" or "Memory barrier" can refer to both a hardware or
compiler barrier, which is why Documentation/memory-barriers.txt speaks of
both in the same file. Indeed, you often have both in the same spot, and the
names are even similar:

barrier() -> compiler memory barrier
wmb() -> write memory barrier
...

Sometimes you'll see "optimization barrier", but you should remember that
barrier() boils down to:

asm volatile ("" ::: "memory")

...because it's preventing memory caching/reordering across the unpredictable
memory clobber.

See?

>
> Thanks,
> Chase