Source-Changes-HG archive

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

[src/trunk]: src/sys Abstraction fix; move physical address -> per-page metad...



details:   https://anonhg.NetBSD.org/src/rev/fce629cdcd40
branches:  trunk
changeset: 758647:fce629cdcd40
user:      uebayasi <uebayasi%NetBSD.org@localhost>
date:      Fri Nov 12 05:23:41 2010 +0000

description:
Abstraction fix; move physical address -> per-page metadata (struct
vm_page *) "reverse" lookup code from uvm_page.h to uvm_page.c, to
help migration to not do that.

Likewise move per-page metadata (struct vm_page *) -> physical
address "forward" conversion code into *.c too.  This is called
only low-layer VM and MD code.

diffstat:

 sys/rump/librump/rumpkern/vm.c |  22 ++++++++++++++++++++--
 sys/uvm/uvm_page.c             |  28 ++++++++++++++++++++++++++--
 sys/uvm/uvm_page.h             |  25 +++++--------------------
 3 files changed, 51 insertions(+), 24 deletions(-)

diffs (146 lines):

diff -r 43bb4677fe14 -r fce629cdcd40 sys/rump/librump/rumpkern/vm.c
--- a/sys/rump/librump/rumpkern/vm.c    Fri Nov 12 04:52:08 2010 +0000
+++ b/sys/rump/librump/rumpkern/vm.c    Fri Nov 12 05:23:41 2010 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: vm.c,v 1.98 2010/10/27 20:44:49 pooka Exp $    */
+/*     $NetBSD: vm.c,v 1.99 2010/11/12 05:23:41 uebayasi Exp $ */
 
 /*
  * Copyright (c) 2007-2010 Antti Kantee.  All Rights Reserved.
@@ -41,7 +41,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: vm.c,v 1.98 2010/10/27 20:44:49 pooka Exp $");
+__KERNEL_RCSID(0, "$NetBSD: vm.c,v 1.99 2010/11/12 05:23:41 uebayasi Exp $");
 
 #include <sys/param.h>
 #include <sys/atomic.h>
@@ -799,6 +799,24 @@
 }
 
 /*
+ * Physical address accessors.
+ */
+
+struct vm_page *
+uvm_phys_to_vm_page(paddr_t pa)
+{
+
+       return NULL;
+}
+
+paddr_t
+uvm_vm_page_to_phys(const struct vm_page *pg)
+{
+
+       return 0;
+}
+
+/*
  * Routines related to the Page Baroness.
  */
 
diff -r 43bb4677fe14 -r fce629cdcd40 sys/uvm/uvm_page.c
--- a/sys/uvm/uvm_page.c        Fri Nov 12 04:52:08 2010 +0000
+++ b/sys/uvm/uvm_page.c        Fri Nov 12 05:23:41 2010 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: uvm_page.c,v 1.162 2010/11/12 03:21:04 uebayasi Exp $  */
+/*     $NetBSD: uvm_page.c,v 1.163 2010/11/12 05:23:41 uebayasi Exp $  */
 
 /*
  * Copyright (c) 2010 The NetBSD Foundation, Inc.
@@ -97,7 +97,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: uvm_page.c,v 1.162 2010/11/12 03:21:04 uebayasi Exp $");
+__KERNEL_RCSID(0, "$NetBSD: uvm_page.c,v 1.163 2010/11/12 05:23:41 uebayasi Exp $");
 
 #include "opt_ddb.h"
 #include "opt_uvmhist.h"
@@ -978,6 +978,30 @@
 #endif
 
 /*
+ * PHYS_TO_VM_PAGE: find vm_page for a PA.   used by MI code to get vm_pages
+ * back from an I/O mapping (ugh!).   used in some MD code as well.
+ */
+struct vm_page *
+uvm_phys_to_vm_page(paddr_t pa)
+{
+       paddr_t pf = atop(pa);
+       int     off;
+       int     psi;
+
+       psi = vm_physseg_find(pf, &off);
+       if (psi != -1)
+               return(&VM_PHYSMEM_PTR(psi)->pgs[off]);
+       return(NULL);
+}
+
+paddr_t
+uvm_vm_page_to_phys(const struct vm_page *pg)
+{
+
+       return pg->phys_addr;
+}
+
+/*
  * uvm_page_recolor: Recolor the pages if the new bucket count is
  * larger than the old one.
  */
diff -r 43bb4677fe14 -r fce629cdcd40 sys/uvm/uvm_page.h
--- a/sys/uvm/uvm_page.h        Fri Nov 12 04:52:08 2010 +0000
+++ b/sys/uvm/uvm_page.h        Fri Nov 12 05:23:41 2010 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: uvm_page.h,v 1.64 2010/11/12 03:21:04 uebayasi Exp $   */
+/*     $NetBSD: uvm_page.h,v 1.65 2010/11/12 05:23:41 uebayasi Exp $   */
 
 /*
  * Copyright (c) 1997 Charles D. Cranor and Washington University.
@@ -294,8 +294,9 @@
 
 int uvm_page_lookup_freelist(struct vm_page *);
 
-static struct vm_page *PHYS_TO_VM_PAGE(paddr_t);
 int vm_physseg_find(paddr_t, int *);
+struct vm_page *uvm_phys_to_vm_page(paddr_t);
+paddr_t uvm_vm_page_to_phys(const struct vm_page *);
 
 /*
  * macros
@@ -303,7 +304,7 @@
 
 #define UVM_PAGE_TREE_PENALTY  4       /* XXX: a guess */
 
-#define VM_PAGE_TO_PHYS(entry) ((entry)->phys_addr)
+#define VM_PAGE_TO_PHYS(entry) uvm_vm_page_to_phys(entry)
 
 /*
  * Compute the page color bucket for a given page.
@@ -311,23 +312,7 @@
 #define        VM_PGCOLOR_BUCKET(pg) \
        (atop(VM_PAGE_TO_PHYS((pg))) & uvmexp.colormask)
 
-
-/*
- * PHYS_TO_VM_PAGE: find vm_page for a PA.   used by MI code to get vm_pages
- * back from an I/O mapping (ugh!).   used in some MD code as well.
- */
-static inline struct vm_page *
-PHYS_TO_VM_PAGE(paddr_t pa)
-{
-       paddr_t pf = atop(pa);
-       int     off;
-       int     psi;
-
-       psi = vm_physseg_find(pf, &off);
-       if (psi != -1)
-               return(&vm_physmem[psi].pgs[off]);
-       return(NULL);
-}
+#define        PHYS_TO_VM_PAGE(pa)     uvm_phys_to_vm_page(pa)
 
 #define VM_PAGE_IS_FREE(entry)  ((entry)->pqflags & PQ_FREE)
 #define        VM_FREE_PAGE_TO_CPU(pg) ((struct uvm_cpu *)((uintptr_t)pg->offset))



Home | Main Index | Thread Index | Old Index