Source-Changes-HG archive

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

[src/trunk]: src/sys/arch/sparc/sparc convert most uses of pmapdebug to use t...



details:   https://anonhg.NetBSD.org/src/rev/180e9d62abb2
branches:  trunk
changeset: 958696:180e9d62abb2
user:      mrg <mrg%NetBSD.org@localhost>
date:      Sun Jan 17 01:54:37 2021 +0000

description:
convert most uses of pmapdebug to use the new DPRINTF() macro.

add PMAP_INITLOUD debug option, that shows how pmap_bootstrap()
eats up the space provided by /boot as spare space.

diffstat:

 sys/arch/sparc/sparc/pmap.c |  233 ++++++++++++++++++-------------------------
 1 files changed, 96 insertions(+), 137 deletions(-)

diffs (truncated from 564 to 300 lines):

diff -r 3efe442c7230 -r 180e9d62abb2 sys/arch/sparc/sparc/pmap.c
--- a/sys/arch/sparc/sparc/pmap.c       Sun Jan 17 01:04:58 2021 +0000
+++ b/sys/arch/sparc/sparc/pmap.c       Sun Jan 17 01:54:37 2021 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: pmap.c,v 1.371 2021/01/13 16:42:17 chs Exp $ */
+/*     $NetBSD: pmap.c,v 1.372 2021/01/17 01:54:37 mrg Exp $ */
 
 /*
  * Copyright (c) 1996
@@ -56,7 +56,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: pmap.c,v 1.371 2021/01/13 16:42:17 chs Exp $");
+__KERNEL_RCSID(0, "$NetBSD: pmap.c,v 1.372 2021/01/17 01:54:37 mrg Exp $");
 
 #include "opt_ddb.h"
 #include "opt_kgdb.h"
@@ -155,6 +155,7 @@
 #define        PDB_CHANGEPROT  0x0008
 #define        PDB_ENTER       0x0010
 #define        PDB_FOLLOW      0x0020
+#define        PDB_INITLOUD    0x0040
 
 #define        PDB_MMU_ALLOC   0x0100
 #define        PDB_MMU_STEAL   0x0200
@@ -166,6 +167,12 @@
 #define        PDB_SWITCHMAP   0x8000
 #define        PDB_SANITYCHK   0x10000
 int    pmapdebug = 0;
+#define DPRINTF(level, fmt, ...) do { \
+       if (pmapdebug & (level)) \
+               printf("%s:%d: " fmt "\n", __func__, __LINE__, ##__VA_ARGS__); \
+} while (0)
+#else
+#define DPRINTF(level, fmt, ...) /* nothing */
 #endif
 
 /*
@@ -1619,8 +1626,8 @@
 #ifdef DEBUG
                if (me->me_pmap != NULL)
                        panic("me_alloc: freelist entry has pmap");
-               if (pmapdebug & PDB_MMU_ALLOC)
-                       printf("me_alloc: got pmeg %d\n", me->me_cookie);
+               DPRINTF(PDB_MMU_ALLOC,
+                   "me_alloc: got pmeg %d", me->me_cookie);
 #endif
                mmuq_insert_tail(mh, me);
 
@@ -1651,11 +1658,8 @@
 
        me = mmuq_first(&segm_lru);
        pm = me->me_pmap;
-#ifdef DEBUG
-       if (pmapdebug & (PDB_MMU_ALLOC | PDB_MMU_STEAL))
-               printf("me_alloc: stealing pmeg 0x%x from pmap %p\n",
-                   me->me_cookie, pm);
-#endif
+       DPRINTF(PDB_MMU_ALLOC | PDB_MMU_STEAL,
+           "me_alloc: stealing pmeg 0x%x from pmap %p", me->me_cookie, pm);
 
        mmu_stolenpmegs_evcnt.ev_count++;
 
@@ -1801,9 +1805,8 @@
 
 #ifdef DEBUG
        rp = &pm->pm_regmap[me->me_vreg];
-       if (pmapdebug & PDB_MMU_ALLOC)
-               printf("me_free: freeing pmeg %d from pmap %p\n",
-                   me->me_cookie, pm);
+       DPRINTF(PDB_MMU_ALLOC,
+          "me_free: freeing pmeg %d from pmap %p", me->me_cookie, pm);
        if (me->me_cookie != pmeg)
                panic("me_free: wrong mmuentry");
        if (pm != me->me_pmap)
@@ -1869,8 +1872,8 @@
 #ifdef DEBUG
                if (me->me_pmap != NULL)
                        panic("region_alloc: freelist entry has pmap");
-               if (pmapdebug & PDB_MMUREG_ALLOC)
-                       printf("region_alloc: got smeg 0x%x\n", me->me_cookie);
+               DPRINTF(PDB_MMUREG_ALLOC,
+                   "region_alloc: got smeg 0x%x", me->me_cookie);
 #endif
                mmuq_insert_tail(mh, me);
 
@@ -1895,11 +1898,10 @@
                panic("region_alloc: LRU entry has no pmap");
        if (pm == pmap_kernel())
                panic("region_alloc: stealing from kernel");
-#ifdef DEBUG
-       if (pmapdebug & (PDB_MMUREG_ALLOC | PDB_MMUREG_STEAL))
-               printf("region_alloc: stealing smeg 0x%x from pmap %p\n",
-                   me->me_cookie, pm);
-#endif
+       DPRINTF(PDB_MMUREG_ALLOC | PDB_MMUREG_STEAL,
+           "region_alloc: stealing smeg 0x%x from pmap %p",
+           me->me_cookie, pm);
+
        /*
         * Remove from LRU list, and insert at end of new list
         * (probably the LRU list again, but so what?).
@@ -1946,10 +1948,9 @@
 {
        struct mmuentry *me = &mmuregions[smeg];
 
+       DPRINTF(PDB_MMUREG_ALLOC,
+           "region_free: freeing smeg 0x%x from pmap %p", me->me_cookie, pm);
 #ifdef DEBUG
-       if (pmapdebug & PDB_MMUREG_ALLOC)
-               printf("region_free: freeing smeg 0x%x from pmap %p\n",
-                   me->me_cookie, pm);
        if (me->me_cookie != smeg)
                panic("region_free: wrong mmuentry");
        if (pm != me->me_pmap)
@@ -2145,9 +2146,10 @@
 #ifdef DEBUG
        if (pm->pm_ctx)
                panic("ctx_alloc pm_ctx");
-       if (pmapdebug & PDB_CTX_ALLOC)
-               printf("ctx_alloc[%d](%p)\n", cpu_number(), pm);
-#endif
+#endif
+       DPRINTF(PDB_CTX_ALLOC,
+           "ctx_alloc[%d](%p)", cpu_number(), pm);
+
        if (CPU_HAS_SUNMMU) {
                gap_start = pm->pm_gap_start;
                gap_end = pm->pm_gap_end;
@@ -2169,10 +2171,11 @@
 #ifdef DEBUG
                if (c->c_pmap == NULL)
                        panic("ctx_alloc cu_pmap");
-               if (pmapdebug & (PDB_CTX_ALLOC | PDB_CTX_STEAL))
-                       printf("ctx_alloc[%d]: steal context %d from %p\n",
-                           cpu_number(), cnum, c->c_pmap);
-#endif
+#endif
+               DPRINTF(PDB_CTX_ALLOC | PDB_CTX_STEAL,
+                   "ctx_alloc[%d]: steal context %d from %p",
+                   cpu_number(), cnum, c->c_pmap);
+
                c->c_pmap->pm_ctx = NULL;
                c->c_pmap->pm_ctxnum = 0;
                doflush = (CACHEINFO.c_vactype != VAC_NONE);
@@ -2621,13 +2624,10 @@
 #endif
                }
                if (BADALIAS(va, pv->pv_va)) {
-#ifdef DEBUG
-                       if (pmapdebug & PDB_CACHESTUFF)
-                               printf(
-                       "pv_link: badalias: proc %s, 0x%lx<=>0x%lx, pg %p\n",
-                               curproc ? curproc->p_comm : "--",
-                               va, pv->pv_va, pg);
-#endif
+                       DPRINTF(PDB_CACHESTUFF,
+                           "pv_link: badalias: proc %s, 0x%lx<=>0x%lx, pg %p",
+                           curproc ? curproc->p_comm : "--",
+                           va, pv->pv_va, pg);
                        /* Mark list head `uncached due to aliases' */
                        pv0->pv_flags |= PV_ANC;
                        pv_changepte4_4c(pg, PG_NC, 0);
@@ -2818,13 +2818,9 @@
                        if (BADALIAS(va, npv->pv_va) ||
                            (npv->pv_flags & PV_NC) != 0)
                                return;
-#ifdef DEBUG
-               if (pmapdebug & PDB_CACHESTUFF)
-                       printf(
-                       "pv_unlink: alias ok: proc %s, va 0x%lx, pg %p\n",
-                               curproc ? curproc->p_comm : "--",
-                               va, pg);
-#endif
+               DPRINTF(PDB_CACHESTUFF,
+                   "pv_unlink: alias ok: proc %s, va 0x%lx, pg %p",
+                   curproc ? curproc->p_comm : "--", va, pg);
                pv0->pv_flags &= ~PV_ANC;
                pv_changepte4m(pg, SRMMU_PG_C, 0);
        }
@@ -2890,13 +2886,10 @@
 #endif
                }
                if (BADALIAS(va, pv->pv_va)) {
-#ifdef DEBUG
-                       if (pmapdebug & PDB_CACHESTUFF)
-                               printf(
-                       "pv_link: badalias: proc %s, 0x%lx<=>0x%lx, pg %p\n",
+                       DPRINTF(PDB_CACHESTUFF,
+                           "pv_link: badalias: proc %s, 0x%lx<=>0x%lx, pg %p",
                                curproc ? curproc->p_comm : "--",
                                va, pv->pv_va, pg);
-#endif
                        /* Mark list head `uncached due to aliases' */
                        pv0->pv_flags |= PV_ANC;
                        pv_changepte4m(pg, 0, SRMMU_PG_C);
@@ -3588,6 +3581,7 @@
        p = (vaddr_t)top;
 
        p = (p + NBPG - 1) & ~PGOFSET;
+       DPRINTF(PDB_INITLOUD, "initial p=%lx", p);
 
        /*
         * Initialize the kernel pmap.
@@ -3605,8 +3599,8 @@
 #pragma GCC diagnostic ignored "-Warray-bounds"
        kernel_pmap_store.pm_regmap = kernel_regmap_store - NUREG;
 #pragma GCC diagnostic pop
-       memset(kernel_regmap_store, 0, NKREG * sizeof(struct regmap));
-       memset(kernel_segmap_store, 0, NKREG * NSEGRG * sizeof(struct segmap));
+       memset(kernel_regmap_store, 0, sizeof kernel_regmap_store);
+       memset(kernel_segmap_store, 0, sizeof kernel_segmap_store);
        for (i = NKREG; --i >= 0;) {
                kernel_regmap_store[i].rg_segmap =
                        &kernel_segmap_store[i * NSEGRG];
@@ -3617,15 +3611,18 @@
 
        /* Allocate kernel region pointer tables */
        pmap_kernel()->pm_reg_ptps = (int **)(q = p);
+       DPRINTF(PDB_INITLOUD, "kernel region pointer tables p=%lx", p);
        p += sparc_ncpus * sizeof(int **);
        memset((void *)q, 0, (u_int)p - (u_int)q);
 
        pmap_kernel()->pm_reg_ptps_pa = (int *)(q = p);
+       DPRINTF(PDB_INITLOUD, "kernel region pointer tables pa p=%lx", p);
        p += sparc_ncpus * sizeof(int *);
        memset((void *)q, 0, (u_int)p - (u_int)q);
 
        /* Allocate context administration */
        pmap_kernel()->pm_ctx = ctxinfo = ci = (union ctxinfo *)p;
+       DPRINTF(PDB_INITLOUD, "context administration p=%lx", p);
        p += ncontext * sizeof *ci;
        memset((void *)ci, 0, (u_int)p - (u_int)ci);
 
@@ -3636,6 +3633,7 @@
         * of available pages are free.
         */
        p = (p + NBPG - 1) & ~PGOFSET;
+       DPRINTF(PDB_INITLOUD, "align p=%lx", p);
 
        /*
         * Reserve memory for MMU pagetables. Some of these have severe
@@ -3654,6 +3652,7 @@
        cpuinfo.ctx_tbl = (int *)roundup((u_int)p, ctxtblsize);
        cpuinfo.ctx_tbl_pa = PMAP_BOOTSTRAP_VA2PA(cpuinfo.ctx_tbl);
        p = (u_int)cpuinfo.ctx_tbl + ctxtblsize;
+       DPRINTF(PDB_INITLOUD, "post ctx table p=%lx", p);
 
 #if defined(MULTIPROCESSOR)
        /*
@@ -3670,23 +3669,30 @@
         * mapping without delay.
         */
        p = (vaddr_t) roundup(p, SRMMU_L1SIZE * sizeof(u_int));
+       DPRINTF(PDB_INITLOUD, "roundup kernel_regtable_store p=%lx", p);
        qzero((void *)p, SRMMU_L1SIZE * sizeof(u_int));
        kernel_regtable_store = (u_int *)p;
        p += SRMMU_L1SIZE * sizeof(u_int);
+       DPRINTF(PDB_INITLOUD, "L1 pages p=%lx", p);
 
        p = (vaddr_t) roundup(p, SRMMU_L2SIZE * sizeof(u_int));
+       DPRINTF(PDB_INITLOUD, "roundup kernel_segtable_store p=%lx", p);
        qzero((void *)p, (SRMMU_L2SIZE * sizeof(u_int)) * NKREG);
        kernel_segtable_store = (u_int *)p;
        p += (SRMMU_L2SIZE * sizeof(u_int)) * NKREG;
+       DPRINTF(PDB_INITLOUD, "L2 pages p=%lx", p);
 
        p = (vaddr_t) roundup(p, SRMMU_L3SIZE * sizeof(u_int));
+       DPRINTF(PDB_INITLOUD, "roundup kernel_pagtable_store p=%lx", p);
        /* zero it: all will be SRMMU_TEINVALID */
        qzero((void *)p, ((SRMMU_L3SIZE * sizeof(u_int)) * NSEGRG) * NKREG);
        kernel_pagtable_store = (u_int *)p;
        p += ((SRMMU_L3SIZE * sizeof(u_int)) * NSEGRG) * NKREG;
+       DPRINTF(PDB_INITLOUD, "L3 pages p=%lx", p);
 
        /* Round to next page and mark end of pre-wired kernel space */
        p = (p + NBPG - 1) & ~PGOFSET;
+       DPRINTF(PDB_INITLOUD, "align p=%lx", p);
        pagetables_end = p;
 
 #if defined(MULTIPROCESSOR)
@@ -3712,12 +3718,14 @@
                cpuinfo_len = sz + align - PAGE_SIZE;
 
                /* Grab as much space as we need */
+               DPRINTF(PDB_INITLOUD, "cpuinfo=%lx", p);
                cpuinfo_data = (uint8_t *)p;
                p += (cpuinfo_len * sparc_ncpus);
        } else
                cpuinfo_data = (uint8_t *)CPUINFO_VA;
 #endif
 
+       DPRINTF(PDB_INITLOUD, "avail_start=%lx", p);
        avail_start = PMAP_BOOTSTRAP_VA2PA(p);
 
        /*
@@ -4204,13 +4212,13 @@
        return (va);
 }



Home | Main Index | Thread Index | Old Index