[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: |
liu ping fan |
Subject: |
Re: [Qemu-devel] [PATCH v6 1/8] atomic: introduce atomic operations |
Date: |
Wed, 21 Nov 2012 13:58:09 +0800 |
On Fri, Nov 16, 2012 at 8:03 AM, Richard Henderson <address@hidden> wrote:
> 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.
>
Very appreciate for you so detailed description.
Regards,
Pingfan
>
> 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, 2012/11/15
- Re: [Qemu-devel] [PATCH v6 1/8] atomic: introduce atomic operations,
liu ping fan <=
- 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
[Qemu-devel] [PATCH v6 6/8] memory: make mmio dispatch able to be out of biglock, Liu Ping Fan, 2012/11/05