Re: [Qemu-devel] [PATCH v2 08/13] qemu-thread: optimize spin_lock for uncontended locks

2016-04-08 Thread Richard Henderson
On 04/07/2016 10:32 AM, Emilio G. Cota wrote: > static inline void qemu_spin_lock(QemuSpin *spin) > { > -do { > +while (atomic_xchg(>value, true)) { > while (atomic_read(>value)) { > cpu_relax(); > } > -} while (atomic_xchg(>value, true)); > +} > }

[Qemu-devel] [PATCH v2 08/13] qemu-thread: optimize spin_lock for uncontended locks

2016-04-07 Thread Emilio G. Cota
This way we can acquire the lock with xchg+test, instead of test+xchg+test. Most spinlocks should be uncontended so this should result in a ne performance gain. Before: 4ad957: eb 09 jmp4ad962 4ad959: 0f 1f 80 00 00 00 00nopl 0x0(%rax)