From 6d541bf1ae28d17d5dae35abe2a82ce1ac9ab411 Mon Sep 17 00:00:00 2001 From: John Baldwin Date: Fri, 22 Jun 2001 21:12:19 +0000 Subject: [PATCH] - 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. --- sys/vm/swap_pager.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/sys/vm/swap_pager.c b/sys/vm/swap_pager.c index 383863cd7557..edbfa8e7a86c 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