Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753545AbXJZBPT (ORCPT ); Thu, 25 Oct 2007 21:15:19 -0400 Received: (majordomo@vger.kernel.org) by vger.kernel.org id S1752723AbXJZBOv (ORCPT ); Thu, 25 Oct 2007 21:14:51 -0400 Received: from smtp-outbound-1.vmware.com ([65.113.40.141]:50571 "EHLO smtp-outbound-1.vmware.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1761360AbXJZBOu (ORCPT ); Thu, 25 Oct 2007 21:14:50 -0400 Subject: Re: Is gcc thread-unsafe? From: Zachary Amsden To: Linus Torvalds Cc: Andi Kleen , Nick Piggin , Linux Kernel Mailing List In-Reply-To: References: <200710251324.49888.nickpiggin@yahoo.com.au> <200710260116.10904.ak@suse.de> <200710260142.37902.ak@suse.de> Content-Type: text/plain Date: Thu, 25 Oct 2007 18:15:38 -0700 Message-Id: <1193361338.9793.37.camel@bodhitayantram.eng.vmware.com> Mime-Version: 1.0 X-Mailer: Evolution 2.10.2 Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 1153 Lines: 29 On Thu, 2007-10-25 at 16:57 -0700, Linus Torvalds wrote: > > On Fri, 26 Oct 2007, Andi Kleen wrote: > > > > The conditional add/sub using carry trick is not generally bogus. > > But for registers it's a fine optimization. > > For registers it's fine. For memory, it's a disaster. It's more than just > dirty cachelines and introducing race conditions, it's also about > protection and dirty pages. > > So even in user space, to even be correct in the first place, the compiler It's actually a fair bit worse for us. We have paths where a false optimization like this would hyperspace the machine. In fact, this frightens me so much I've just gone off to investigate whether gcc has gone and done this to any of our code. Clearly the right solution is to introduce threads and write protected memory into gcc so that the developers are either motivated to ensure they work or self-destruct. Zach - 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/