[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Qemu-devel] [PATCH] qom: Use atomics for object refcounting
From: |
Jan Kiszka |
Subject: |
Re: [Qemu-devel] [PATCH] qom: Use atomics for object refcounting |
Date: |
Tue, 02 Jul 2013 13:52:35 +0200 |
User-agent: |
Mozilla/5.0 (X11; U; Linux i686 (x86_64); de; rv:1.8.1.12) Gecko/20080226 SUSE/2.0.0.12-1.1 Thunderbird/2.0.0.12 Mnenhy/0.7.5.666 |
On 2013-07-02 13:49, Paolo Bonzini wrote:
> 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).
Please avoid this ambiguity by naming the functions properly. That xchg
returns old values is known, that dec and inc do, is surely not.
Jan
--
Siemens AG, Corporate Technology, CT RTC ITP SES-DE
Corporate Competence Center Embedded Linux
Re: [Qemu-devel] [PATCH] qom: Use atomics for object refcounting, Anthony Liguori, 2013/07/02
- Re: [Qemu-devel] [PATCH] qom: Use atomics for object refcounting, Paolo Bonzini, 2013/07/02
- Re: [Qemu-devel] [PATCH] qom: Use atomics for object refcounting, Anthony Liguori, 2013/07/02
- Re: [Qemu-devel] [PATCH] qom: Use atomics for object refcounting, liu ping fan, 2013/07/02
- Re: [Qemu-devel] [PATCH] qom: Use atomics for object refcounting, Andreas Färber, 2013/07/03
- Re: [Qemu-devel] [PATCH] qom: Use atomics for object refcounting, liu ping fan, 2013/07/04
- Re: [Qemu-devel] [PATCH] qom: Use atomics for object refcounting, Andreas Färber, 2013/07/04
- Re: [Qemu-devel] [PATCH] qom: Use atomics for object refcounting, liu ping fan, 2013/07/04
Re: [Qemu-devel] [PATCH] qom: Use atomics for object refcounting, Paolo Bonzini, 2013/07/04