From a3880e122dd1dd267a3b5bc6631cb86b52f184ab Mon Sep 17 00:00:00 2001 From: jeff Date: Sun, 24 Mar 2002 10:56:11 +0000 Subject: Reset the cachefree statistics after draining the cache. This fixes a bug where a sysctl within 20 seconds of a cache_drain could yield negative "USED" counts. Also, grab the uma_mtx while in the sysctl handler. This hadn't caused problems yet because Giant is held all the time. Reported by: kkenn --- sys/vm/uma_core.c | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'sys') diff --git a/sys/vm/uma_core.c b/sys/vm/uma_core.c index 2f1b765..359c9e8 100644 --- a/sys/vm/uma_core.c +++ b/sys/vm/uma_core.c @@ -483,6 +483,8 @@ cache_drain(uma_zone_t zone) continue; CPU_UNLOCK(zone, cpu); } + + zone->uz_cachefree = 0; } /* @@ -1878,6 +1880,7 @@ sysctl_vm_zone(SYSCTL_HANDLER_ARGS) if (error || cnt == 0) goto out; offset = tmpbuf; + mtx_lock(&uma_mtx); LIST_FOREACH(z, &uma_zones, uz_link) { if (cnt == 0) /* list may have changed size */ break; @@ -1897,6 +1900,7 @@ sysctl_vm_zone(SYSCTL_HANDLER_ARGS) cnt--; offset += len; } + mtx_unlock(&uma_mtx); *offset++ = '\0'; error = SYSCTL_OUT(req, tmpbuf, offset - tmpbuf); out: -- cgit v1.1