diff options
author | Niklas Hallqvist <niklas@cvs.openbsd.org> | 1997-04-17 01:25:23 +0000 |
---|---|---|
committer | Niklas Hallqvist <niklas@cvs.openbsd.org> | 1997-04-17 01:25:23 +0000 |
commit | 88b359233160997d773bfca12d4654247062701d (patch) | |
tree | 54f9173892d3b02700bcb5bd04f403869b91a844 /sys/vm/vm_pageout.c | |
parent | 823c29b4663430510be1e46e888f930ca96a9ab4 (diff) |
Removal of race conditions. Inspired by Charles Hannum's
<mycroft@netbsd.org> reorganization of the vm_collapse logic, although not
used verbatim. We no longer collapse objects from the pagedaemon as that
is not necessary anymore with the more aggressive collapses that gets done.
This also increases performance of loaded systems. Much KNF too.
Diffstat (limited to 'sys/vm/vm_pageout.c')
-rw-r--r-- | sys/vm/vm_pageout.c | 45 |
1 files changed, 24 insertions, 21 deletions
diff --git a/sys/vm/vm_pageout.c b/sys/vm/vm_pageout.c index f2c9cad7509..23585120dd2 100644 --- a/sys/vm/vm_pageout.c +++ b/sys/vm/vm_pageout.c @@ -1,4 +1,4 @@ -/* $OpenBSD: vm_pageout.c,v 1.4 1996/09/18 11:57:38 deraadt Exp $ */ +/* $OpenBSD: vm_pageout.c,v 1.5 1997/04/17 01:25:22 niklas Exp $ */ /* $NetBSD: vm_pageout.c,v 1.23 1996/02/05 01:54:07 christos Exp $ */ /* @@ -72,6 +72,7 @@ #include <sys/param.h> #include <sys/proc.h> #include <sys/systm.h> +#include <sys/kernel.h> #include <vm/vm.h> #include <vm/vm_page.h> @@ -274,14 +275,22 @@ vm_pageout_page(m, object) * We must unlock the page queues first. */ vm_page_unlock_queues(); + +#if 0 + /* + * vm_object_collapse might want to sleep waiting for pages which + * is not allowed to do in this thread. Anyway, we now aggressively + * collapse object-chains as early as possible so this call ought + * to not be very useful anyhow. This is just an educated guess. + * Not doing a collapse operation is never fatal though, so we skip + * it for the time being. Later we might add some NOWAIT option for + * the collapse code to look at, if it's deemed necessary. + */ if (object->pager == NULL) vm_object_collapse(object); - -#ifdef DIAGNOSTIC - if (object->paging_in_progress == 0xdead) - panic("vm_pageout_page: object deallocated"); #endif - object->paging_in_progress++; + + vm_object_paging_begin(object); vm_object_unlock(object); /* @@ -297,7 +306,7 @@ vm_pageout_page(m, object) */ if ((pager = object->pager) == NULL) { pager = vm_pager_allocate(PG_DFLT, (caddr_t)0, object->size, - VM_PROT_ALL, (vm_offset_t)0); + VM_PROT_ALL, (vm_offset_t)0); if (pager != NULL) vm_object_setpager(object, pager, 0, FALSE); } @@ -330,8 +339,8 @@ vm_pageout_page(m, object) * shortage, so we put pause for awhile and try again. * XXX could get stuck here. */ - (void) tsleep((caddr_t)&vm_pages_needed, PZERO|PCATCH, - "pageout", 100); + (void)tsleep((caddr_t)&vm_pages_needed, PZERO|PCATCH, + "pageout", hz); break; } case VM_PAGER_FAIL: @@ -357,7 +366,7 @@ vm_pageout_page(m, object) if (pageout_status != VM_PAGER_PEND) { m->flags &= ~PG_BUSY; PAGE_WAKEUP(m); - object->paging_in_progress--; + vm_object_paging_end(object); } } @@ -381,7 +390,6 @@ vm_pageout_cluster(m, object) vm_offset_t offset, loff, hoff; vm_page_t plist[MAXPOCLUSTER], *plistp, p; int postatus, ix, count; - extern int lbolt; /* * Determine the range of pages that can be part of a cluster @@ -448,11 +456,7 @@ vm_pageout_cluster(m, object) * in case it blocks. */ vm_page_unlock_queues(); -#ifdef DIAGNOSTIC - if (object->paging_in_progress == 0xdead) - panic("vm_pageout_cluster: object deallocated"); -#endif - object->paging_in_progress++; + vm_object_paging_begin(object); vm_object_unlock(object); again: thread_wakeup(&cnt.v_free_count); @@ -461,7 +465,8 @@ again: * XXX rethink this */ if (postatus == VM_PAGER_AGAIN) { - (void) tsleep((caddr_t)&lbolt, PZERO|PCATCH, "pageout", 0); + (void)tsleep((caddr_t)&vm_pages_needed, PZERO|PCATCH, + "pageout", 0); goto again; } else if (postatus == VM_PAGER_BAD) panic("vm_pageout_cluster: VM_PAGER_BAD"); @@ -501,7 +506,6 @@ again: if (postatus != VM_PAGER_PEND) { p->flags &= ~PG_BUSY; PAGE_WAKEUP(p); - } } /* @@ -509,8 +513,7 @@ again: * indicator set so that we don't attempt an object collapse. */ if (postatus != VM_PAGER_PEND) - object->paging_in_progress--; - + vm_object_paging_end(object); } #endif @@ -521,7 +524,7 @@ again: void vm_pageout() { - (void) spl0(); + (void)spl0(); /* * Initialize some paging parameters. |