Source-Changes-HG archive

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

[src/trunk]: src/sys For debugging, use UVMHIST to create kernel histories pm...



details:   https://anonhg.NetBSD.org/src/rev/41c6ecc6fa28
branches:  trunk
changeset: 765976:41c6ecc6fa28
user:      matt <matt%NetBSD.org@localhost>
date:      Sun Jun 12 05:32:38 2011 +0000

description:
For debugging, use UVMHIST to create kernel histories pmaphist and
pmapexechist.  This replaces the old pmapdebug/PDB stuff.
In ddb, you can just use kernhist_dump(pmaphist) to view the history
or vmstat -H from userland.

diffstat:

 sys/arch/powerpc/booke/booke_pmap.c |    7 +-
 sys/arch/powerpc/booke/trap.c       |   24 ++-
 sys/common/pmap/tlb/pmap.c          |  376 ++++++++++++++++++++---------------
 sys/common/pmap/tlb/pmap.h          |    8 +-
 4 files changed, 249 insertions(+), 166 deletions(-)

diffs (truncated from 917 to 300 lines):

diff -r 719d83466cc2 -r 41c6ecc6fa28 sys/arch/powerpc/booke/booke_pmap.c
--- a/sys/arch/powerpc/booke/booke_pmap.c       Sun Jun 12 05:31:14 2011 +0000
+++ b/sys/arch/powerpc/booke/booke_pmap.c       Sun Jun 12 05:32:38 2011 +0000
@@ -37,7 +37,7 @@
 
 #include <sys/cdefs.h>
 
-__KERNEL_RCSID(0, "$NetBSD: booke_pmap.c,v 1.4 2011/06/05 16:52:24 matt Exp $");
+__KERNEL_RCSID(0, "$NetBSD: booke_pmap.c,v 1.5 2011/06/12 05:32:38 matt Exp $");
 
 #include <sys/param.h>
 #include <sys/kcore.h>
@@ -263,8 +263,9 @@
 void
 pmap_zero_page(paddr_t pa)
 {
-//     printf("%s(%#lx): calling dcache_zero_page(%#lx)\n", __func__, pa, pa);
        dcache_zero_page(pa);
+
+       KASSERT(!VM_PAGE_MD_EXECPAGE_P(PHYS_TO_VM_PAGE(pa)));
 }
 
 void
@@ -289,6 +290,8 @@
                              "r28", "r29", "r30", "r31");
                }
        }
+
+       KASSERT(!VM_PAGE_MD_EXECPAGE_P(PHYS_TO_VM_PAGE(dst - PAGE_SIZE)));
 }
 
 void
diff -r 719d83466cc2 -r 41c6ecc6fa28 sys/arch/powerpc/booke/trap.c
--- a/sys/arch/powerpc/booke/trap.c     Sun Jun 12 05:31:14 2011 +0000
+++ b/sys/arch/powerpc/booke/trap.c     Sun Jun 12 05:32:38 2011 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: trap.c,v 1.7 2011/06/05 16:52:24 matt Exp $    */
+/*     $NetBSD: trap.c,v 1.8 2011/06/12 05:32:38 matt Exp $    */
 /*-
  * Copyright (c) 2010, 2011 The NetBSD Foundation, Inc.
  * All rights reserved.
@@ -39,7 +39,7 @@
 
 #include <sys/cdefs.h>
 
-__KERNEL_RCSID(1, "$NetBSD: trap.c,v 1.7 2011/06/05 16:52:24 matt Exp $");
+__KERNEL_RCSID(1, "$NetBSD: trap.c,v 1.8 2011/06/12 05:32:38 matt Exp $");
 
 #include <sys/param.h>
 #include <sys/systm.h>
@@ -287,11 +287,20 @@
        KASSERT(ptep != NULL);
        pt_entry_t pte = *ptep;
 
+       UVMHIST_FUNC(__func__); UVMHIST_CALLED(pmapexechist);
+
        if ((pte & PTE_UNSYNCED) == PTE_UNSYNCED) {
                const paddr_t pa = pte_to_paddr(pte);
                struct vm_page * const pg = PHYS_TO_VM_PAGE(pa);
                KASSERT(pg);
 
+               UVMHIST_LOG(pmapexechist,
+                   "srr0=%#x pg=%p (pa %#"PRIxPADDR"): %s", 
+                   tf->tf_srr0, pg, pa, 
+                   (VM_PAGE_MD_EXECPAGE_P(pg)
+                       ? "no syncicache (already execpage)"
+                       : "performed syncicache (now execpage)"));
+
                if (!VM_PAGE_MD_EXECPAGE_P(pg)) {
                        ci->ci_softc->cpu_ev_exec_trap_sync.ev_count++;
                        dcache_wb_page(pa);
@@ -301,10 +310,12 @@
                pte &= ~PTE_UNSYNCED;
                pte |= PTE_xX;
                *ptep = pte;
+
                pmap_tlb_update_addr(faultmap->pmap, trunc_page(faultva),
                    pte, 0);
                kpreempt_enable();
-               return false;
+               UVMHIST_LOG(pmapexechist, "<- 0", 0,0,0,0);
+               return 0;
        }
        kpreempt_enable();
 
@@ -323,6 +334,7 @@
                ksi->ksi_code = SEGV_ACCERR;
                ksi->ksi_addr = (void *)tf->tf_srr0; /* not truncated */
        }
+       UVMHIST_LOG(pmapexechist, "<- %d", rv, 0,0,0);
        return rv;
 }
 
@@ -442,6 +454,12 @@
        if (!usertrap_p(tf))
                return rv;
 
+       UVMHIST_FUNC(__func__); UVMHIST_CALLED(pmapexechist);
+
+       UVMHIST_LOG(pmapexechist, " srr0/1=%#x/%#x esr=%#x pte=%#x", 
+           tf->tf_srr0, tf->tf_srr1, tf->tf_esr,
+           *trap_pte_lookup(tf, trunc_page(tf->tf_srr0), PSL_IS));
+
        ci->ci_ev_pgm.ev_count++;
 
        if (tf->tf_esr & ESR_PTR) {
diff -r 719d83466cc2 -r 41c6ecc6fa28 sys/common/pmap/tlb/pmap.c
--- a/sys/common/pmap/tlb/pmap.c        Sun Jun 12 05:31:14 2011 +0000
+++ b/sys/common/pmap/tlb/pmap.c        Sun Jun 12 05:32:38 2011 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: pmap.c,v 1.4 2011/06/05 16:52:27 matt Exp $    */
+/*     $NetBSD: pmap.c,v 1.5 2011/06/12 05:32:38 matt Exp $    */
 
 /*-
  * Copyright (c) 1998, 2001 The NetBSD Foundation, Inc.
@@ -67,7 +67,7 @@
 
 #include <sys/cdefs.h>
 
-__KERNEL_RCSID(0, "$NetBSD: pmap.c,v 1.4 2011/06/05 16:52:27 matt Exp $");
+__KERNEL_RCSID(0, "$NetBSD: pmap.c,v 1.5 2011/06/12 05:32:38 matt Exp $");
 
 /*
  *     Manages physical address maps.
@@ -189,21 +189,6 @@
 PMAP_COUNTER(protect, "protects");
 PMAP_COUNTER(page_protect, "page_protects");
 
-#define PDB_FOLLOW     0x0001
-#define PDB_INIT       0x0002
-#define PDB_ENTER      0x0004
-#define PDB_REMOVE     0x0008
-#define PDB_CREATE     0x0010
-#define PDB_PTPAGE     0x0020
-#define PDB_PVENTRY    0x0040
-#define PDB_BITS       0x0080
-#define PDB_PROTECT    0x0200
-#define PDB_TLBPID     0x0400
-#define PDB_PARANOIA   0x2000
-#define PDB_WIRING     0x4000
-#define PDB_PVDUMP     0x8000
-int pmapdebug = 0;
-
 #define PMAP_ASID_RESERVED 0
 CTASSERT(PMAP_ASID_RESERVED == 0);
 
@@ -243,6 +228,11 @@
 } poolpage;
 #endif
 
+#ifdef UVMHIST
+static struct kern_history_ent pmapexechistbuf[10000];
+static struct kern_history_ent pmaphistbuf[10000];
+#endif
+
 /*
  * The pools from which pmap structures and sub-structures are allocated.
  */
@@ -441,10 +431,10 @@
 void
 pmap_init(void)
 {
-#ifdef DEBUG
-       if (pmapdebug & (PDB_FOLLOW|PDB_INIT))
-               printf("pmap_init()\n");
-#endif
+        UVMHIST_INIT_STATIC(pmapexechist, pmapexechistbuf);
+        UVMHIST_INIT_STATIC(pmaphist, pmaphistbuf);
+
+       UVMHIST_FUNC(__func__); UVMHIST_CALLED(pmaphist);
 
        /*
         * Set a low water mark on the pv_entry pool, so that we are
@@ -478,11 +468,8 @@
 {
        pmap_t pmap;
 
+       UVMHIST_FUNC(__func__); UVMHIST_CALLED(pmaphist);
        PMAP_COUNT(create);
-#ifdef DEBUG
-       if (pmapdebug & (PDB_FOLLOW|PDB_CREATE))
-               printf("pmap_create()\n");
-#endif
 
        pmap = pool_get(&pmap_pmap_pool, PR_WAITOK);
        memset(pmap, 0, PMAP_SIZE);
@@ -495,6 +482,7 @@
 
        pmap_segtab_alloc(pmap);
 
+       UVMHIST_LOG(pmaphist, "<- pmap %p", pmap,0,0,0);
        return pmap;
 }
 
@@ -506,10 +494,9 @@
 void
 pmap_destroy(pmap_t pmap)
 {
-#ifdef DEBUG
-       if (pmapdebug & (PDB_FOLLOW|PDB_CREATE))
-               printf("pmap_destroy(%p)\n", pmap);
-#endif
+       UVMHIST_FUNC(__func__); UVMHIST_CALLED(pmaphist);
+       UVMHIST_LOG(pmaphist, "(pmap=%p)", pmap, 0,0,0);
+
        if (atomic_dec_uint_nv(&pmap->pm_count) > 0) {
                PMAP_COUNT(dereference);
                return;
@@ -523,6 +510,8 @@
 
        pool_put(&pmap_pmap_pool, pmap);
        kpreempt_enable();
+
+       UVMHIST_LOG(pmaphist, "<- done", 0,0,0,0);
 }
 
 /*
@@ -532,14 +521,15 @@
 pmap_reference(pmap_t pmap)
 {
 
-#ifdef DEBUG
-       if (pmapdebug & PDB_FOLLOW)
-               printf("pmap_reference(%p)\n", pmap);
-#endif
+       UVMHIST_FUNC(__func__); UVMHIST_CALLED(pmaphist);
+       UVMHIST_LOG(pmaphist, "(pmap=%p)", pmap, 0,0,0);
+       PMAP_COUNT(reference);
+
        if (pmap != NULL) {
                atomic_inc_uint(&pmap->pm_count);
        }
-       PMAP_COUNT(reference);
+
+       UVMHIST_LOG(pmaphist, "<- done", 0,0,0,0);
 }
 
 /*
@@ -550,6 +540,8 @@
 {
        pmap_t pmap = l->l_proc->p_vmspace->vm_map.pmap;
 
+       UVMHIST_FUNC(__func__); UVMHIST_CALLED(pmaphist);
+       UVMHIST_LOG(pmaphist, "(l=%p (pmap=%p))", l, pmap, 0,0);
        PMAP_COUNT(activate);
 
        kpreempt_disable();
@@ -558,6 +550,8 @@
                pmap_segtab_activate(pmap, l);
        }
        kpreempt_enable();
+
+       UVMHIST_LOG(pmaphist, "<- done", 0,0,0,0);
 }
 
 /*
@@ -566,39 +560,50 @@
 void
 pmap_deactivate(struct lwp *l)
 {
+       pmap_t pmap = l->l_proc->p_vmspace->vm_map.pmap;
+
+       UVMHIST_FUNC(__func__); UVMHIST_CALLED(pmaphist);
+       UVMHIST_LOG(pmaphist, "(l=%p (pmap=%p))", l, pmap, 0,0);
        PMAP_COUNT(deactivate);
 
        kpreempt_disable();
        curcpu()->ci_pmap_user_segtab = PMAP_INVALID_SEGTAB_ADDRESS;
-       pmap_tlb_asid_deactivate(l->l_proc->p_vmspace->vm_map.pmap);
+       pmap_tlb_asid_deactivate(pmap);
        kpreempt_enable();
+
+       UVMHIST_LOG(pmaphist, "<- done", 0,0,0,0);
 }
 
 void
-pmap_update(struct pmap *pm)
+pmap_update(struct pmap *pmap)
 {
+
+       UVMHIST_FUNC(__func__); UVMHIST_CALLED(pmaphist);
+       UVMHIST_LOG(pmaphist, "(pmap=%p)", pmap, 0,0,0);
        PMAP_COUNT(update);
 
        kpreempt_disable();
 #ifdef MULTIPROCESSOR
-       u_int pending = atomic_swap_uint(&pm->pm_shootdown_pending, 0);
-       if (pending && pmap_tlb_shootdown_bystanders(pm))
+       u_int pending = atomic_swap_uint(&pmap->pm_shootdown_pending, 0);
+       if (pending && pmap_tlb_shootdown_bystanders(pmap))
                PMAP_COUNT(shootdown_ipis);
 #endif
 #ifdef DEBUG
-       pmap_tlb_check(pm);
+       pmap_tlb_check(pmap);
 #endif /* DEBUG */
 
        /*
         * If pmap_remove_all was called, we deactivated ourselves and nuked
         * our ASID.  Now we have to reactivate ourselves.



Home | Main Index | Thread Index | Old Index