[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Qemu-devel] [PATCH v6 1/8] atomic: introduce atomic operations
From: |
Richard Henderson |
Subject: |
Re: [Qemu-devel] [PATCH v6 1/8] atomic: introduce atomic operations |
Date: |
Thu, 15 Nov 2012 16:03:14 -0800 |
User-agent: |
Mozilla/5.0 (X11; Linux x86_64; rv:16.0) Gecko/20121029 Thunderbird/16.0.2 |
On 2012-11-14 23:47, liu ping fan wrote:
> Probably I made a mistake here, in vhost, log =
> __sync_fetch_and_and(from, 0) is used to fetch 64bits atomically in
> the case 32bits qemu running on 64bits linux. Right? But how can
> we read 32bits twice in atomic? Seem that no instruction like "_lock
> xchg" for this ops. So I guess _sync_fetch_and_and() based on
> something like spinlock.
... or for gcc 4.7 and later,
log = __atomic_load_n(from, memory_model)
For i386, we will not perform 2 32-bit reads of course. Paulo suggests
using cmpxchg8b, but that's a tad slow. Instead we'll perform a 64-bit
read into either the fpu or the sse units, and from there copy the data
wherever it's needed. Such 64-bit aligned reads are guaranteed to be
atomic for i586 (pentium) and later.
For other 32-bit architectures other possibilities exist. Recent arm can
use its ldrexd insn. Many of the 32-bit linux architectures have special
kernel entry points or schemes to perform atomic operations. These are
generally based on the assumption of a single-processor system, and are
arranged to either disable interrupts or notice that no interrupt occurred,
while executing a code region.
As an ultimate fallback, yes we would use locks. But none of the host
architectures that QEMU supports needs to do so.
r~
- [Qemu-devel] [PATCH v6 0/8] push mmio dispatch out of big lock, Liu Ping Fan, 2012/11/05
- [Qemu-devel] [PATCH v6 1/8] atomic: introduce atomic operations, Liu Ping Fan, 2012/11/05
- Re: [Qemu-devel] [PATCH v6 1/8] atomic: introduce atomic operations, Paolo Bonzini, 2012/11/12
- Re: [Qemu-devel] [PATCH v6 1/8] atomic: introduce atomic operations, liu ping fan, 2012/11/13
- Re: [Qemu-devel] [PATCH v6 1/8] atomic: introduce atomic operations, Paolo Bonzini, 2012/11/13
- Re: [Qemu-devel] [PATCH v6 1/8] atomic: introduce atomic operations, liu ping fan, 2012/11/14
- Re: [Qemu-devel] [PATCH v6 1/8] atomic: introduce atomic operations, Paolo Bonzini, 2012/11/14
- Re: [Qemu-devel] [PATCH v6 1/8] atomic: introduce atomic operations, liu ping fan, 2012/11/15
- Re: [Qemu-devel] [PATCH v6 1/8] atomic: introduce atomic operations, Paolo Bonzini, 2012/11/15
- Re: [Qemu-devel] [PATCH v6 1/8] atomic: introduce atomic operations,
Richard Henderson <=
- Re: [Qemu-devel] [PATCH v6 1/8] atomic: introduce atomic operations, liu ping fan, 2012/11/21
- Re: [Qemu-devel] [PATCH v6 1/8] atomic: introduce atomic operations, Avi Kivity, 2012/11/18
- Re: [Qemu-devel] [PATCH v6 1/8] atomic: introduce atomic operations, liu ping fan, 2012/11/21
- Re: [Qemu-devel] [PATCH v6 1/8] atomic: introduce atomic operations, Paolo Bonzini, 2012/11/13
[Qemu-devel] [PATCH v6 2/8] qom: apply atomic on object's refcount, Liu Ping Fan, 2012/11/05
[Qemu-devel] [PATCH v6 3/8] hotplug: introduce qdev_unplug_complete() to remove device from views, Liu Ping Fan, 2012/11/05
[Qemu-devel] [PATCH v6 4/8] pci: remove pci device from mem view when unplug, Liu Ping Fan, 2012/11/05
[Qemu-devel] [PATCH v6 5/8] memory: introduce local lock for address space, Liu Ping Fan, 2012/11/05