From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751270AbWGGVtD (ORCPT ); Fri, 7 Jul 2006 17:49:03 -0400 Received: (majordomo@vger.kernel.org) by vger.kernel.org id S1751268AbWGGVtB (ORCPT ); Fri, 7 Jul 2006 17:49:01 -0400 Received: from relay00.pair.com ([209.68.5.9]:45580 "HELO relay00.pair.com") by vger.kernel.org with SMTP id S1751267AbWGGVtA (ORCPT ); Fri, 7 Jul 2006 17:49:00 -0400 X-pair-Authenticated: 71.197.50.189 Date: Fri, 7 Jul 2006 16:48:56 -0500 (CDT) From: Chase Venters X-X-Sender: root@turbotaz.ourhouse To: "linux-os \\\\(Dick Johnson\\\\)" cc: Linus Torvalds , Krzysztof Halasa , Ingo Molnar , Andrew Morton , Linux kernel , arjan@infradead.org Subject: Re: [patch] spinlocks: remove 'volatile' In-Reply-To: Message-ID: References: <20060705114630.GA3134@elte.hu><20060705101059.66a762bf.akpm@osdl.org><20060705193551.GA13070@elte.hu><20060705131824.52fa20ec.akpm@osdl.org><20060705204727.GA16615@elte.hu><20060705214502.GA27597@elte.hu><20060706081639.GA24179@elte.hu> MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII; format=flowed Sender: linux-kernel-owner@vger.kernel.org X-Mailing-List: linux-kernel@vger.kernel.org On Fri, 7 Jul 2006, linux-os \(Dick Johnson\) wrote: > Again, I didn't propose to do that. In fact, your spin-lock > code already inserts "rep nops" and I never implied that they > should be removed. I said only that "volatile" still needs to > be used, not some macro that tells the compiler that everything > in memory probably got trashed. Read what I said, not what you > think some idiot might have said. > Dude, are you even paying attention? "volatile" very much does not need to be used (and as Linus points out, it is _wrong_). Since we're using GCC's inline asm syntax _already_, it is perfectly sufficient to use the same syntax to tell GCC that memory should be considered invalid. Locks are supposed to be syncronization points, which is why they ALREADY HAVE "memory" on the clobber list! "memory" IS NECESSARY. The fact that "=m" is changing to "+m" in Linus's patches is because "=m" is in fact insufficient, because it would let the compiler believe we're just going to over-write the value. "volatile" merely hides that bug -- once that bug is _fixed_ (by going to "+m"), "volatile" is no longer useful. (It wasn't useful before, it just _papered over_ a problem). If "volatile" is in use elsewhere (other than locks), it's still probably wrong. In these cases, you can use a barrier, a volatile cast, or an inline asm with a specific clobber. Thanks, Chase