Re: [PATCH] dm.c - device-mapper I/O path fixes

Kevin Corry
2002-12-12T13:10:41Z

On Wednesday 11 December 2002 15:12, Paul Mackerras wrote:
> Kevin Corry writes:
> > Storing an int is *not* atomic unless it is declared as atomic_t and you
> > use the appropriate macros (see include/asm-*/atomic.h). Remember, we are
> > talking about a field in a data structure that can be accessed from
> > multiple threads on multiple CPUs.
>
> As a practical matter, I believe that storing an int to an int-aligned
> address _is_ actually atomic on any CPU that can run Linux. The
> PowerPC architecture spec requires that single-word (i.e. 32-bit)
> aligned stores are atomic, for instance, and I think that would be the
> case on any other sane architecture as well.

Given the constraints of having properly aligned data on an SMP machine with
the correct cache-coherency hardware, then yes, I will agree that such stores
should be atomic. However, it has been my understanding that these conditions
cannot be guaranteed on every architecture. Thus we're stuck with atomic_t's
so everyone can play nicely together.

--
Kevin Corry
corryk@us.ibm.com