Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1757469AbXHISR0 (ORCPT ); Thu, 9 Aug 2007 14:17:26 -0400 Received: (majordomo@vger.kernel.org) by vger.kernel.org id S1753333AbXHISRM (ORCPT ); Thu, 9 Aug 2007 14:17:12 -0400 Received: from mtagate8.de.ibm.com ([195.212.29.157]:11609 "EHLO mtagate8.de.ibm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752677AbXHISRK (ORCPT ); Thu, 9 Aug 2007 14:17:10 -0400 Subject: Re: [PATCH] make atomic_t volatile on all architectures From: Martin Schwidefsky Reply-To: schwidefsky@de.ibm.com To: Linus Torvalds Cc: Chuck Ebbert , Chris Snook , akpm@linux-foundation.org, ak@suse.de, heiko.carstens@de.ibm.com, davem@davemloft.net, linux-kernel@vger.kernel.org, netdev@vger.kernel.org, wensong@linux-vs.org, horms@verge.net.au, wjiang@resilience.com, cfriesen@nortel.com, zlynx@acm.org In-Reply-To: References: <20070808230733.GA17270@shell.boston.redhat.com> <46BAC2BE.1090106@redhat.com> <46BB508B.7050601@redhat.com> Content-Type: text/plain Organization: IBM Corporation Date: Thu, 09 Aug 2007 20:20:46 +0200 Message-Id: <1186683646.9669.20.camel@localhost> Mime-Version: 1.0 X-Mailer: Evolution 2.10.3 Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 1247 Lines: 32 On Thu, 2007-08-09 at 10:55 -0700, Linus Torvalds wrote: > > You can use this forget() macro to make the compiler reread a variable: > > > > #define forget(var) asm volatile ("" : "=m"(var)) > > No. That will also make the compiler "forget" any previous writes to it, > so it changes behaviour. > > You'd have to use "+m". Yes, though I would use "=m" on the output list and "m" on the input list. The reason is that I've seen gcc fall on its face with an ICE on s390 due to "+m". The explanation I've got from our compiler people was quite esoteric, as far as I remember gcc splits "+m" to an input operand and an output operand. Now it can happen that the compiler chooses two different registers to access the same memory location. "+m" requires that the two memory references are identical which causes the ICE if they are not. I do not know if the current compilers still do this. Has anyone else seen this happen ? -- blue skies, Martin. "Reality continues to ruin my life." - Calvin. - 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/