Date: Sun, 27 Jul 2008 17:05:17 GMT From: Nick Barkas <snb@FreeBSD.org> To: Perforce Change Reviews <perforce@FreeBSD.org> Subject: PERFORCE change 146050 for review Message-ID: <200807271705.m6RH5H7M041086@repoman.freebsd.org>
next in thread | raw e-mail | index | archive | help
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(); }
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200807271705.m6RH5H7M041086>