Source-Changes-HG archive

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

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



details:   https://anonhg.NetBSD.org/src/rev/44ed5669389e
branches:  trunk
changeset: 758277:44ed5669389e
user:      uebayasi <uebayasi%NetBSD.org@localhost>
date:      Sat Oct 30 18:30:55 2010 +0000

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

diffstat:

 sys/arch/arm/arm32/mem.c        |   8 ++++--
 sys/arch/sparc64/sparc64/pmap.c |  50 +++++++++++++++++++++++++++-------------
 2 files changed, 39 insertions(+), 19 deletions(-)

diffs (264 lines):

diff -r 2beecdb2b038 -r 44ed5669389e sys/arch/arm/arm32/mem.c
--- a/sys/arch/arm/arm32/mem.c  Sat Oct 30 18:08:48 2010 +0000
+++ b/sys/arch/arm/arm32/mem.c  Sat Oct 30 18:30:55 2010 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: mem.c,v 1.26 2008/11/19 06:24:04 matt Exp $    */
+/*     $NetBSD: mem.c,v 1.27 2010/10/30 18:35:38 uebayasi Exp $        */
 
 /*
  * Copyright (c) 1982, 1986, 1990, 1993
@@ -76,7 +76,7 @@
 #include "opt_compat_netbsd.h"
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: mem.c,v 1.26 2008/11/19 06:24:04 matt Exp $");
+__KERNEL_RCSID(0, "$NetBSD: mem.c,v 1.27 2010/10/30 18:35:38 uebayasi Exp $");
 
 #include <sys/param.h>
 #include <sys/conf.h>
@@ -92,6 +92,8 @@
 
 #include <uvm/uvm_extern.h>
 
+#define        VM_PAGE_TO_MD(pg)       (&(pg)->mdpage)
+
 extern vaddr_t memhook;                        /* in pmap.c (poor name!) */
 extern kmutex_t memlock;               /* in pmap.c */
 extern void *zeropage;                 /* in pmap.c */
@@ -145,7 +147,7 @@
                                struct vm_page *pg;
                                pg = PHYS_TO_VM_PAGE(trunc_page(v));
                                if (pg != NULL && pmap_is_page_colored_p(pg))
-                                       o = pg->mdpage.pvh_attrs;
+                                       o = VM_PAGE_TO_MD(pg)->pvh_attrs;
                                else
                                        o = v;
                                m += o & arm_cache_prefer_mask;
diff -r 2beecdb2b038 -r 44ed5669389e sys/arch/sparc64/sparc64/pmap.c
--- a/sys/arch/sparc64/sparc64/pmap.c   Sat Oct 30 18:08:48 2010 +0000
+++ b/sys/arch/sparc64/sparc64/pmap.c   Sat Oct 30 18:30:55 2010 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: pmap.c,v 1.265 2010/07/29 10:54:50 hannken Exp $       */
+/*     $NetBSD: pmap.c,v 1.266 2010/10/30 18:30:55 uebayasi Exp $      */
 /*
  *
  * Copyright (C) 1996-1999 Eduardo Horvath.
@@ -26,7 +26,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: pmap.c,v 1.265 2010/07/29 10:54:50 hannken Exp $");
+__KERNEL_RCSID(0, "$NetBSD: pmap.c,v 1.266 2010/10/30 18:30:55 uebayasi Exp $");
 
 #undef NO_VCACHE /* Don't forget the locked TLB in dostart */
 #define        HWREF
@@ -73,6 +73,8 @@
 #define db_printf      printf
 #endif
 
+#define        VM_PAGE_TO_MD(pg)       (&(pg)->mdpage)
+
 #define        MEG             (1<<20) /* 1MB */
 #define        KB              (1<<10) /* 1KB */
 
@@ -1447,7 +1449,7 @@
                KASSERT((pg->flags & PG_MARKER) == 0);
                nextpg = TAILQ_NEXT(pg, listq.queue);
                TAILQ_REMOVE(&pm->pm_obj.memq, pg, listq.queue);
-               KASSERT(pg->mdpage.mdpg_pvh.pv_pmap == NULL);
+               KASSERT(md->mdpg_pvh.pv_pmap == NULL);
                dcache_flush_page_cpuset(VM_PAGE_TO_PHYS(pg), pmap_cpus_active);
                uvm_pagefree(pg);
        }
@@ -1714,7 +1716,9 @@
         */
        pg = PHYS_TO_VM_PAGE(pa);
        if (pg) {
-               pvh = &pg->mdpage.mdpg_pvh;
+               struct vm_page_md * const md = VM_PAGE_TO_MD(pg);
+
+               pvh = &md->mdpg_pvh;
                uncached = (pvh->pv_va & (PV_ALIAS|PV_NVC));
 #ifdef DIAGNOSTIC
                if ((flags & VM_PROT_ALL) & ~prot)
@@ -2132,8 +2136,10 @@
 
                pg = PHYS_TO_VM_PAGE(pa);
                if (pg) {
+                       struct vm_page_md * const md = VM_PAGE_TO_MD(pg);
+
                        /* Save REF/MOD info */
-                       pv = &pg->mdpage.mdpg_pvh;
+                       pv = &md->mdpg_pvh;
                        if (data & TLB_ACCESS)
                                pv->pv_va |= PV_REF;
                        if (data & TLB_MODIFY)
@@ -2472,6 +2478,7 @@
 bool
 pmap_clear_modify(struct vm_page *pg)
 {
+       struct vm_page_md * const md = VM_PAGE_TO_MD(pg);
        pv_entry_t pv;
        int rv;
        int changed = 0;
@@ -2484,7 +2491,7 @@
 #endif
        mutex_enter(&pmap_lock);
        /* Clear all mappings */
-       pv = &pg->mdpage.mdpg_pvh;
+       pv = &md->mdpg_pvh;
 #ifdef DEBUG
        if (pv->pv_va & PV_MOD)
                pv->pv_va |= PV_WE;     /* Remember this was modified */
@@ -2553,6 +2560,7 @@
 bool
 pmap_clear_reference(struct vm_page *pg)
 {
+       struct vm_page_md * const md = VM_PAGE_TO_MD(pg);
        pv_entry_t pv;
        int rv;
        int changed = 0;
@@ -2566,7 +2574,7 @@
        referenced = pmap_is_referenced_locked(pg);
 #endif
        /* Clear all references */
-       pv = &pg->mdpage.mdpg_pvh;
+       pv = &md->mdpg_pvh;
        if (pv->pv_va & PV_REF) {
                changed |= 1;
                pv->pv_va &= ~PV_REF;
@@ -2619,7 +2627,7 @@
        pv_check();
 #ifdef DEBUG
        if (pmap_is_referenced_locked(pg)) {
-               pv = &pg->mdpage.mdpg_pvh;
+               pv = &md->mdpg_pvh;
                printf("pmap_clear_reference(): %p still referenced "
                        "(pmap = %p, ctx = %d)\n", pg, pv->pv_pmap,
                        pv->pv_pmap ? pmap_ctx(pv->pv_pmap) : 0);
@@ -2644,11 +2652,12 @@
 bool
 pmap_is_modified(struct vm_page *pg)
 {
+       struct vm_page_md * const md = VM_PAGE_TO_MD(pg);
        pv_entry_t pv, npv;
        bool res = false;
 
        /* Check if any mapping has been modified */
-       pv = &pg->mdpage.mdpg_pvh;
+       pv = &md->mdpg_pvh;
        if (pv->pv_va & PV_MOD)
                res = true;
 #ifdef HWREF
@@ -2698,13 +2707,14 @@
 static bool
 pmap_is_referenced_locked(struct vm_page *pg)
 {
+       struct vm_page_md * const md = VM_PAGE_TO_MD(pg);
        pv_entry_t pv, npv;
        bool res = false;
 
        KASSERT(mutex_owned(&pmap_lock));
 
        /* Check if any mapping has been referenced */
-       pv = &pg->mdpage.mdpg_pvh;
+       pv = &md->mdpg_pvh;
        if (pv->pv_va & PV_REF)
                return true;
 
@@ -2746,11 +2756,12 @@
 bool
 pmap_is_referenced(struct vm_page *pg)
 {
+       struct vm_page_md * const md = VM_PAGE_TO_MD(pg);
        pv_entry_t pv;
        bool res = false;
 
        /* Check if any mapping has been referenced */
-       pv = &pg->mdpage.mdpg_pvh;
+       pv = &md->mdpg_pvh;
        if (pv->pv_va & PV_REF)
                return true;
 
@@ -2822,6 +2833,7 @@
 void
 pmap_page_protect(struct vm_page *pg, vm_prot_t prot)
 {
+       struct vm_page_md * const md = VM_PAGE_TO_MD(pg);
        int64_t clear, set;
        int64_t data = 0;
        int rv;
@@ -2834,7 +2846,7 @@
            ("pmap_page_protect: pg %p prot %x\n", pg, prot));
 
        mutex_enter(&pmap_lock);
-       pv = &pg->mdpage.mdpg_pvh;
+       pv = &md->mdpg_pvh;
        if (prot & (VM_PROT_READ|VM_PROT_EXECUTE)) {
                /* copy_on_write */
 
@@ -3192,11 +3204,12 @@
 pmap_enter_pv(struct pmap *pmap, vaddr_t va, paddr_t pa, struct vm_page *pg,
              pv_entry_t npv)
 {
+       struct vm_page_md * const md = VM_PAGE_TO_MD(pg);
        pv_entry_t pvh;
 
        KASSERT(mutex_owned(&pmap_lock));
 
-       pvh = &pg->mdpage.mdpg_pvh;
+       pvh = &md->mdpg_pvh;
        DPRINTF(PDB_ENTER, ("pmap_enter: pvh %p: was %lx/%p/%p\n",
            pvh, pvh->pv_va, pvh->pv_pmap, pvh->pv_next));
        if (pvh->pv_pmap == NULL) {
@@ -3253,12 +3266,13 @@
 pv_entry_t
 pmap_remove_pv(struct pmap *pmap, vaddr_t va, struct vm_page *pg)
 {
+       struct vm_page_md * const md = VM_PAGE_TO_MD(pg);
        pv_entry_t pvh, npv, pv;
        int64_t data = 0;
 
        KASSERT(mutex_owned(&pmap_lock));
 
-       pvh = &pg->mdpage.mdpg_pvh;
+       pvh = &md->mdpg_pvh;
 
        DPRINTF(PDB_REMOVE, ("pmap_remove_pv(pm=%p, va=%p, pg=%p)\n", pmap,
            (void *)(u_long)va, pg));
@@ -3329,6 +3343,7 @@
 pmap_page_cache(struct pmap *pm, paddr_t pa, int mode)
 {
        struct vm_page *pg;
+       struct vm_page_md *md;
        pv_entry_t pv;
        vaddr_t va;
        int rv;
@@ -3338,7 +3353,8 @@
        DPRINTF(PDB_ENTER, ("pmap_page_uncache(%llx)\n",
            (unsigned long long)pa));
        pg = PHYS_TO_VM_PAGE(pa);
-       pv = &pg->mdpage.mdpg_pvh;
+       md = VM_PAGE_TO_MD(pg);
+       pv = &md->mdpg_pvh;
        while (pv) {
                va = pv->pv_va & PV_VAMASK;
                if (pv->pv_va & PV_NC) {
@@ -3431,6 +3447,7 @@
 db_dump_pv(db_expr_t addr, int have_addr, db_expr_t count, const char *modif)
 {
        struct vm_page *pg;
+       struct vm_page_md *md;
        struct pv_entry *pv;
 
        if (!have_addr) {
@@ -3443,7 +3460,8 @@
                db_printf("page is not managed\n");
                return;
        }
-       for (pv = &pg->mdpage.mdpg_pvh; pv; pv = pv->pv_next)
+       md = VM_PAGE_TO_MD(pg);
+       for (pv = &md->mdpg_pvh; pv; pv = pv->pv_next)
                db_printf("pv@%p: next=%p pmap=%p va=0x%llx\n",
                          pv, pv->pv_next, pv->pv_pmap,
                          (unsigned long long)pv->pv_va);



Home | Main Index | Thread Index | Old Index