From owner-p4-projects@FreeBSD.ORG Sun Jul 27 17:05:18 2008 Return-Path: Delivered-To: p4-projects@freebsd.org Received: by hub.freebsd.org (Postfix, from userid 32767) id 33ECE1065686; Sun, 27 Jul 2008 17:05:18 +0000 (UTC) Delivered-To: perforce@FreeBSD.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id EBDAD1065678 for ; Sun, 27 Jul 2008 17:05:17 +0000 (UTC) (envelope-from snb@FreeBSD.org) Received: from repoman.freebsd.org (repoman.freebsd.org [IPv6:2001:4f8:fff6::29]) by mx1.freebsd.org (Postfix) with ESMTP id E064B8FC08 for ; Sun, 27 Jul 2008 17:05:17 +0000 (UTC) (envelope-from snb@FreeBSD.org) Received: from repoman.freebsd.org (localhost [127.0.0.1]) by repoman.freebsd.org (8.14.2/8.14.2) with ESMTP id m6RH5HCk041088 for ; Sun, 27 Jul 2008 17:05:17 GMT (envelope-from snb@FreeBSD.org) Received: (from perforce@localhost) by repoman.freebsd.org (8.14.2/8.14.1/Submit) id m6RH5H7M041086 for perforce@freebsd.org; Sun, 27 Jul 2008 17:05:17 GMT (envelope-from snb@FreeBSD.org) Date: Sun, 27 Jul 2008 17:05:17 GMT Message-Id: <200807271705.m6RH5H7M041086@repoman.freebsd.org> X-Authentication-Warning: repoman.freebsd.org: perforce set sender to snb@FreeBSD.org using -f From: Nick Barkas To: Perforce Change Reviews Cc: Subject: PERFORCE change 146050 for review X-BeenThere: p4-projects@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: p4 projects tree changes List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 27 Jul 2008 17:05:18 -0000 http://perforce.freebsd.org/chv.cgi?CH=146050 Change 146050 by snb@snb_toro on 2008/07/27 17:05:09 Only delete dirhashes until we've freed up 10% of the memory that was in use when the vm_lowmem event handler was called. This amount could very well need some fine tuning, but this will prevent ufsdirhash_lowmem() from deleting gigabytes of dirhashes when only a little bit of memory is needed. Also make the fallback method of deleting just the first dirhash in the TAILQ actually stop after deleting that one rather than going on and removing every dirhash it can. Affected files ... .. //depot/projects/soc2008/snb-dirhash/sys-ufs-ufs/ufs_dirhash.c#7 edit Differences ... ==== //depot/projects/soc2008/snb-dirhash/sys-ufs-ufs/ufs_dirhash.c#7 (text+ko) ==== @@ -113,6 +113,7 @@ /* Protects: ufsdirhash_list, `dh_list' field, ufs_dirhashmem. */ static struct mtx ufsdirhash_mtx; + /* * Locking: * @@ -1172,19 +1173,25 @@ { struct dirhash *dh; int memfreed = 0; + int memwanted = ufs_dirhashmem / 10; ufs_dirhashlowmemcount++; DIRHASHLIST_LOCK(); /* - * Delete all dirhashes not used for more than DH_RECLAIMAGE seconds. - * If we can't get a lock on the dirhash, it will be skipped. + * Delete dirhashes not used for more than DH_RECLAIMAGE seconds. + * If we can't get a lock on the dirhash, it will be skipped. Quit + * when we have freed up 10% or more of the memory currently used by + * dirhashes. + * XXX 10% may need to be adjusted? */ for (dh = TAILQ_FIRST(&ufsdirhash_list); dh != NULL; dh = TAILQ_NEXT(dh, dh_list)) { if (time_second - dh->dh_lastused > DH_RECLAIMAGE && lockmgr(&dh->dh_lock, LK_EXCLUSIVE | LK_NOWAIT, NULL)) memfreed += ufsdirhash_destroy(dh); + if (memfreed >= memwanted) + break; } /* @@ -1198,6 +1205,7 @@ continue; } memfreed += ufsdirhash_destroy(dh); + break; } DIRHASHLIST_UNLOCK(); }