From owner-freebsd-sparc64@FreeBSD.ORG Tue Mar 1 12:01:47 2005 Return-Path: Delivered-To: freebsd-sparc64@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 0DB8C16A4CE; Tue, 1 Mar 2005 12:01:47 +0000 (GMT) Received: from cyrus.watson.org (cyrus.watson.org [204.156.12.53]) by mx1.FreeBSD.org (Postfix) with ESMTP id CE2E343D1F; Tue, 1 Mar 2005 12:01:46 +0000 (GMT) (envelope-from robert@fledge.watson.org) Received: from fledge.watson.org (fledge.watson.org [204.156.12.50]) by cyrus.watson.org (Postfix) with SMTP id 5A83D46B0C; Tue, 1 Mar 2005 07:01:46 -0500 (EST) Date: Tue, 1 Mar 2005 11:59:49 +0000 (GMT) From: Robert Watson X-Sender: robert@fledge.watson.org To: Doug White In-Reply-To: <20050228214850.X62607@carver.gumbysoft.com> Message-ID: MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII cc: sparc64@FreeBSD.org cc: net@FreeBSD.org cc: Kris Kennaway Subject: Re: Race condition in mb_free_ext()? X-BeenThere: freebsd-sparc64@freebsd.org X-Mailman-Version: 2.1.1 Precedence: list List-Id: Porting FreeBSD to the Sparc List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 01 Mar 2005 12:01:47 -0000 On Mon, 28 Feb 2005, Doug White wrote: > Forgive me for being naieve, but is there a reason you don't do an > atomic subtraction on the refcount? I can see why it repeats -- if two > things are warring over the refcount one or the other keep trying until > one wins -- but the subtraction would seem more intuitive. I'm not all that familiar with this code, but my guess is that he uses the cmpset so that he guarantees the value of 'cnt' is fresh with respect to the decrement -- i.e., only one caller to mb_free_ext() will end up with a 'cnt' of 1 and perform the GC. If you re-read it, there may be a race. Robert N M Watson