Re: [BUG FIX] Make x86_32 uni-processor Atomic ops, Atomic

From: Michael S. Zick
Date: Fri May 22 2009 - 16:03:21 EST


On Fri May 22 2009, Roland Dreier wrote:
>
> > Unless you have interrupts enabled, then you have two contexts.
> > Only xchg is "naturally" atomic.
>
> Isn't the lock prefix about consistency between multiple processors?
> The x86 architecture always handles interrupts on instruction
> boundaries. I'm guessing you're worried about definitions like
>
> static inline void atomic_inc(atomic_t *v)
> {
> asm volatile(LOCK_PREFIX "incl %0"
> : "+m" (v->counter));
> }
>
> which compiles to just "incl" (with no lock prefix) on uniprocessor
> kernels; but the IA-32 architecture guarantees that the incl instruction
> cannot be interrupted between reading the old value and writing the new
> value.
>

Not prior to P-4, and since then only "may" be done atomically,
see reference post in my earlier reply.

PS: And yes, that was where I spotted the usage first. ;)

Mike
> - R.
>
>


--
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/