From owner-freebsd-arch@FreeBSD.ORG Wed May 13 00:25:55 2009 Return-Path: Delivered-To: arch@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id C8F6A106568B for ; Wed, 13 May 2009 00:25:55 +0000 (UTC) (envelope-from jroberson@jroberson.net) Received: from rv-out-0506.google.com (rv-out-0506.google.com [209.85.198.233]) by mx1.freebsd.org (Postfix) with ESMTP id A6D5F8FC1B for ; Wed, 13 May 2009 00:25:55 +0000 (UTC) (envelope-from jroberson@jroberson.net) Received: by rv-out-0506.google.com with SMTP id k40so245621rvb.43 for ; Tue, 12 May 2009 17:25:55 -0700 (PDT) Received: by 10.141.52.6 with SMTP id e6mr107223rvk.133.1242174355215; Tue, 12 May 2009 17:25:55 -0700 (PDT) Received: from ?10.0.1.198? (udp016664uds.hawaiiantel.net [72.235.41.117]) by mx.google.com with ESMTPS id g14sm1073984rvb.22.2009.05.12.17.25.53 (version=SSLv3 cipher=RC4-MD5); Tue, 12 May 2009 17:25:54 -0700 (PDT) Date: Tue, 12 May 2009 14:29:11 -1000 (HST) From: Jeff Roberson X-X-Sender: jroberson@desktop To: =?ISO-8859-15?Q?Dag-Erling_Sm=F8rgrav?= In-Reply-To: <86bppy60ti.fsf@ds4.des.no> Message-ID: References: <86bppy60ti.fsf@ds4.des.no> User-Agent: Alpine 2.00 (BSF 1167 2008-08-23) MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII; format=flowed Cc: arch@freebsd.org Subject: Re: lockless file descriptor lookup X-BeenThere: freebsd-arch@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Discussion related to FreeBSD architecture List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 13 May 2009 00:25:56 -0000 On Tue, 12 May 2009, Dag-Erling Sm?rgrav wrote: > Jeff Roberson writes: >> I'd also appreciate it if someone could look at my volatile cast and >> make sure I'm actually forcing the compiler to refresh the fd_ofiles >> array here: >> >> + if (fp == ((struct file *volatile*)fdp->fd_ofiles)[fd]) > > The problem is that since it is not declared as volatile, some other > piece of code may have modified it but not yet flushed it to RAM. That is an acceptable race due to other guarantees. If it hasn't been committed to memory yet, the old table still contains valid data. I only need to be certain that the compiler doesn't cache the original ofiles value. It can't anyway because atomics use inline assembly on all platforms but I'd like it to be explicit anyway. Thanks, Jeff > > DES > -- > Dag-Erling Sm?rgrav - des@des.no >