Source-Changes-HG archive

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

[src/trunk]: src/sys/arch/alpha/alpha Use VM_PAGE_TO_MD() to locate struct vm...



details:   https://anonhg.NetBSD.org/src/rev/b6bd4e6e35c3
branches:  trunk
changeset: 758273:b6bd4e6e35c3
user:      uebayasi <uebayasi%NetBSD.org@localhost>
date:      Sat Oct 30 17:00:54 2010 +0000

description:
Use VM_PAGE_TO_MD() to locate struct vm_page_md.  No functional
changes.

diffstat:

 sys/arch/alpha/alpha/pmap.c |  80 +++++++++++++++++++++++++++-----------------
 1 files changed, 49 insertions(+), 31 deletions(-)

diffs (285 lines):

diff -r 4ade282f40b4 -r b6bd4e6e35c3 sys/arch/alpha/alpha/pmap.c
--- a/sys/arch/alpha/alpha/pmap.c       Sat Oct 30 16:14:08 2010 +0000
+++ b/sys/arch/alpha/alpha/pmap.c       Sat Oct 30 17:00:54 2010 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: pmap.c,v 1.252 2009/11/26 00:19:11 matt Exp $ */
+/* $NetBSD: pmap.c,v 1.253 2010/10/30 17:00:54 uebayasi Exp $ */
 
 /*-
  * Copyright (c) 1998, 1999, 2000, 2001, 2007, 2008 The NetBSD Foundation, Inc.
@@ -140,7 +140,7 @@
 
 #include <sys/cdefs.h>                 /* RCS ID & Copyright macro defns */
 
-__KERNEL_RCSID(0, "$NetBSD: pmap.c,v 1.252 2009/11/26 00:19:11 matt Exp $");
+__KERNEL_RCSID(0, "$NetBSD: pmap.c,v 1.253 2010/10/30 17:00:54 uebayasi Exp $");
 
 #include <sys/param.h>
 #include <sys/systm.h>
@@ -159,6 +159,8 @@
 #include <machine/rpb.h>
 #endif
 
+#define        VM_PAGE_TO_MD(pg)       (&(pg)->mdpage)
+
 #ifdef DEBUG
 #define        PDB_FOLLOW      0x0001
 #define        PDB_INIT        0x0002
@@ -1401,6 +1403,7 @@
 void
 pmap_page_protect(struct vm_page *pg, vm_prot_t prot)
 {
+       struct vm_page_md * const md = VM_PAGE_TO_MD(pg);
        pmap_t pmap;
        pv_entry_t pv, nextpv;
        bool needkisync = false;
@@ -1427,7 +1430,7 @@
                PMAP_HEAD_TO_MAP_LOCK();
                lock = pmap_pvh_lock(pg);
                mutex_enter(lock);
-               for (pv = pg->mdpage.pvh_list; pv != NULL; pv = pv->pv_next) {
+               for (pv = md->pvh_list; pv != NULL; pv = pv->pv_next) {
                        PMAP_LOCK(pv->pv_pmap);
                        if (*pv->pv_pte & (PG_KWE | PG_UWE)) {
                                *pv->pv_pte &= ~(PG_KWE | PG_UWE);
@@ -1452,7 +1455,7 @@
        PMAP_HEAD_TO_MAP_LOCK();
        lock = pmap_pvh_lock(pg);
        mutex_enter(lock);
-       for (pv = pg->mdpage.pvh_list; pv != NULL; pv = nextpv) {
+       for (pv = md->pvh_list; pv != NULL; pv = nextpv) {
                nextpv = pv->pv_next;
                pmap = pv->pv_pmap;
 
@@ -1793,6 +1796,7 @@
         */
        npte = ((pa >> PGSHIFT) << PG_SHIFT) | pte_prot(pmap, prot) | PG_V;
        if (pg != NULL) {
+               struct vm_page_md * const md = VM_PAGE_TO_MD(pg);
                int attrs;
 
 #ifdef DIAGNOSTIC
@@ -1802,10 +1806,10 @@
                lock = pmap_pvh_lock(pg);
                mutex_enter(lock);
                if (flags & VM_PROT_WRITE)
-                       pg->mdpage.pvh_attrs |= (PGA_REFERENCED|PGA_MODIFIED);
+                       md->pvh_attrs |= (PGA_REFERENCED|PGA_MODIFIED);
                else if (flags & VM_PROT_ALL)
-                       pg->mdpage.pvh_attrs |= PGA_REFERENCED;
-               attrs = pg->mdpage.pvh_attrs;
+                       md->pvh_attrs |= PGA_REFERENCED;
+               attrs = md->pvh_attrs;
                mutex_exit(lock);
 
                /*
@@ -2282,6 +2286,7 @@
 bool
 pmap_clear_modify(struct vm_page *pg)
 {
+       struct vm_page_md * const md = VM_PAGE_TO_MD(pg);
        bool rv = false;
        long cpu_id = cpu_number();
        kmutex_t *lock;
@@ -2295,10 +2300,10 @@
        lock = pmap_pvh_lock(pg);
        mutex_enter(lock);
 
-       if (pg->mdpage.pvh_attrs & PGA_MODIFIED) {
+       if (md->pvh_attrs & PGA_MODIFIED) {
                rv = true;
                pmap_changebit(pg, PG_FOW, ~0, cpu_id);
-               pg->mdpage.pvh_attrs &= ~PGA_MODIFIED;
+               md->pvh_attrs &= ~PGA_MODIFIED;
        }
 
        mutex_exit(lock);
@@ -2315,6 +2320,7 @@
 bool
 pmap_clear_reference(struct vm_page *pg)
 {
+       struct vm_page_md * const md = VM_PAGE_TO_MD(pg);
        bool rv = false;
        long cpu_id = cpu_number();
        kmutex_t *lock;
@@ -2328,10 +2334,10 @@
        lock = pmap_pvh_lock(pg);
        mutex_enter(lock);
 
-       if (pg->mdpage.pvh_attrs & PGA_REFERENCED) {
+       if (md->pvh_attrs & PGA_REFERENCED) {
                rv = true;
                pmap_changebit(pg, PG_FOR | PG_FOW | PG_FOE, ~0, cpu_id);
-               pg->mdpage.pvh_attrs &= ~PGA_REFERENCED;
+               md->pvh_attrs &= ~PGA_REFERENCED;
        }
 
        mutex_exit(lock);
@@ -2539,6 +2545,7 @@
 static void
 pmap_changebit(struct vm_page *pg, u_long set, u_long mask, long cpu_id)
 {
+       struct vm_page_md * const md = VM_PAGE_TO_MD(pg);
        pv_entry_t pv;
        pt_entry_t *pte, npte;
        vaddr_t va;
@@ -2554,7 +2561,7 @@
        /*
         * Loop over all current mappings setting/clearing as apropos.
         */
-       for (pv = pg->mdpage.pvh_list; pv != NULL; pv = pv->pv_next) {
+       for (pv = md->pvh_list; pv != NULL; pv = pv->pv_next) {
                va = pv->pv_va;
 
                PMAP_LOCK(pv->pv_pmap);
@@ -2681,16 +2688,17 @@
         *      (2) if it was a write fault, mark page as modified.
         */
        pg = PHYS_TO_VM_PAGE(pa);
+       struct vm_page_md * const md = VM_PAGE_TO_MD(pg);
 
        PMAP_HEAD_TO_MAP_LOCK();
        lock = pmap_pvh_lock(pg);
        mutex_enter(lock);
 
        if (type == ALPHA_MMCSR_FOW) {
-               pg->mdpage.pvh_attrs |= (PGA_REFERENCED|PGA_MODIFIED);
+               md->pvh_attrs |= (PGA_REFERENCED|PGA_MODIFIED);
                faultoff = PG_FOR | PG_FOW;
        } else {
-               pg->mdpage.pvh_attrs |= PGA_REFERENCED;
+               md->pvh_attrs |= PGA_REFERENCED;
                faultoff = PG_FOR;
                if (exec) {
                        faultoff |= PG_FOE;
@@ -2713,16 +2721,18 @@
 pmap_pv_dump(paddr_t pa)
 {
        struct vm_page *pg;
+       struct vm_page_md *md;
        pv_entry_t pv;
        kmutex_t *lock;
 
        pg = PHYS_TO_VM_PAGE(pa);
+       md = VM_PAGE_TO_MD(pg);
 
        lock = pmap_pvh_lock(pg);
        mutex_enter(lock);
 
-       printf("pa 0x%lx (attrs = 0x%x):\n", pa, pg->mdpage.pvh_attrs);
-       for (pv = pg->mdpage.pvh_list; pv != NULL; pv = pv->pv_next)
+       printf("pa 0x%lx (attrs = 0x%x):\n", pa, md->pvh_attrs);
+       for (pv = md->pvh_list; pv != NULL; pv = pv->pv_next)
                printf("     pmap %p, va 0x%lx\n",
                    pv->pv_pmap, pv->pv_va);
        printf("\n");
@@ -2773,6 +2783,7 @@
 pmap_pv_enter(pmap_t pmap, struct vm_page *pg, vaddr_t va, pt_entry_t *pte,
     bool dolock)
 {
+       struct vm_page_md * const md = VM_PAGE_TO_MD(pg);
        pv_entry_t newpv;
        kmutex_t *lock;
 
@@ -2797,7 +2808,7 @@
        /*
         * Make sure the entry doesn't already exist.
         */
-       for (pv = pg->mdpage.pvh_list; pv != NULL; pv = pv->pv_next) {
+       for (pv = md->pvh_list; pv != NULL; pv = pv->pv_next) {
                if (pmap == pv->pv_pmap && va == pv->pv_va) {
                        printf("pmap = %p, va = 0x%lx\n", pmap, va);
                        panic("pmap_pv_enter: already in pv table");
@@ -2809,8 +2820,8 @@
        /*
         * ...and put it in the list.
         */
-       newpv->pv_next = pg->mdpage.pvh_list;
-       pg->mdpage.pvh_list = newpv;
+       newpv->pv_next = md->pvh_list;
+       md->pvh_list = newpv;
 
        if (dolock) {
                mutex_exit(lock);
@@ -2827,6 +2838,7 @@
 static void
 pmap_pv_remove(pmap_t pmap, struct vm_page *pg, vaddr_t va, bool dolock)
 {
+       struct vm_page_md * const md = VM_PAGE_TO_MD(pg);
        pv_entry_t pv, *pvp;
        kmutex_t *lock;
 
@@ -2840,7 +2852,7 @@
        /*
         * Find the entry to remove.
         */
-       for (pvp = &pg->mdpage.pvh_list, pv = *pvp;
+       for (pvp = &md->pvh_list, pv = *pvp;
             pv != NULL; pvp = &pv->pv_next, pv = *pvp)
                if (pmap == pv->pv_pmap && va == pv->pv_va)
                        break;
@@ -2910,9 +2922,10 @@
        if (pg != NULL) {
                pa = VM_PAGE_TO_PHYS(pg);
 #ifdef DEBUG
-               if (pg->mdpage.pvh_refcnt != 0) {
+               struct vm_page_md * const md = VM_PAGE_TO_MD(pg);
+               if (md->pvh_refcnt != 0) {
                        printf("pmap_physpage_alloc: page 0x%lx has "
-                           "%d references\n", pa, pg->mdpage.pvh_refcnt);
+                           "%d references\n", pa, md->pvh_refcnt);
                        panic("pmap_physpage_alloc");
                }
 #endif
@@ -2936,7 +2949,8 @@
                panic("pmap_physpage_free: bogus physical page address");
 
 #ifdef DEBUG
-       if (pg->mdpage.pvh_refcnt != 0)
+       struct vm_page_md * const md = VM_PAGE_TO_MD(pg);
+       if (md->pvh_refcnt != 0)
                panic("pmap_physpage_free: page still has references");
 #endif
 
@@ -2952,14 +2966,16 @@
 pmap_physpage_addref(void *kva)
 {
        struct vm_page *pg;
+       struct vm_page_md *md;
        paddr_t pa;
 
        pa = ALPHA_K0SEG_TO_PHYS(trunc_page((vaddr_t)kva));
        pg = PHYS_TO_VM_PAGE(pa);
-
-       KASSERT((int)pg->mdpage.pvh_refcnt >= 0);
-
-       return atomic_inc_uint_nv(&pg->mdpage.pvh_refcnt);
+       md = VM_PAGE_TO_MD(pg);
+
+       KASSERT((int)md->pvh_refcnt >= 0);
+
+       return atomic_inc_uint_nv(&md->pvh_refcnt);
 }
 
 /*
@@ -2971,14 +2987,16 @@
 pmap_physpage_delref(void *kva)
 {
        struct vm_page *pg;
+       struct vm_page_md *md;
        paddr_t pa;
 
        pa = ALPHA_K0SEG_TO_PHYS(trunc_page((vaddr_t)kva));
        pg = PHYS_TO_VM_PAGE(pa);
-
-       KASSERT((int)pg->mdpage.pvh_refcnt > 0);
-
-       return atomic_dec_uint_nv(&pg->mdpage.pvh_refcnt);
+       md = VM_PAGE_TO_MD(pg);
+
+       KASSERT((int)md->pvh_refcnt > 0);
+
+       return atomic_dec_uint_nv(&md->pvh_refcnt);
 }
 
 /******************** page table page management ********************/



Home | Main Index | Thread Index | Old Index