Source-Changes-HG archive

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

[src/uebayasi-xip]: src/sys/uvm Initial support of uvm_page_physunload(9) and...



details:   https://anonhg.NetBSD.org/src/rev/01ed24957f03
branches:  uebayasi-xip
changeset: 751695:01ed24957f03
user:      uebayasi <uebayasi%NetBSD.org@localhost>
date:      Wed Apr 28 13:28:42 2010 +0000

description:
Initial support of uvm_page_physunload(9) and uvm_page_physunload_device(9).
Note that callers of these functions are responsible to ensure that the
segment is not used.

diffstat:

 sys/uvm/uvm_extern.h |   4 ++-
 sys/uvm/uvm_page.c   |  66 ++++++++++++++++++++++++++++++++++++++++++++-------
 2 files changed, 60 insertions(+), 10 deletions(-)

diffs (164 lines):

diff -r 2f35b56119f1 -r 01ed24957f03 sys/uvm/uvm_extern.h
--- a/sys/uvm/uvm_extern.h      Wed Apr 28 09:27:47 2010 +0000
+++ b/sys/uvm/uvm_extern.h      Wed Apr 28 13:28:42 2010 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: uvm_extern.h,v 1.161.2.3 2010/04/28 08:22:04 uebayasi Exp $    */
+/*     $NetBSD: uvm_extern.h,v 1.161.2.4 2010/04/28 13:28:42 uebayasi Exp $    */
 
 /*
  *
@@ -722,8 +722,10 @@
 /* Actually, uvm_page_physload takes PF#s which need their own type */
 void                   *uvm_page_physload(paddr_t, paddr_t,
                            paddr_t, paddr_t, int);
+void                   uvm_page_physunload(void *);
 void                   *uvm_page_physload_device(paddr_t, paddr_t,
                            paddr_t, paddr_t, int);
+void                   uvm_page_physunload_device(void *);
 void                   uvm_setpagesize(void);
 
 /* uvm_pager.c */
diff -r 2f35b56119f1 -r 01ed24957f03 sys/uvm/uvm_page.c
--- a/sys/uvm/uvm_page.c        Wed Apr 28 09:27:47 2010 +0000
+++ b/sys/uvm/uvm_page.c        Wed Apr 28 13:28:42 2010 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: uvm_page.c,v 1.153.2.28 2010/04/28 09:27:47 uebayasi Exp $     */
+/*     $NetBSD: uvm_page.c,v 1.153.2.29 2010/04/28 13:28:43 uebayasi Exp $     */
 
 /*
  * Copyright (c) 1997 Charles D. Cranor and Washington University.
@@ -71,7 +71,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: uvm_page.c,v 1.153.2.28 2010/04/28 09:27:47 uebayasi Exp $");
+__KERNEL_RCSID(0, "$NetBSD: uvm_page.c,v 1.153.2.29 2010/04/28 13:28:43 uebayasi Exp $");
 
 #include "opt_ddb.h"
 #include "opt_uvmhist.h"
@@ -176,10 +176,8 @@
 static void uvm_pageremove(struct uvm_object *, struct vm_page *);
 #ifdef DEVICE_PAGE
 static void vm_page_device_mdpage_insert(paddr_t);
-#if 0
 static void vm_page_device_mdpage_remove(paddr_t);
 #endif
-#endif
 
 /*
  * per-object tree of pages
@@ -761,15 +759,17 @@
 static struct vm_physseg *
 uvm_page_physload_common(struct vm_physseg_freelist * const, struct vm_physseg **, int,
     const paddr_t, const paddr_t, const paddr_t, const paddr_t, const int);
-#if 0
 static void
-uvm_page_physunload_common(struct vm_physseg * const);
-#endif
+uvm_page_physunload_common(struct vm_physseg_freelist *,
+    struct vm_physseg **, struct vm_physseg *);
 static void
 uvm_page_physseg_init(void);
 static struct vm_physseg *
 uvm_physseg_insert(struct vm_physseg_freelist *, struct vm_physseg **, int,
     const paddr_t, const paddr_t);
+static void
+uvm_physseg_remove(struct vm_physseg_freelist *, struct vm_physseg **,
+    struct vm_physseg *);
 
 void *
 uvm_page_physload(paddr_t start, paddr_t end, paddr_t avail_start,
@@ -803,6 +803,19 @@
        return seg;
 }
 
+void
+uvm_page_physunload(void *cookie)
+{
+       struct vm_physseg *seg = cookie;
+
+       panic("memory unload is not supported yet");
+
+       /* XXX */
+
+       uvm_page_physunload_common(&vm_physmem_freelist, vm_physmem_ptrs, seg);
+       vm_nphysmem--;
+}
+
 #ifdef DEVICE_PAGE
 void *
 uvm_page_physload_device(paddr_t start, paddr_t end, paddr_t avail_start,
@@ -819,6 +832,17 @@
        vm_nphysdev++;
        return seg;
 }
+
+void
+uvm_page_physunload_device(void *cookie)
+{
+       struct vm_physseg *seg = cookie;
+
+       for (paddr_t pf = seg->start; pf < seg->end; pf++)
+               vm_page_device_mdpage_remove(pf);
+       uvm_page_physunload_common(&vm_physdev_freelist, vm_physdev_ptrs, seg);
+       vm_nphysdev--;
+}
 #endif
 
 static struct vm_physseg *
@@ -857,6 +881,14 @@
        return ps;
 }
 
+void
+uvm_page_physunload_common(struct vm_physseg_freelist *freelist,
+    struct vm_physseg **segs, struct vm_physseg *seg)
+{
+
+       uvm_physseg_remove(freelist, segs, seg);
+}
+
 static void
 uvm_page_physseg_init(void)
 {
@@ -917,6 +949,24 @@
        return ps;
 }
 
+static void
+uvm_physseg_remove(struct vm_physseg_freelist *freelist, struct vm_physseg **segs,
+    struct vm_physseg *seg)
+{
+       struct vm_physseg **segp;
+
+       for (segp = segs; segp < segs + VM_PHYSSEG_MAX; segp++)
+               if (*segp == seg)
+                       break;
+       if (segp == segs + VM_PHYSSEG_MAX)
+               panic("unknown segment: %p", seg);
+       SIMPLEQ_INSERT_TAIL(freelist, seg, list);
+       while (segp < segs + VM_PHYSSEG_MAX) {
+               *segp = *(segp + 1);
+               segp++;
+       }
+}
+
 /*
  * vm_physseg_find: find vm_physseg structure that belongs to a PA
  */
@@ -1248,7 +1298,6 @@
        mutex_spin_exit(lock);
 }
 
-#if 0
 static void
 vm_page_device_mdpage_remove(paddr_t pf)
 {
@@ -1275,7 +1324,6 @@
        KASSERT(mde != NULL);
        kmem_free(mde, sizeof(*mde));
 }
-#endif
 
 static struct vm_page_md *
 vm_page_device_mdpage_lookup(struct vm_page *pg)



Home | Main Index | Thread Index | Old Index