From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:41887) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1aswbA-0007GO-Dc for qemu-devel@nongnu.org; Wed, 20 Apr 2016 14:11:37 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1aswb7-0004zx-8O for qemu-devel@nongnu.org; Wed, 20 Apr 2016 14:11:36 -0400 Received: from out2-smtp.messagingengine.com ([66.111.4.26]:52922) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1aswb7-0004zs-3I for qemu-devel@nongnu.org; Wed, 20 Apr 2016 14:11:33 -0400 Received: from compute4.internal (compute4.nyi.internal [10.202.2.44]) by mailout.nyi.internal (Postfix) with ESMTP id 94ACD20E63 for ; Wed, 20 Apr 2016 14:11:32 -0400 (EDT) Date: Wed, 20 Apr 2016 14:11:32 -0400 From: "Emilio G. Cota" Message-ID: <20160420181132.GA24862@flamenco> References: <1461107270-19234-1-git-send-email-cota@braap.org> <1461107270-19234-6-git-send-email-cota@braap.org> <57179DE0.5080701@twiddle.net> <20160420171734.GA1124@flamenco> <5717C2A1.9010805@twiddle.net> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <5717C2A1.9010805@twiddle.net> Subject: Re: [Qemu-devel] [PATCH v3 05/11] qemu-thread: add simple test-and-set spinlock List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Richard Henderson Cc: QEMU Developers , MTTCG Devel , Alex =?iso-8859-1?Q?Benn=E9e?= , Paolo Bonzini , Peter Crosthwaite , Peter Maydell , Sergey Fedorov 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." > > https://gcc.gnu.org/onlinedocs/gcc-4.1.2/gcc/Atomic-Builtins.html > > 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. Thanks, Emilio