- Subject: Re: [Qemu-devel] [PATCH 01/15] atomic: introduce atomic operations
- From: Stefan Hajnoczi <stefanha@xxxxxxxxx>
- Date: Wed, 8 Aug 2012 14:09:25 +0100
- Cc: Liu Ping Fan <qemulist@xxxxxxxxx>, qemu-devel@xxxxxxxxxx, kvm@xxxxxxxxxxxxxxx, Marcelo Tosatti <mtosatti@xxxxxxxxxx>, Blue Swirl <blauwirbel@xxxxxxxxx>, Avi Kivity <avi@xxxxxxxxxx>, Anthony Liguori <anthony@xxxxxxxxxxxxx>, Jan Kiszka <jan.kiszka@xxxxxxxxxxx>, Paolo Bonzini <pbonzini@xxxxxxxxxx>, Andreas Färber <afaerber@xxxxxxx>
- In-reply-to: <CAFEAcA_rnFmxzY5jGBQDg9nXBH3WmMMhd2h3=-wiY8vxQxAReg@mail.gmail.com>
- References: <1344407156-25562-1-git-send-email-qemulist@gmail.com> <1344407156-25562-2-git-send-email-qemulist@gmail.com> <CAFEAcA_rnFmxzY5jGBQDg9nXBH3WmMMhd2h3=-wiY8vxQxAReg@mail.gmail.com>
On Wed, Aug 8, 2012 at 10:21 AM, Peter Maydell <peter.maydell@xxxxxxxxxx> wrote:
> On 8 August 2012 07:25, Liu Ping Fan <qemulist@xxxxxxxxx> wrote:
>> +static inline void atomic_sub(int i, Atomic *v)
>> +{
>> + asm volatile("lock; subl %1,%0"
>> + : "+m" (v->counter)
>> + : "ir" (i));
>> +}
>
> NAK. We don't want random inline assembly implementations of locking
> primitives in QEMU, they are way too hard to keep working with all the
> possible host architectures we support. I spent some time a while back
> getting rid of the (variously busted) versions we had previously.
>
> If you absolutely must use atomic ops, use the gcc builtins. For
> preference, stick to higher level and less error-prone abstractions.
We're spoilt for choice here:
1. Atomic built-ins from gcc
2. glib atomics
No need to roll our own or copy the implementation from the kernel.
Stefan
--
To unsubscribe from this list: send the line "unsubscribe kvm" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
[KVM ARM]
[KVM ia64]
[KVM ppc]
[Spice Development]
[Libvirt]
[Libvirt Users]
[Linux USB Devel]
[Video for Linux]
[Linux Audio Users]
[Photo]
[Yosemite News]
[Yosemite Photos]
[Linux Kernel]
[Linux SCSI]
[XFree86]