Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1762392AbXJZSQc (ORCPT ); Fri, 26 Oct 2007 14:16:32 -0400 Received: (majordomo@vger.kernel.org) by vger.kernel.org id S1753677AbXJZSQY (ORCPT ); Fri, 26 Oct 2007 14:16:24 -0400 Received: from smtp2.linux-foundation.org ([207.189.120.14]:44104 "EHLO smtp2.linux-foundation.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753252AbXJZSQX (ORCPT ); Fri, 26 Oct 2007 14:16:23 -0400 Date: Fri, 26 Oct 2007 11:14:17 -0700 (PDT) From: Linus Torvalds To: Alan Cox cc: Bart Van Assche , Linux Kernel Mailing List , Andrew Haley Subject: Re: Is gcc thread-unsafe? In-Reply-To: <20071026190856.18510fc4@the-village.bc.nu> Message-ID: References: <20071026190856.18510fc4@the-village.bc.nu> 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: 1237 Lines: 30 On Fri, 26 Oct 2007, Alan Cox wrote: > > > non-volatile variables. But for asm statements this can be solved by > > adding memory to the list of clobbered registers -- this will prevent > > any reordering of manipulations of non-volatile variables and asm > > statements. > > IFF the processor doesn't reorder them in hardware, which on some > processors is visibly out of order when viewed from an I/O device or > another CPU. > > You can stop the compiler but not the CPU - and some processors will > certainly speculatively load across conditionals, reorder writes etc Well, when we're talking inline asms used for locking, the whole point of using inline asm is exactly that you cannot do it with regular accesses, and have to add architecture-specific barriers. If the user gets that wrong, then it's a user problem, not a compiler issue. So that's not the problem. The problem is if the compiler then does other things wrong *despite* the inline asm being correct. 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/