Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1759254AbXEJVy6 (ORCPT ); Thu, 10 May 2007 17:54:58 -0400 Received: (majordomo@vger.kernel.org) by vger.kernel.org id S1759304AbXEJVyv (ORCPT ); Thu, 10 May 2007 17:54:51 -0400 Received: from mail.tmr.com ([64.65.253.246]:33093 "EHLO gaimboi.tmr.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1758697AbXEJVyu (ORCPT ); Thu, 10 May 2007 17:54:50 -0400 Message-ID: <4643947C.10105@tmr.com> Date: Thu, 10 May 2007 17:54:04 -0400 From: Bill Davidsen User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.8.0.8) Gecko/20061105 SeaMonkey/1.0.6 MIME-Version: 1.0 To: Jonathan Corbet CC: linux-kernel@vger.kernel.org, akpm@linux-foundation.org, Randy Dunlap Subject: Re: [PATCH] "volatile considered harmful" document References: <25493.1178744744@lwn.net> In-Reply-To: <25493.1178744744@lwn.net> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 1581 Lines: 33 Jonathan Corbet wrote: > +There are still a few rare situations where volatile makes sense in the > +kernel: > + > + - The above-mentioned accessor functions might use volatile on > + architectures where direct I/O memory access does work. Essentially, > + each accessor call becomes a little critical section on its own and > + ensures that the access happens as expected by the programmer. > + > + - Inline assembly code which changes memory, but which has no other > + visible side effects, risks being deleted by GCC. Adding the volatile > + keyword to asm statements will prevent this removal. > + > + - The jiffies variable is special in that it can have a different value > + every time it is referenced, but it can be read without any special > + locking. So jiffies can be volatile, but the addition of other > + variables of this type is frowned upon. Jiffies is considered to be a > + "stupid legacy" issue in this regard. It would seem that any variable which is (a) subject to change by other threads or hardware, and (b) the value of which is going to be used without writing the variable, would be a valid use for volatile. -- Bill Davidsen "We have more to fear from the bungling of the incompetent than from the machinations of the wicked." - from Slashdot - 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/