[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Qemu-devel] [PATCH v5 07/18] qemu-thread: add simple test-and-set s
From: |
Paolo Bonzini |
Subject: |
Re: [Qemu-devel] [PATCH v5 07/18] qemu-thread: add simple test-and-set spinlock |
Date: |
Wed, 18 May 2016 16:05:34 +0200 |
User-agent: |
Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101 Thunderbird/45.0 |
On 18/05/2016 15:59, Sergey Fedorov wrote:
>
> But actually (cf include/qemu/atomic.h) we can have:
>
> #define atomic_read(ptr) \
> ({ \
> QEMU_BUILD_BUG_ON(sizeof(*ptr) > sizeof(void *)); \
> typeof(*ptr) _val; \
> __atomic_load(ptr, &_val, __ATOMIC_RELAXED); \
> _val; \
> })
>
>
> I can't find anywhere if this __atomic_load() has volatile/compiler
> barrier semantics...
The standard says "you can have data races on atomic loads", that is
very close to compiler barrier semantics but indeed atomics.txt should
be updated to explain the C11 memory model in not-so-formal terms.
For example this:
atomic_set(&x, 1);
atomic_set(&y, 1);
atomic_set(&x, 2);
atomic_set(&y, 2);
could become
atomic_set(&x, 2);
atomic_set(&y, 2);
with C11 atomics but not with volatile. However this:
if (atomic_read(&x) != 1) {
atomic_set(&x, 1);
}
couldn't become an unconditional
atomic_set(&x, 1);
Thanks,
Paolo
- Re: [Qemu-devel] [PATCH v5 05/18] atomics: add atomic_test_and_set_acquire, (continued)
[Qemu-devel] [PATCH v5 07/18] qemu-thread: add simple test-and-set spinlock, Emilio G. Cota, 2016/05/13
- Message not available
- Re: [Qemu-devel] [PATCH v5 07/18] qemu-thread: add simple test-and-set spinlock, Emilio G. Cota, 2016/05/17
- Re: [Qemu-devel] [PATCH v5 07/18] qemu-thread: add simple test-and-set spinlock, Sergey Fedorov, 2016/05/17
- Re: [Qemu-devel] [PATCH v5 07/18] qemu-thread: add simple test-and-set spinlock, Emilio G. Cota, 2016/05/17
- Re: [Qemu-devel] [PATCH v5 07/18] qemu-thread: add simple test-and-set spinlock, Sergey Fedorov, 2016/05/18
- Re: [Qemu-devel] [PATCH v5 07/18] qemu-thread: add simple test-and-set spinlock,
Paolo Bonzini <=
- Re: [Qemu-devel] [PATCH v5 07/18] qemu-thread: add simple test-and-set spinlock, Sergey Fedorov, 2016/05/18
- Re: [Qemu-devel] [PATCH v5 07/18] qemu-thread: add simple test-and-set spinlock, Paolo Bonzini, 2016/05/18
Message not available
- Re: [Qemu-devel] [PATCH v5 07/18] qemu-thread: add simple test-and-set spinlock, Richard Henderson, 2016/05/17
- Re: [Qemu-devel] [PATCH v5 07/18] qemu-thread: add simple test-and-set spinlock, Emilio G. Cota, 2016/05/17
- Re: [Qemu-devel] [PATCH v5 07/18] qemu-thread: add simple test-and-set spinlock, Sergey Fedorov, 2016/05/17
- Re: [Qemu-devel] [PATCH v5 07/18] qemu-thread: add simple test-and-set spinlock, Emilio G. Cota, 2016/05/17
- Re: [Qemu-devel] [PATCH v5 07/18] qemu-thread: add simple test-and-set spinlock, Sergey Fedorov, 2016/05/18
- Re: [Qemu-devel] [PATCH v5 07/18] qemu-thread: add simple test-and-set spinlock, Sergey Fedorov, 2016/05/18
- Re: [Qemu-devel] [PATCH v5 07/18] qemu-thread: add simple test-and-set spinlock, Paolo Bonzini, 2016/05/18
- Re: [Qemu-devel] [PATCH v5 07/18] qemu-thread: add simple test-and-set spinlock, Sergey Fedorov, 2016/05/18