From owner-freebsd-fs@FreeBSD.ORG Fri Apr 13 14:47:53 2007 Return-Path: X-Original-To: freebsd-fs@freebsd.org Delivered-To: freebsd-fs@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [69.147.83.52]) by hub.freebsd.org (Postfix) with ESMTP id AB9E416A408; Fri, 13 Apr 2007 14:47:53 +0000 (UTC) (envelope-from rwatson@FreeBSD.org) Received: from cyrus.watson.org (cyrus.watson.org [209.31.154.42]) by mx1.freebsd.org (Postfix) with ESMTP id 635E213C4B8; Fri, 13 Apr 2007 14:47:53 +0000 (UTC) (envelope-from rwatson@FreeBSD.org) Received: from fledge.watson.org (fledge.watson.org [209.31.154.41]) by cyrus.watson.org (Postfix) with ESMTP id 2111946DE8; Fri, 13 Apr 2007 10:47:52 -0400 (EDT) Date: Fri, 13 Apr 2007 15:47:52 +0100 (BST) From: Robert Watson X-X-Sender: robert@fledge.watson.org To: Craig Boston In-Reply-To: <20070413143550.GA19881@nowhere> Message-ID: <20070413154418.M65660@fledge.watson.org> References: <86k5wo55s0.fsf@dwp.des.no> <20070407203411.GJ8831@cicely12.cicely.de> <86wt0n3mxv.fsf@dwp.des.no> <20070411214911.GA38351@VARK.MIT.EDU> <20070412073605.GB834@turion.vk2pj.dyndns.org> <86ps6aht1i.fsf@dwp.des.no> <20070412160603.GB92079@keira.kiwi-computer.com> <20070412185159.GB95302@nowhere> <86slb5e33a.fsf@dwp.des.no> <20070413164840.V31079@besplex.bde.org> <20070413143550.GA19881@nowhere> MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII; format=flowed Cc: freebsd-fs@freebsd.org, Dag-Erling Sm?rgrav , "Rick C. Petty" , freebsd-current@freebsd.org Subject: Re: ZFS committed to the FreeBSD base. X-BeenThere: freebsd-fs@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Filesystems List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 13 Apr 2007 14:47:53 -0000 On Fri, 13 Apr 2007, Craig Boston wrote: > On Fri, Apr 13, 2007 at 05:34:56PM +1000, Bruce Evans wrote: > >> Doesn't everyone who uses atomic operations knows that they are expensive? >> :) > > Yes, though hopefully they should at least be faster than using a mutex, > though for cmpxchg8b it sounds like that may not necessarily be the case... A common example of this not being the case is statistics updates: it doesn't take too many statistics being updated at once before it makes more sense to use a mutex than individual atomic instructions, as mutex lock and unlock, in the uncontended case, involve an atomic instruction each (with memory barriers). Then it becomes more semantic: is using non-blocking primitives preferable, or are there consistency requirements between "atomically" updated fields? If contention never happens, then maybe you get consistency for free by using a mutex. As a general rule, unless it's a very clear-cut case (a simple counter), I would encourage people to program with mutexes rather than directly with atomic instructions. It prevents them from having to deal with really weird stuff that happens with weaker memory consistency. Robert N M Watson Computer Laboratory University of Cambridge