[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Qemu-devel] [PATCH v3 05/11] qemu-thread: add simple test-and-set s
Re: [Qemu-devel] [PATCH v3 05/11] qemu-thread: add simple test-and-set spinlock
Wed, 20 Apr 2016 12:39:45 -0700
Mozilla/5.0 (X11; Linux x86_64; rv:38.0) Gecko/20100101 Thunderbird/38.7.1
On 04/20/2016 11:11 AM, Emilio G. Cota wrote:
On Wed, Apr 20, 2016 at 10:55:45 -0700, Richard Henderson wrote:
On 04/20/2016 10:17 AM, Emilio G. Cota wrote:
I've tried to find a GCC intrinsic for test-and-set, and I've only found
lock_test_and_set, which is what we use for atomic_xchg (except on ppc)
because it really is an atomic exchange:
"This builtin, as described by Intel, is not a traditional test-and-set
operation, but rather an atomic exchange operation."
Please read the entire documentation, not just the first sentence.
I did read it and I'm aware of the limitations of using xchg.
My comment was related to this:
[...] do note that there are compiler primitives for test-and-set that
(can be) simpler for a cpu to implement than xchg.
What compiler (I assume gcc) primitives are these? I couldn't find them.
__sync_lock_test_and_set and __atomic_test_and_set.
Both expand to ldstub on sparcv7, tas on coldfire, tas.b on sh.
None of these are xchg operations.
I had forgotten that there wasn't a __sync_exchange builtin, so
__sync_lock_test_and_set plays double-duty as both xchg and test-and-set.
But when __atomic builtins are available, __atomic_exchange does not fall back;
you must use __atomic_test_and_set for less capable hosts.
But of course none of this is really relevant for normal hosts.
[Qemu-devel] [UPDATED v3 05/11] qemu-thread: add simple test-and-set spinlock, Emilio G. Cota, 2016/04/20
[Qemu-devel] [PATCH v3 04/11] include/processor.h: define cpu_relax(), Emilio G. Cota, 2016/04/19
[Qemu-devel] [UPDATED v3 04/11] include/processor.h: define cpu_relax(), Emilio G. Cota, 2016/04/20
Re: [Qemu-devel] [PATCH v3 04/11] include/processor.h: define cpu_relax(), Alex Bennée, 2016/04/22
[Qemu-devel] [PATCH v3 03/11] seqlock: rename write_lock/unlock to write_begin/end, Emilio G. Cota, 2016/04/19
[Qemu-devel] [PATCH v3 10/11] tb hash: track translated blocks with qht, Emilio G. Cota, 2016/04/19