Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1759445AbWLGPmF (ORCPT ); Thu, 7 Dec 2006 10:42:05 -0500 Received: (majordomo@vger.kernel.org) by vger.kernel.org id S1759440AbWLGPmF (ORCPT ); Thu, 7 Dec 2006 10:42:05 -0500 Received: from smtp.osdl.org ([65.172.181.25]:36327 "EHLO smtp.osdl.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1759384AbWLGPmC (ORCPT ); Thu, 7 Dec 2006 10:42:02 -0500 Date: Thu, 7 Dec 2006 07:36:16 -0800 (PST) From: Linus Torvalds To: Nick Piggin cc: Russell King , Christoph Lameter , David Howells , akpm@osdl.org, linux-arm-kernel@lists.arm.linux.org.uk, linux-kernel@vger.kernel.org, linux-arch@vger.kernel.org Subject: Re: [PATCH] WorkStruct: Implement generic UP cmpxchg() where an arch doesn't support it In-Reply-To: <4577DF5C.5070701@yahoo.com.au> Message-ID: References: <20061206164314.19870.33519.stgit@warthog.cambridge.redhat.com> <20061206190025.GC9959@flint.arm.linux.org.uk> <20061206195820.GA15281@flint.arm.linux.org.uk> <4577DF5C.5070701@yahoo.com.au> MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII Sender: linux-kernel-owner@vger.kernel.org X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 1259 Lines: 30 On Thu, 7 Dec 2006, Nick Piggin wrote: > > It might be reasonable to implement this watered down version, but: > don't some architectures have restrictions on what instructions can > be issued between the ll and the sc? Yes. You really probably do not want to expose ll/sc on a C level because of this. On alpha, the architecture manual says (I didn't go back and check, but I'm pretty sure) that a ld.l and st.c cannot have a taken branch in between then, for example. That basically means that you can't allow the compiler to reorder the basic blocks (which it often will with a while-loop). Now, I actually suspect that this was not a microarchitectural flaw, and that a branch would _work_ there, and that the architecture manual was just being anal, but strictly speaking, it means that these things had better always be in assembly, and you can sadly not expose them (on alpha, at least) as higher-level primitives as such - you can only expose the end result ("cmpxchg" or similar). Linus - To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/