RE: [PATCH] x86: fix and improve cmpxchg_double{,_local}()

From: Jan Beulich
Date: Wed Jan 04 2012 - 05:53:32 EST


>>> On 04.01.12 at 11:36, "David Laight" <David.Laight@xxxxxxxxxx> wrote:

>> BTW atomic64_set() asm() contraints are wrong :
>>
>> static inline void atomic64_set(atomic64_t *v, long long i)
>> {
>> unsigned high = (unsigned)(i >> 32);
>> unsigned low = (unsigned)i;
>> asm volatile(ATOMIC64_ALTERNATIVE(set)
>> : "+b" (low), "+c" (high)
>> : "S" (v)
>> : "eax", "edx", "memory"
>> );
>> }
>>
>>
>> ebx/ecx registers are not modified by cmpxchg8b (or the
>> atomic64_set_386 emulation). Only eax/edx can be modified.

Same would be true for atomic64_xchg() and the use of "+c" (v)
in subsequent functions (whether unnecessarily strict or too lax
varies).

> Isn't it also possible to constrain the "memory"
> constraint to only apply to '*v' not all of memory?
> I can't remember the syntax off hand though...

Absolutely - "=m" (v->counter) would be the right way to specify
this.

Jan

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