From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1Nv9jX-0006N7-PI for qemu-devel@nongnu.org; Fri, 26 Mar 2010 09:37:55 -0400 Received: from [140.186.70.92] (port=45400 helo=eggs.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1Nv9jV-0006Mt-LU for qemu-devel@nongnu.org; Fri, 26 Mar 2010 09:37:54 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.69) (envelope-from ) id 1Nv9jU-00030l-Iy for qemu-devel@nongnu.org; Fri, 26 Mar 2010 09:37:53 -0400 Received: from mail-pw0-f45.google.com ([209.85.160.45]:55553) by eggs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1Nv9jU-000302-EH for qemu-devel@nongnu.org; Fri, 26 Mar 2010 09:37:52 -0400 Received: by pwi9 with SMTP id 9so5912824pwi.4 for ; Fri, 26 Mar 2010 06:37:46 -0700 (PDT) Sender: Richard Henderson Message-ID: <4BACB89B.4070809@twiddle.net> Date: Fri, 26 Mar 2010 06:37:31 -0700 From: Richard Henderson MIME-Version: 1.0 Subject: Re: [Qemu-devel] [PATCH 00/10, v3] target-alpha improvements References: <20100326015252.GG19308@shareable.org> In-Reply-To: <20100326015252.GG19308@shareable.org> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit List-Id: qemu-devel.nongnu.org List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Jamie Lokier Cc: qemu-devel@nongnu.org, aurelien@aurel32.net On 03/25/2010 06:52 PM, Jamie Lokier wrote: > I guess you are thinking to save the value loaded by load-locked, > and use it as the "old" for host cmpxchg at target's > store-conditional? Yes. > It'll be fine when ll/sc are only used to provide single-word atomic > calculations, but I'm not sure those are the only uses to which they > are put by any code anywhere. E.g. if I remember rightly, there was > some discussion of a planned unusual ll/sc use on the linux-arm > list, which involved a second word, but the idea wasn't ever > implemented. "It is UNPREDICTABLE whether a processor's lock_flag is cleared by that processor executing a normal load or store instruction." So at least on Alpha your double-word update isn't supposed to work. Now, what the cmpxchg *doesn't* handle is when the store isn't to exactly the same address as the load. The Alpha spec does allow the store to be anywhere within the same 16-byte aligned block, and we can't handle that. That said, I'm pretty sure such a non-matching store is never used on Linux. > So stop-the-world ought to remain in, but only as a last resort to > be used when the ll/sc sequence doesn't pass the no-funny-business > test. The existing stop-the-world implementation is *exactly* cmpxchg. It doesn't do what you want: stop the world at the ll, resume the world at the sc (or other suitable subsequent condition e.g. taken branch or N executed instructions). r~