PERFORCE change 146050 for review
Nick Barkas
snb at FreeBSD.org
Sun Jul 27 17:05:18 UTC 2008
http://perforce.freebsd.org/chv.cgi?CH=146050
Change 146050 by snb at 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();
}
More information about the p4-projects
mailing list