- 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.
This commit is contained in:
John Baldwin 2001-06-22 21:12:19 +00:00
parent 2f7f966cb8
commit 6d541bf1ae

View File

@ -312,10 +312,12 @@ swap_pager_swap_init()
nsw_cluster_max = min((MAXPHYS/PAGE_SIZE), MAX_PAGEOUT_CLUSTER); nsw_cluster_max = min((MAXPHYS/PAGE_SIZE), MAX_PAGEOUT_CLUSTER);
mtx_lock(&pbuf_mtx);
nsw_rcount = (nswbuf + 1) / 2; nsw_rcount = (nswbuf + 1) / 2;
nsw_wcount_sync = (nswbuf + 3) / 4; nsw_wcount_sync = (nswbuf + 3) / 4;
nsw_wcount_async = 4; nsw_wcount_async = 4;
nsw_wcount_async_max = nsw_wcount_async; nsw_wcount_async_max = nsw_wcount_async;
mtx_unlock(&pbuf_mtx);
/* /*
* Initialize our zone. Right now I'm just guessing on the number * 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. * Do not let the sysop crash the machine with bogus numbers.
*/ */
mtx_lock(&pbuf_mtx);
if (swap_async_max != nsw_wcount_async_max) { if (swap_async_max != nsw_wcount_async_max) {
int n; int n;
int s; int s;
@ -1312,18 +1315,15 @@ swap_pager_putpages(object, m, count, sync, rtvals)
* at this time. * at this time.
*/ */
s = splvm(); s = splvm();
mtx_unlock(&vm_mtx);
mtx_lock(&pbuf_mtx);
n -= nsw_wcount_async_max; n -= nsw_wcount_async_max;
if (nsw_wcount_async + n >= 0) { if (nsw_wcount_async + n >= 0) {
nsw_wcount_async += n; nsw_wcount_async += n;
nsw_wcount_async_max += n; nsw_wcount_async_max += n;
wakeup(&nsw_wcount_async); wakeup(&nsw_wcount_async);
} }
mtx_unlock(&pbuf_mtx);
mtx_lock(&vm_mtx);
splx(s); splx(s);
} }
mtx_unlock(&pbuf_mtx);
/* /*
* Step 3 * Step 3