diff options
author | dillon <dillon@FreeBSD.org> | 2001-07-04 16:20:28 +0000 |
---|---|---|
committer | dillon <dillon@FreeBSD.org> | 2001-07-04 16:20:28 +0000 |
commit | e028603b7e3e4fb35cdf00aab533f3965f4a13cc (patch) | |
tree | 7420cce169451a74c5b87963467a4aeff668ed12 /sys/vm/vm_pageout.c | |
parent | 0b028660051eb7abf4306d34e7fec0e7fde86a28 (diff) | |
download | FreeBSD-src-e028603b7e3e4fb35cdf00aab533f3965f4a13cc.zip FreeBSD-src-e028603b7e3e4fb35cdf00aab533f3965f4a13cc.tar.gz |
With Alfred's permission, remove vm_mtx in favor of a fine-grained approach
(this commit is just the first stage). Also add various GIANT_ macros to
formalize the removal of Giant, making it easy to test in a more piecemeal
fashion. These macros will allow us to test fine-grained locks to a degree
before removing Giant, and also after, and to remove Giant in a piecemeal
fashion via sysctl's on those subsystems which the authors believe can
operate without Giant.
Diffstat (limited to 'sys/vm/vm_pageout.c')
-rw-r--r-- | sys/vm/vm_pageout.c | 46 |
1 files changed, 11 insertions, 35 deletions
diff --git a/sys/vm/vm_pageout.c b/sys/vm/vm_pageout.c index f4c5670..444bfdc 100644 --- a/sys/vm/vm_pageout.c +++ b/sys/vm/vm_pageout.c @@ -226,7 +226,8 @@ vm_pageout_clean(m) int ib, is, page_base; vm_pindex_t pindex = m->pindex; - mtx_assert(&vm_mtx, MA_OWNED); + GIANT_REQUIRED; + object = m->object; /* @@ -366,7 +367,7 @@ vm_pageout_flush(mc, count, flags) int numpagedout = 0; int i; - mtx_assert(&vm_mtx, MA_OWNED); + GIANT_REQUIRED; /* * Initiate I/O. Bump the vm_page_t->busy counter and * mark the pages read-only. @@ -449,8 +450,6 @@ vm_pageout_flush(mc, count, flags) * backing_objects. * * The object and map must be locked. - * - * Requires the vm_mtx */ static void vm_pageout_object_deactivate_pages(map, object, desired, map_remove_only) @@ -464,7 +463,7 @@ vm_pageout_object_deactivate_pages(map, object, desired, map_remove_only) int remove_mode; int s; - mtx_assert(&vm_mtx, MA_OWNED); + GIANT_REQUIRED; if (object->type == OBJT_DEVICE || object->type == OBJT_PHYS) return; @@ -553,7 +552,7 @@ vm_pageout_map_deactivate_pages(map, desired) vm_map_entry_t tmpe; vm_object_t obj, bigobj; - mtx_assert(&vm_mtx, MA_OWNED); + GIANT_REQUIRED; if (lockmgr(&map->lock, LK_EXCLUSIVE | LK_NOWAIT, (void *)0, curproc)) { return; } @@ -619,7 +618,7 @@ vm_pageout_page_free(vm_page_t m) { vm_object_t object = m->object; int type = object->type; - mtx_assert(&vm_mtx, MA_OWNED); + GIANT_REQUIRED; if (type == OBJT_SWAP || type == OBJT_DEFAULT) vm_object_reference(object); vm_page_busy(m); @@ -649,8 +648,7 @@ vm_pageout_scan(int pass) int maxlaunder; int s; - mtx_assert(&Giant, MA_OWNED); - mtx_assert(&vm_mtx, MA_OWNED); + GIANT_REQUIRED; /* * Do whatever cleanup that the pmap code can. */ @@ -878,17 +876,14 @@ rescan0: vp = object->handle; mp = NULL; - mtx_unlock(&vm_mtx); if (vp->v_type == VREG) vn_start_write(vp, &mp, V_NOWAIT); if (vget(vp, LK_EXCLUSIVE|LK_NOOBJ, curproc)) { vn_finished_write(mp); - mtx_lock(&vm_mtx); if (object->flags & OBJ_MIGHTBEDIRTY) vnodes_skipped++; continue; } - mtx_lock(&vm_mtx); /* * The page might have been moved to another @@ -902,10 +897,8 @@ rescan0: object->handle != vp) { if (object->flags & OBJ_MIGHTBEDIRTY) vnodes_skipped++; - mtx_unlock(&vm_mtx); vput(vp); vn_finished_write(mp); - mtx_lock(&vm_mtx); continue; } @@ -916,10 +909,8 @@ rescan0: * statistics are more correct if we don't. */ if (m->busy || (m->flags & PG_BUSY)) { - mtx_unlock(&vm_mtx); vput(vp); vn_finished_write(mp); - mtx_lock(&vm_mtx); continue; } @@ -933,10 +924,8 @@ rescan0: splx(s); if (object->flags & OBJ_MIGHTBEDIRTY) vnodes_skipped++; - mtx_unlock(&vm_mtx); vput(vp); vn_finished_write(mp); - mtx_lock(&vm_mtx); continue; } } @@ -967,10 +956,8 @@ rescan0: TAILQ_REMOVE(&vm_page_queues[PQ_INACTIVE].pl, &marker, pageq); splx(s); if (vp) { - mtx_unlock(&vm_mtx); vput(vp); vn_finished_write(mp); - mtx_lock(&vm_mtx); } } } @@ -1154,11 +1141,9 @@ rescan0: #if 0 if ((vm_swap_size < 64 || swap_pager_full) && vm_page_count_min()) { #endif - mtx_unlock(&vm_mtx); bigproc = NULL; bigsize = 0; sx_slock(&allproc_lock); - mtx_lock(&vm_mtx); LIST_FOREACH(p, &allproc, p_list) { /* * If this process is already locked, skip it. @@ -1350,7 +1335,6 @@ vm_pageout() int pass; mtx_lock(&Giant); - mtx_lock(&vm_mtx); /* * Initialize some paging parameters. @@ -1410,7 +1394,6 @@ vm_pageout() */ if (vm_pageout_stats_free_max == 0) vm_pageout_stats_free_max = 5; - mtx_unlock(&vm_mtx); PROC_LOCK(curproc); curproc->p_flag |= P_BUFEXHAUST; @@ -1420,7 +1403,6 @@ vm_pageout() /* * The pageout daemon is never done, so loop forever. */ - mtx_lock(&vm_mtx); while (TRUE) { int error; int s = splvm(); @@ -1444,7 +1426,7 @@ vm_pageout() */ ++pass; if (pass > 1) - msleep(&vm_pages_needed, &vm_mtx, PVM, + tsleep(&vm_pages_needed, PVM, "psleep", hz/2); } else { /* @@ -1455,8 +1437,8 @@ vm_pageout() pass = 1; else pass = 0; - error = msleep(&vm_pages_needed, &vm_mtx, - PVM, "psleep", vm_pageout_stats_interval * hz); + error = tsleep(&vm_pages_needed, PVM, + "psleep", vm_pageout_stats_interval * hz); if (error && !vm_pages_needed) { splx(s); pass = 0; @@ -1501,14 +1483,11 @@ vm_daemon() mtx_lock(&Giant); while (TRUE) { - mtx_lock(&vm_mtx); - msleep(&vm_daemon_needed, &vm_mtx, PPAUSE, "psleep", 0); + tsleep(&vm_daemon_needed, PPAUSE, "psleep", 0); if (vm_pageout_req_swapout) { swapout_procs(vm_pageout_req_swapout); - mtx_assert(&vm_mtx, MA_OWNED); vm_pageout_req_swapout = 0; } - mtx_unlock(&vm_mtx); /* * scan the processes for exceeding their rlimits or if * process is swapped out -- deactivate pages @@ -1525,7 +1504,6 @@ vm_daemon() if (p->p_flag & (P_SYSTEM | P_WEXIT)) { continue; } - mtx_lock(&vm_mtx); /* * if the process is in a non-running type state, * don't touch it. @@ -1533,7 +1511,6 @@ vm_daemon() mtx_lock_spin(&sched_lock); if (p->p_stat != SRUN && p->p_stat != SSLEEP) { mtx_unlock_spin(&sched_lock); - mtx_unlock(&vm_mtx); continue; } /* @@ -1557,7 +1534,6 @@ vm_daemon() vm_pageout_map_deactivate_pages( &p->p_vmspace->vm_map, limit); } - mtx_unlock(&vm_mtx); } sx_sunlock(&allproc_lock); } |