From owner-cvs-all@FreeBSD.ORG Wed Jun 9 18:14:36 2004 Return-Path: Delivered-To: cvs-all@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 0132016A4CE; Wed, 9 Jun 2004 18:14:36 +0000 (GMT) Received: from darkness.comp.waw.pl (darkness.comp.waw.pl [195.117.238.236]) by mx1.FreeBSD.org (Postfix) with ESMTP id A437043D45; Wed, 9 Jun 2004 18:14:35 +0000 (GMT) (envelope-from pjd@darkness.comp.waw.pl) Received: by darkness.comp.waw.pl (Postfix, from userid 1009) id 024E8ACAFB; Wed, 9 Jun 2004 19:37:48 +0200 (CEST) Date: Wed, 9 Jun 2004 19:37:47 +0200 From: Pawel Jakub Dawidek To: Garrett Wollman Message-ID: <20040609173747.GT12007@darkness.comp.waw.pl> References: <20040609.100413.118633043.imp@bsdimp.com> <55929.1086798000@critter.freebsd.dk> <200406091629.i59GTnCx052623@khavrinen.lcs.mit.edu> Mime-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha1; protocol="application/pgp-signature"; boundary="HC0F8i/BfMshQzR8" Content-Disposition: inline In-Reply-To: <200406091629.i59GTnCx052623@khavrinen.lcs.mit.edu> User-Agent: Mutt/1.4.2i X-PGP-Key-URL: http://people.freebsd.org/~pjd/pjd.asc X-OS: FreeBSD 5.2.1-RC2 i386 cc: cvs-src@FreeBSD.ORG cc: Poul-Henning Kamp cc: src-committers@FreeBSD.ORG cc: cvs-all@FreeBSD.ORG Subject: Re: cvs commit: src/sys/kern kern_proc.c X-BeenThere: cvs-all@freebsd.org X-Mailman-Version: 2.1.1 Precedence: list List-Id: CVS commit messages for the entire tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 09 Jun 2004 18:14:36 -0000 --HC0F8i/BfMshQzR8 Content-Type: text/plain; charset=iso-8859-2 Content-Disposition: inline Content-Transfer-Encoding: quoted-printable On Wed, Jun 09, 2004 at 12:29:49PM -0400, Garrett Wollman wrote: +> < said: +>=20 +> > The way to fix this is to make sure that the test for zero-ness +> > is done on the result of our own decrement operation: +>=20 +> > LOCK(foo->lock) +> > i =3D --foo->refcount; +> > UNLOCK(foo->lock) +> > if (i =3D=3D 0) +> > destroy(foo); +>=20 +> I think it's clearer if you write: +>=20 +> LOCK(foo->lock); +> if (--foo->refcount =3D=3D 0) +> destroy(foo); /* expects a locked foo */ +> else +> UNLOCK(foo); +>=20 +> ...and also a bit harder to mess up in maintenance (particularly if +> destroy() asserts that the lock is held). No, it is still wrong. The only good way is green's way. You cannot destroy object even if you held its lock, because another thread can sleep on this lock and it will be destroyed under it. So first of all one have to lock whole list of element before will take one of then and then remove it from the list before list-lock is released. --=20 Pawel Jakub Dawidek http://www.FreeBSD.org pjd@FreeBSD.org http://garage.freebsd.pl FreeBSD committer Am I Evil? Yes, I Am! --HC0F8i/BfMshQzR8 Content-Type: application/pgp-signature Content-Disposition: inline -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.2.4 (FreeBSD) iD8DBQFAx0rrForvXbEpPzQRAtc4AKCuzk5gBVW4Oe2MU5h7MwN3ufCWIgCg1Rlt CSu5aw95eahlpqh6lx/B2s0= =3OQZ -----END PGP SIGNATURE----- --HC0F8i/BfMshQzR8--