From: niklas Date: Tue, 24 Dec 1996 20:14:28 +0000 (+0000) Subject: Make termination of objects wait for possible collapses before altering X-Git-Url: http://artulab.com/gitweb/?a=commitdiff_plain;h=51fad3232fc89f871b02615ff093e52fac00b3ae;p=openbsd Make termination of objects wait for possible collapses before altering the object's shadow linkage. Also note that the object is going to die so that a possible collapse can finish early. --- diff --git a/sys/vm/vm_object.c b/sys/vm/vm_object.c index 0fa0d2e92c4..722d2f583b0 100644 --- a/sys/vm/vm_object.c +++ b/sys/vm/vm_object.c @@ -1,4 +1,4 @@ -/* $OpenBSD: vm_object.c,v 1.12 1996/11/06 23:24:40 niklas Exp $ */ +/* $OpenBSD: vm_object.c,v 1.13 1996/12/24 20:14:28 niklas Exp $ */ /* $NetBSD: vm_object.c,v 1.34 1996/02/28 22:35:35 gwr Exp $ */ /* @@ -337,6 +337,21 @@ vm_object_terminate(object) register vm_page_t p; vm_object_t shadow_object; + /* + * Setters of paging_in_progress might be interested that this object + * is going away as soon as we get a grip on it. + */ + object->flags |= OBJ_FADING; + + /* + * Wait until the pageout daemon is through with the object or a + * potential collapse operation is finished. + */ + while (object->paging_in_progress) { + vm_object_sleep(object, object, FALSE); + vm_object_lock(object); + } + /* * Detach the object from its shadow if we are the shadow's * copy. @@ -353,14 +368,6 @@ vm_object_terminate(object) vm_object_unlock(shadow_object); } - /* - * Wait until the pageout daemon is through with the object. - */ - while (object->paging_in_progress) { - vm_object_sleep(object, object, FALSE); - vm_object_lock(object); - } - /* * If not an internal object clean all the pages, removing them * from paging queues as we go. @@ -1340,6 +1347,18 @@ vm_object_collapse_aux(object) thread_wakeup(backing_object); thread_wakeup(object); + /* + * During the pagein vm_object_terminate + * might have slept on our front object in + * order to remove it. If this is the + * case, we might as well stop all the + * collapse work right here. + */ + if (object->flags & OBJ_FADING) { + PAGE_WAKEUP(backing_page); + return KERN_FAILURE; + } + /* * Third, relookup in case pager changed * page. Pager is responsible for diff --git a/sys/vm/vm_object.h b/sys/vm/vm_object.h index 46a7939ac68..be739e1fb11 100644 --- a/sys/vm/vm_object.h +++ b/sys/vm/vm_object.h @@ -1,4 +1,4 @@ -/* $OpenBSD: vm_object.h,v 1.3 1996/08/02 00:06:02 niklas Exp $ */ +/* $OpenBSD: vm_object.h,v 1.4 1996/12/24 20:14:32 niklas Exp $ */ /* $NetBSD: vm_object.h,v 1.16 1995/03/29 22:10:28 briggs Exp $ */ /* @@ -110,6 +110,7 @@ struct vm_object { #define OBJ_CANPERSIST 0x0001 /* allow to persist */ #define OBJ_INTERNAL 0x0002 /* internally created object */ #define OBJ_ACTIVE 0x0004 /* used to mark active objects */ +#define OBJ_FADING 0x0008 /* tell others that the object is going away */ TAILQ_HEAD(vm_object_hash_head, vm_object_hash_entry);