From owner-svn-src-head@FreeBSD.ORG Wed Jun 3 21:06:57 2009 Return-Path: Delivered-To: svn-src-head@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 500B81065677; Wed, 3 Jun 2009 21:06:57 +0000 (UTC) (envelope-from pjd@garage.freebsd.pl) Received: from mail.garage.freebsd.pl (chello087206192061.chello.pl [87.206.192.61]) by mx1.freebsd.org (Postfix) with ESMTP id 967898FC19; Wed, 3 Jun 2009 21:06:56 +0000 (UTC) (envelope-from pjd@garage.freebsd.pl) Received: by mail.garage.freebsd.pl (Postfix, from userid 65534) id BE92245C9C; Wed, 3 Jun 2009 23:06:54 +0200 (CEST) Received: from localhost (chello087206192061.chello.pl [87.206.192.61]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by mail.garage.freebsd.pl (Postfix) with ESMTP id 5997E4569A; Wed, 3 Jun 2009 23:06:49 +0200 (CEST) Date: Wed, 3 Jun 2009 23:06:52 +0200 From: Pawel Jakub Dawidek To: Sean Nicholas Barkas Message-ID: <20090603210652.GD3821@garage.freebsd.pl> References: <200906030944.n539iM2K045164@svn.freebsd.org> Mime-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha1; protocol="application/pgp-signature"; boundary="O5XBE6gyVG5Rl6Rj" Content-Disposition: inline In-Reply-To: <200906030944.n539iM2K045164@svn.freebsd.org> User-Agent: Mutt/1.4.2.3i X-PGP-Key-URL: http://people.freebsd.org/~pjd/pjd.asc X-OS: FreeBSD 8.0-CURRENT i386 X-Spam-Checker-Version: SpamAssassin 3.0.4 (2005-06-05) on mail.garage.freebsd.pl X-Spam-Level: X-Spam-Status: No, score=-0.6 required=3.0 tests=BAYES_00,RCVD_IN_SORBS_DUL autolearn=no version=3.0.4 Cc: svn-src-head@freebsd.org, svn-src-all@freebsd.org, src-committers@freebsd.org Subject: Re: svn commit: r193375 - head/sys/ufs/ufs X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 03 Jun 2009 21:06:58 -0000 --O5XBE6gyVG5Rl6Rj Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable On Wed, Jun 03, 2009 at 09:44:22AM +0000, Sean Nicholas Barkas wrote: > Author: snb > Date: Wed Jun 3 09:44:22 2009 > New Revision: 193375 > URL: http://svn.freebsd.org/changeset/base/193375 >=20 > Log: > Add vm_lowmem event handler for dirhash. This will cause dirhashes to be > deleted when the system is low on memory. This ought to allow an increa= se to > vfs.ufs.dirhash_maxmem on machines that have lots of memory, without > degrading performance by having too much memory reserved for dirhash wh= en > other things need it. The default value for dirhash_maxmem is being kep= t at > 2MB for now, though. > =20 > This work was mostly done during the 2008 Google Summer of Code. > =20 > Approved by: dwmalone (mentor), re > MFC after: 3 months [...] > +static int > +ufsdirhash_destroy(struct dirhash *dh) > +{ [...] > + /* Remove it from the list and detach its memory. */ > + TAILQ_REMOVE(&ufsdirhash_list, dh, dh_list); [...] > +static void > +ufsdirhash_lowmem() > +{ [...] > + /*=20 > + * Delete dirhashes not used for more than ufs_dirhashreclaimage=20 > + * seconds. If we can't get a lock on the dirhash, it will be skipped. > + */ > + for (dh =3D TAILQ_FIRST(&ufsdirhash_list); dh !=3D NULL; dh =3D=20 > + TAILQ_NEXT(dh, dh_list)) { > + if (!sx_try_xlock(&dh->dh_lock)) > + continue; > + if (time_second - dh->dh_lastused > ufs_dirhashreclaimage) > + memfreed +=3D ufsdirhash_destroy(dh); > + /* Unlock if we didn't delete the dirhash */ > + else > + ufsdirhash_release(dh); > + } > + > + /*=20 > + * If not enough memory was freed, keep deleting hashes from the head= =20 > + * of the dirhash list. The ones closest to the head should be the=20 > + * oldest.=20 > + */ > + for (dh =3D TAILQ_FIRST(&ufsdirhash_list); memfreed < memwanted && > + dh !=3DNULL; dh =3D TAILQ_NEXT(dh, dh_list)) { > + if (!sx_try_xlock(&dh->dh_lock)) > + continue; > + memfreed +=3D ufsdirhash_destroy(dh); > + } > + DIRHASHLIST_UNLOCK(); > +} I don't see how that works. If you remove dh from the tailq in ufsdirhash_destroy(), you can't do 'dh =3D TAILQ_NEXT(dh, dh_list)' at the end of the loop. You should use TAILQ_FOREACH_SAFE(3). In the second case you also need to move this extra check into the loop, probably. In addition you drop DIRHASHLIST lock in ufsdirhash_destroy() during the loop. Can't the tailq be modified from elsewhere? Or even from parallel call to ufsdirhash_lowmem() (I don't think we serialize those)? --=20 Pawel Jakub Dawidek http://www.wheel.pl pjd@FreeBSD.org http://www.FreeBSD.org FreeBSD committer Am I Evil? Yes, I Am! --O5XBE6gyVG5Rl6Rj Content-Type: application/pgp-signature Content-Disposition: inline -----BEGIN PGP SIGNATURE----- Version: GnuPG v2.0.4 (FreeBSD) iD8DBQFKJuXrForvXbEpPzQRAmzyAKD0A66qjlntobqzZuTayARF3hjSPgCgnAIh 8xMU3V+3afLvKTb3KThI2GY= =LIJ2 -----END PGP SIGNATURE----- --O5XBE6gyVG5Rl6Rj--