qemu-devel
[Top][All Lists]
Advanced

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

Re: [Qemu-devel] [PATCH v2 1/4] exec: Atomic access to bounce buffer


From: Paolo Bonzini
Subject: Re: [Qemu-devel] [PATCH v2 1/4] exec: Atomic access to bounce buffer
Date: Fri, 13 Mar 2015 09:41:42 +0100
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:31.0) Gecko/20100101 Thunderbird/31.5.0


On 13/03/2015 09:32, Paolo Bonzini wrote:
> 
> 
> On 13/03/2015 09:16, Fam Zheng wrote:
>>>>>> +        if (atomic_cmpxchg(&bounce.in_use, false, true)) {
>>>>
>>>> atomic_or is enough...
>> atomic_cmpxchg is here to take the ownership of bounce iff it is not in use, 
>> so
>> I think it is necessary.
> 
> It's changing false to true and true to true, so you can do
> 
>     if (atomic_or(&bounce.in_use, 1)) {
>         // was true already
>     }

... and actually, atomic_xchg is even better (on x86, atomic_or is
compiled into a cmpxchg loop, but atomic_xchg is a single instruction).

Paolo



reply via email to

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