From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:53341) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1b2qTT-00087L-9I for qemu-devel@nongnu.org; Tue, 17 May 2016 21:40:40 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1b2l79-0005EG-1q for qemu-devel@nongnu.org; Tue, 17 May 2016 15:57:15 -0400 Received: from mail-lf0-x243.google.com ([2a00:1450:4010:c07::243]:34039) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1b2l78-0005DX-LL for qemu-devel@nongnu.org; Tue, 17 May 2016 15:57:10 -0400 Received: by mail-lf0-x243.google.com with SMTP id m101so1889018lfi.1 for ; Tue, 17 May 2016 12:57:10 -0700 (PDT) References: <1463196873-17737-1-git-send-email-cota@braap.org> <1463196873-17737-8-git-send-email-cota@braap.org> <573B5134.8060104@gmail.com> <66d14198-dab0-c72e-fe17-d022cff3feff@twiddle.net> From: Sergey Fedorov Message-ID: <573B7793.9020109@gmail.com> Date: Tue, 17 May 2016 22:57:07 +0300 MIME-Version: 1.0 In-Reply-To: <66d14198-dab0-c72e-fe17-d022cff3feff@twiddle.net> Content-Type: text/plain; charset=windows-1252 Content-Transfer-Encoding: 7bit Subject: Re: [Qemu-devel] [PATCH v5 07/18] qemu-thread: add simple test-and-set spinlock List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Richard Henderson , "Emilio G. Cota" , QEMU Developers , MTTCG Devel Cc: =?UTF-8?Q?Alex_Benn=c3=a9e?= , Paolo Bonzini , Peter Crosthwaite On 17/05/16 22:19, Richard Henderson wrote: > On 05/17/2016 10:13 AM, Sergey Fedorov wrote: >>>> +static inline void qemu_spin_lock(QemuSpin *spin) >>>> +{ >>>> + while (atomic_test_and_set_acquire(&spin->value)) { >> >From gcc-4.8 info page, node "__atomic Builtins", description of >> __atomic_test_and_set(): >> >> It should be only used for operands of type 'bool' or 'char'. >> > Hum. I thought I remembered all operand sizes there, but I've just re-checked > and you're right about bool (and really only bool). > > Perhaps we should just stick with __sync_test_and_set then. I'm thinking here > of e.g. armv6, a reasonable host, which can't operate on 1 byte atomic values. > Sorry, I can't see reading ARMv6 ARM that 1-byte access can't be atomic. What I've found: B2.4.1 Normal memory attribute (snip) Shared Normal memory (snip) ... Reads to Shared Normal Memory that are aligned in memory to the size of the access must be atomic. Kind regards, Sergey