Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/chs-ubc2]: src/sys/uvm add uvm_page_unbusy() to simplify dropping PG_BUSY.



details:   https://anonhg.NetBSD.org/src/rev/486fa2a437dd
branches:  chs-ubc2
changeset: 471410:486fa2a437dd
user:      chs <chs%NetBSD.org@localhost>
date:      Sat Jul 31 18:57:31 1999 +0000

description:
add uvm_page_unbusy() to simplify dropping PG_BUSY.

diffstat:

 sys/uvm/uvm_page.c |  56 +++++++++++++++++++++++++++++++++++++++++++++++++++--
 sys/uvm/uvm_page.h |   8 ++----
 2 files changed, 56 insertions(+), 8 deletions(-)

diffs (113 lines):

diff -r 71e76752c0cc -r 486fa2a437dd sys/uvm/uvm_page.c
--- a/sys/uvm/uvm_page.c        Sat Jul 31 18:56:27 1999 +0000
+++ b/sys/uvm/uvm_page.c        Sat Jul 31 18:57:31 1999 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: uvm_page.c,v 1.17.2.1.2.3 1999/07/11 05:49:07 chs Exp $        */
+/*     $NetBSD: uvm_page.c,v 1.17.2.1.2.4 1999/07/31 18:57:31 chs Exp $        */
 
 /* 
  * Copyright (c) 1997 Charles D. Cranor and Washington University.
@@ -71,6 +71,7 @@
  */
 
 #include "opt_pmap_new.h"
+#include "opt_uvmhist.h"
 
 #include <sys/param.h>
 #include <sys/systm.h>
@@ -121,7 +122,7 @@
  */
 
 static void uvm_pageinsert __P((struct vm_page *));
-
+static void uvm_pageremove __P((struct vm_page *));
 
 /*
  * inline functions
@@ -168,7 +169,7 @@
  * => caller must lock page queues
  */
 
-void __inline
+static __inline void
 uvm_pageremove(pg)
        struct vm_page *pg;
 {
@@ -1112,6 +1113,55 @@
        uvm_unlock_fpageq(s);
 }
 
+/*
+ * uvm_page_unbusy: unbusy an array of pages.
+ *
+ * => pages must either all belong to the same object, or all belong to anons.
+ * => pages must not be loaned.
+ * => if pages are object-owned, object must be locked.
+ * => if pages are anon-owned, anons must be unlockd and have 0 refcount.
+ */
+
+void
+uvm_page_unbusy(pgs, npgs)
+       struct vm_page **pgs;
+       int npgs;
+{
+       struct vm_page *pg;
+       struct uvm_object *uobj;
+       int i;
+       UVMHIST_FUNC("uvm_page_unbusy"); UVMHIST_CALLED(ubchist);
+
+       for (i = 0; i < npgs; i++) {
+               pg = pgs[i];
+
+               if (pg == NULL) {
+                       continue;
+               }
+               if (pg->loan_count != 0) {
+                       panic("uvm_page_unbusy: loaned pg %p", pg);
+               }
+
+               if (pg->flags & PG_WANTED) {
+                       wakeup(pg);
+               }
+               if (pg->flags & PG_RELEASED) {
+                       UVMHIST_LOG(ubchist, "releasing pg %p", pg,0,0,0);
+                       if ((uobj = pg->uobject) != NULL) {
+                               uobj->pgops->pgo_releasepg(pg, NULL);
+                       } else {
+                               pg->flags &= ~(PG_BUSY);
+                               UVM_PAGE_OWN(pg, NULL);
+                               uvm_anfree(pg->uanon);
+                       }
+               } else {
+                       UVMHIST_LOG(ubchist, "unbusing pg %p", pg,0,0,0);
+                       pg->flags &= ~(PG_WANTED|PG_BUSY);
+                       UVM_PAGE_OWN(pg, NULL);
+               }
+       }
+}
+
 #if defined(UVM_PAGE_TRKOWN)
 /*
  * uvm_page_own: set or release page ownership
diff -r 71e76752c0cc -r 486fa2a437dd sys/uvm/uvm_page.h
--- a/sys/uvm/uvm_page.h        Sat Jul 31 18:56:27 1999 +0000
+++ b/sys/uvm/uvm_page.h        Sat Jul 31 18:57:31 1999 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: uvm_page.h,v 1.11.4.2 1999/07/01 23:55:17 thorpej Exp $        */
+/*     $NetBSD: uvm_page.h,v 1.11.4.3 1999/07/31 18:57:39 chs Exp $    */
 
 /* 
  * Copyright (c) 1997 Charles D. Cranor and Washington University.
@@ -116,10 +116,8 @@
 PAGE_INLINE void uvm_pagecopy __P((struct vm_page *, struct vm_page *));
 PAGE_INLINE void uvm_pagedeactivate __P((struct vm_page *));
 void uvm_pagefree __P((struct vm_page *));
-PAGE_INLINE struct vm_page *uvm_pagelookup 
-                                       __P((struct uvm_object *, vaddr_t));
-void uvm_pageremove __P((struct vm_page *));
-/* uvm_pagerename: not needed */
+void uvm_page_unbusy __P((struct vm_page **, int));
+PAGE_INLINE struct vm_page *uvm_pagelookup __P((struct uvm_object *, vaddr_t));
 PAGE_INLINE void uvm_pageunwire __P((struct vm_page *));
 PAGE_INLINE void uvm_pagewait __P((struct vm_page *, int));
 PAGE_INLINE void uvm_pagewake __P((struct vm_page *));



Home | Main Index | Thread Index | Old Index