[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
- [Qemu-devel] [PATCH v2 4/4] dma-helpers: Move reschedule_dma BH to blk's AioContext, (continued)
[Qemu-devel] [PATCH v2 1/4] exec: Atomic access to bounce buffer, Fam Zheng, 2015/03/12
[Qemu-devel] [PATCH v2 2/4] exec: Atomic access to map_client_list, Fam Zheng, 2015/03/12
[Qemu-devel] [PATCH v2 3/4] exec: Notify cpu_register_map_client caller if the bounce buffer is available, Fam Zheng, 2015/03/12