Re: [PATCH] x86: fix inline assembly constraints

From: Jike Song
Date: Thu Oct 30 2008 - 02:40:49 EST


On Thu, Oct 30, 2008 at 11:54 AM, H. Peter Anvin <hpa@xxxxxxxxx> wrote:
> Jike Song wrote:
>>
>> Besides, by looking at the inline assembly in kernel, I found lots of
>> codes like this:
>>
>> static inline void atomic_add(int i, atomic_t *v)
>> {
>> asm volatile(LOCK_PREFIX "addl %1,%0"
>> : "=m" (v->counter)
>> : "ir" (i), "m" (v->counter));
>> }
>>
>>
>> Yes, it works. But a little ugly.. Should this be cleaned-up with the
>> following?
>>
>> : "+m" (v->counter)
>> : "ir" (i)
>>
>> If you agrees, I'll send out the patch; otherwise I won't wasting your time ;-)
>>
>
> Please don't change them just to change them, if there is no actual
> error. You never know when you're going to trigger a new bug in some
> weird version of gcc.
>
> -hpa

Yes, sometimes gcc did have bugs with its obscure inline asm
conventions. But I think the change of x86-64 atomic operations should
be OK. Anyway, the "+" constraint is more clear than a "=m" output and
a "m" input.

The 32-bit atomic ops were already changed to "+m".(commit
b862f3b099f3ea672c7438c0b282ce8201d39dfc)

--
Thanks,
Jike
--
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/