Source-Changes-HG archive

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

[src/uebayasi-xip]: src/sys/arch Use VM_PAGE_TO_MD(). Only compile tested.



details:   https://anonhg.NetBSD.org/src/rev/bdc15b384ded
branches:  uebayasi-xip
changeset: 751608:bdc15b384ded
user:      uebayasi <uebayasi%NetBSD.org@localhost>
date:      Thu Feb 25 05:54:03 2010 +0000

description:
Use VM_PAGE_TO_MD().  Only compile tested.

diffstat:

 sys/arch/sparc/include/vmparam.h |   4 +-
 sys/arch/sparc64/sparc64/pmap.c  |  52 +++++++++++++++++++++++++++------------
 2 files changed, 38 insertions(+), 18 deletions(-)

diffs (247 lines):

diff -r 2139a913cb73 -r bdc15b384ded sys/arch/sparc/include/vmparam.h
--- a/sys/arch/sparc/include/vmparam.h  Thu Feb 25 05:13:01 2010 +0000
+++ b/sys/arch/sparc/include/vmparam.h  Thu Feb 25 05:54:03 2010 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: vmparam.h,v 1.40.2.1 2010/02/23 15:27:56 uebayasi Exp $ */
+/*     $NetBSD: vmparam.h,v 1.40.2.2 2010/02/25 05:54:03 uebayasi Exp $ */
 
 /*
  * Copyright (c) 1992, 1993
@@ -136,7 +136,7 @@
                int     pv_flags;               /* flags (below) */
        } pvlisthead;
 };
-#define VM_MDPAGE_PVHEAD(pg)   (&(pg)->mdpage.pvlisthead)
+#define VM_MDPAGE_PVHEAD(pg)   (&VM_PAGE_TO_MD(pg)->pvlisthead)
 
 #define VM_MDPAGE_INIT(md, pa) do {                    \
        (md)->pvlisthead.pv_next = NULL;                \
diff -r 2139a913cb73 -r bdc15b384ded sys/arch/sparc64/sparc64/pmap.c
--- a/sys/arch/sparc64/sparc64/pmap.c   Thu Feb 25 05:13:01 2010 +0000
+++ b/sys/arch/sparc64/sparc64/pmap.c   Thu Feb 25 05:54:03 2010 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: pmap.c,v 1.250 2010/02/05 12:04:10 martin Exp $        */
+/*     $NetBSD: pmap.c,v 1.250.2.1 2010/02/25 05:54:03 uebayasi Exp $  */
 /*
  *
  * Copyright (C) 1996-1999 Eduardo Horvath.
@@ -26,7 +26,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: pmap.c,v 1.250 2010/02/05 12:04:10 martin Exp $");
+__KERNEL_RCSID(0, "$NetBSD: pmap.c,v 1.250.2.1 2010/02/25 05:54:03 uebayasi Exp $");
 
 #undef NO_VCACHE /* Don't forget the locked TLB in dostart */
 #define        HWREF
@@ -1398,9 +1398,13 @@
 
        /* we could be a little smarter and leave pages zeroed */
        for (pg = TAILQ_FIRST(&pm->pm_obj.memq); pg != NULL; pg = nextpg) {
+#ifdef DIAGNOSTIC
+               struct vm_page_md * const md = VM_PAGE_TO_MD(pg);
+#endif
+
                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);
                uvm_pagefree(pg);
        }
        pmap_free_page((paddr_t)(u_long)pm->pm_segs);
@@ -1667,7 +1671,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)
@@ -2064,8 +2070,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)
@@ -2410,6 +2418,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;
@@ -2424,7 +2433,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 */
@@ -2493,6 +2502,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;
@@ -2506,7 +2516,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;
@@ -2559,7 +2569,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);
@@ -2584,13 +2594,14 @@
 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;
 
        KASSERT(!mutex_owned(&pmap_lock));
 
        /* 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
@@ -2640,13 +2651,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;
 
@@ -2688,13 +2700,14 @@
 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;
 
        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;
 
@@ -2766,6 +2779,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;
@@ -2778,7 +2792,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 */
 
@@ -3171,11 +3185,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) {
@@ -3232,12 +3247,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));
@@ -3308,6 +3324,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;
@@ -3317,7 +3334,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) {
@@ -3399,6 +3417,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) {
@@ -3411,7 +3430,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