[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Qemu-devel] [PATCH] qom: Use atomics for object refcounting

From: Paolo Bonzini
Subject: Re: [Qemu-devel] [PATCH] qom: Use atomics for object refcounting
Date: Tue, 02 Jul 2013 13:49:27 +0200
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:17.0) Gecko/20130514 Thunderbird/17.0.6

Il 02/07/2013 13:44, Jan Kiszka ha scritto:
> On 2013-07-02 13:28, Paolo Bonzini wrote:
>> Il 02/07/2013 13:15, Andreas Färber ha scritto:
>>>>> @@ -683,16 +683,15 @@ GSList *object_class_get_list(const char 
>>>>> *implements_type,
>>>>>  void object_ref(Object *obj)
>>>>>  {
>>>>> -    obj->ref++;
>>>>> +     __sync_fetch_and_add(&obj->ref, 1);
>>> How widespread are these in GCC/clang? Is there any fallback? I remember
>>> seeing some __sync_* warnings on Mac OS X around 4.2...
>> We are using them already in several places (vhost was the first one to
>> introduce them, I think, but now they are also in migration ad in some
>> tests too).  There is no fallback (asm could be a fallback, but we chose
>> to require GCC 4.2 or newer).
>> I'll change this to atomic_inc/dec when applying.  Otherwise
> But then atomic_dec_and_test or so. Letting the inc/dec return some
> value leaves room for interpretations (value of before or after the
> modification?).

In qemu, I made all atomic_* functions return the old value.  This is
consistent with atomic_cmpxchg and atomic_xchg (where returning the new
value makes no sense).


reply via email to

[Prev in Thread] Current Thread [Next in Thread]