summaryrefslogtreecommitdiffstats
path: root/sys
diff options
context:
space:
mode:
authorjhb <jhb@FreeBSD.org>2001-06-22 21:12:19 +0000
committerjhb <jhb@FreeBSD.org>2001-06-22 21:12:19 +0000
commitce09fa9fbcc566309eb97707b5aadbb9162dadf8 (patch)
tree68b8f70d2008328fa143239c3a5ded0c841e5b1c /sys
parent95a162e88f188b9ba282d7871c9f371c97d5cc60 (diff)
downloadFreeBSD-src-ce09fa9fbcc566309eb97707b5aadbb9162dadf8.zip
FreeBSD-src-ce09fa9fbcc566309eb97707b5aadbb9162dadf8.tar.gz
- Protect all accesses to nsw_[rw]count{,_{,a}sync} with the pbuf mutex.
- Don't drop the vm mutex while grabbing the pbuf mutex to manipulate said variables.
Diffstat (limited to 'sys')
-rw-r--r--sys/vm/swap_pager.c8
1 files changed, 4 insertions, 4 deletions
diff --git a/sys/vm/swap_pager.c b/sys/vm/swap_pager.c
index 383863c..edbfa8e 100644
--- a/sys/vm/swap_pager.c
+++ b/sys/vm/swap_pager.c
@@ -312,10 +312,12 @@ swap_pager_swap_init()
nsw_cluster_max = min((MAXPHYS/PAGE_SIZE), MAX_PAGEOUT_CLUSTER);
+ mtx_lock(&pbuf_mtx);
nsw_rcount = (nswbuf + 1) / 2;
nsw_wcount_sync = (nswbuf + 3) / 4;
nsw_wcount_async = 4;
nsw_wcount_async_max = nsw_wcount_async;
+ mtx_unlock(&pbuf_mtx);
/*
* Initialize our zone. Right now I'm just guessing on the number
@@ -1293,6 +1295,7 @@ swap_pager_putpages(object, m, count, sync, rtvals)
* Do not let the sysop crash the machine with bogus numbers.
*/
+ mtx_lock(&pbuf_mtx);
if (swap_async_max != nsw_wcount_async_max) {
int n;
int s;
@@ -1312,18 +1315,15 @@ swap_pager_putpages(object, m, count, sync, rtvals)
* at this time.
*/
s = splvm();
- mtx_unlock(&vm_mtx);
- mtx_lock(&pbuf_mtx);
n -= nsw_wcount_async_max;
if (nsw_wcount_async + n >= 0) {
nsw_wcount_async += n;
nsw_wcount_async_max += n;
wakeup(&nsw_wcount_async);
}
- mtx_unlock(&pbuf_mtx);
- mtx_lock(&vm_mtx);
splx(s);
}
+ mtx_unlock(&pbuf_mtx);
/*
* Step 3
OpenPOWER on IntegriCloud