Module Name:    src
Committed By:   mrg
Date:           Sun Jan 17 01:54:37 UTC 2021

Modified Files:
        src/sys/arch/sparc/sparc: pmap.c

Log Message:
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.


To generate a diff of this commit:
cvs rdiff -u -r1.371 -r1.372 src/sys/arch/sparc/sparc/pmap.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/arch/sparc/sparc/pmap.c
diff -u src/sys/arch/sparc/sparc/pmap.c:1.371 src/sys/arch/sparc/sparc/pmap.c:1.372
--- src/sys/arch/sparc/sparc/pmap.c:1.371	Wed Jan 13 16:42:17 2021
+++ src/sys/arch/sparc/sparc/pmap.c	Sun Jan 17 01:54:37 2021
@@ -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 @@ EVCNT_ATTACH_STATIC(mmu_pagein_evcnt);
 #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 @@ EVCNT_ATTACH_STATIC(mmu_pagein_evcnt);
 #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 @@ me_alloc(struct mmuentry *mh, struct pma
 #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_alloc(struct mmuentry *mh, struct pma
 
 	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 @@ me_free(struct pmap *pm, u_int pmeg)
 
 #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 @@ region_alloc(struct mmuentry *mh, struct
 #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 @@ region_alloc(struct mmuentry *mh, struct
 		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 @@ region_free(struct pmap *pm, u_int smeg)
 {
 	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 @@ ctx_alloc(struct pmap *pm)
 #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
+	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 @@ ctx_alloc(struct pmap *pm)
 #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
+		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 @@ pv_link4_4c(struct vm_page *pg, struct p
 #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 @@ pv_unlink4m(struct vm_page *pg, struct p
 			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 @@ pv_link4m(struct vm_page *pg, struct pma
 #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 @@ pmap_bootstrap4m(void *top)
 	p = (vaddr_t)top;
 
 	p = (p + NBPG - 1) & ~PGOFSET;
+	DPRINTF(PDB_INITLOUD, "initial p=%lx", p);
 
 	/*
 	 * Initialize the kernel pmap.
@@ -3605,8 +3599,8 @@ pmap_bootstrap4m(void *top)
 #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 @@ pmap_bootstrap4m(void *top)
 
 	/* 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 @@ pmap_bootstrap4m(void *top)
 	 * 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 @@ pmap_bootstrap4m(void *top)
 	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 @@ pmap_bootstrap4m(void *top)
 	 * 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 @@ pmap_bootstrap4m(void *top)
 		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 @@ pmap_map(vaddr_t va, paddr_t pa, paddr_t
 	return (va);
 }
 
-#ifdef DEBUG
 /*
  * Check a pmap for spuriously lingering mappings
  */
 static inline void
 pmap_quiet_check(struct pmap *pm)
 {
+#ifdef DEBUG
 	int vs, vr;
 
 	if (CPU_HAS_SUNMMU) {
@@ -4300,8 +4308,8 @@ pmap_quiet_check(struct pmap *pm)
 		printf("pmap_chk: wired count %ld\n",
 		       pm->pm_stats.wired_count);
 	}
-}
 #endif /* DEBUG */
+}
 
 int
 pmap_pmap_pool_ctor(void *arg, void *object, int flags)
@@ -4392,10 +4400,7 @@ pmap_pmap_pool_dtor(void *arg, void *obj
 	union ctxinfo *c;
 	int s = splvm();	/* paranoia */
 
-#ifdef DEBUG
-	if (pmapdebug & PDB_DESTROY)
-		printf("pmap_pmap_pool_dtor(%p)\n", pm);
-#endif
+	DPRINTF(PDB_DESTROY, "pmap_pmap_pool_dtor(%p)", pm);
 
 	if ((c = pm->pm_ctx) != NULL) {
 		mutex_spin_enter(&ctx_lock);
@@ -4455,11 +4460,9 @@ pmap_create(void)
 		pm->pm_gap_end = VA_VREG(VM_MAXUSER_ADDRESS);
 	}
 
-#ifdef DEBUG
-	if (pmapdebug & PDB_CREATE)
-		printf("pmap_create[%d]: created %p\n", cpu_number(), pm);
+	DPRINTF(PDB_CREATE, "pmap_create[%d]: created %p", cpu_number(), pm);
 	pmap_quiet_check(pm);
-#endif
+
 	return (pm);
 }
 
@@ -4471,14 +4474,9 @@ void
 pmap_destroy(struct pmap *pm)
 {
 
-#ifdef DEBUG
-	if (pmapdebug & PDB_DESTROY)
-		printf("pmap_destroy[%d](%p)\n", cpu_number(), pm);
-#endif
+	DPRINTF(PDB_DESTROY, "pmap_destroy[%d](%p)", cpu_number(), pm);
 	if (atomic_dec_uint_nv(&pm->pm_refcount) == 0) {
-#ifdef DEBUG
 		pmap_quiet_check(pm);
-#endif
 		pool_cache_put(&pmap_cache, pm);
 	}
 }
@@ -4649,11 +4647,8 @@ pmap_remove(struct pmap *pm, vaddr_t va,
 	int vr, vs, s, ctx;
 	void (*rm)(struct pmap *, vaddr_t, vaddr_t, int, int);
 
-#ifdef DEBUG
-	if (pmapdebug & PDB_REMOVE)
-		printf("pmap_remove[%d](%p, 0x%lx, 0x%lx)\n",
-			cpu_number(), pm, va, endva);
-#endif
+	DPRINTF(PDB_REMOVE, "pmap_remove[%d](%p, 0x%lx, 0x%lx)",
+	    cpu_number(), pm, va, endva);
 
 	if (!CPU_HAS_SRMMU)
 		write_user_windows();
@@ -5066,6 +5061,7 @@ pmap_page_protect4_4c(struct vm_page *pg
 		printf("pmap_page_protect(0x%lx, 0x%x)\n",
 			VM_PAGE_TO_PHYS(pg), prot);
 #endif
+
 	/*
 	 * Skip unmanaged pages, or operations that do not take
 	 * away write permission.
@@ -5279,11 +5275,8 @@ pmap_changeprot4_4c(struct pmap *pm, vad
 	struct regmap *rp;
 	struct segmap *sp;
 
-#ifdef DEBUG
-	if (pmapdebug & PDB_CHANGEPROT)
-		printf("pmap_changeprot(%p, 0x%lx, 0x%x, 0x%x)\n",
-		    pm, va, prot, flags);
-#endif
+	DPRINTF(PDB_CHANGEPROT, "pmap_changeprot(%p, 0x%lx, 0x%x, 0x%x)",
+	    pm, va, prot, flags);
 
 	if (pm == pmap_kernel())
 		newprot = prot & VM_PROT_WRITE ? PG_S|PG_W : PG_S;
@@ -5476,13 +5469,10 @@ pmap_protect4m(struct pmap *pm, vaddr_t 
 		return;
 	}
 
-#ifdef DEBUG
-	if (pmapdebug & PDB_CHANGEPROT)
-		printf("pmap_protect[%d][curpid %d, ctx %d,%d](%lx, %lx, %x)\n",
-			cpu_number(), curproc->p_pid,
-			getcontext4m(), pm->pm_ctx ? pm->pm_ctxnum : -1,
-			sva, eva, prot);
-#endif
+	DPRINTF(PDB_CHANGEPROT,
+	    "pmap_protect[%d][curpid %d, ctx %d,%d](%lx, %lx, %x)",
+	    cpu_number(), curproc->p_pid, getcontext4m(),
+	    pm->pm_ctx ? pm->pm_ctxnum : -1, sva, eva, prot);
 
 	newprot = pte_prot4m(pm, prot);
 
@@ -5554,11 +5544,8 @@ pmap_changeprot4m(struct pmap *pm, vaddr
 	struct segmap *sp;
 	bool owired;
 
-#ifdef DEBUG
-	if (pmapdebug & PDB_CHANGEPROT)
-		printf("pmap_changeprot[%d](%p, 0x%lx, 0x%x, 0x%x)\n",
-		    cpu_number(), pm, va, prot, flags);
-#endif
+	DPRINTF(PDB_CHANGEPROT, "pmap_changeprot[%d](%p, 0x%lx, 0x%x, 0x%x)",
+	    cpu_number(), pm, va, prot, flags);
 
 	newprot = pte_prot4m(pm, prot);
 
@@ -5629,11 +5616,8 @@ pmap_enter4_4c(struct pmap *pm, vaddr_t 
 		return 0;
 	}
 
-#ifdef DEBUG
-	if (pmapdebug & PDB_ENTER)
-		printf("pmap_enter(%p, 0x%lx, 0x%lx, 0x%x, 0x%x)\n",
-		    pm, va, pa, prot, flags);
-#endif
+	DPRINTF(PDB_ENTER, "pmap_enter(%p, 0x%lx, 0x%lx, 0x%x, 0x%x)",
+	    pm, va, pa, prot, flags);
 
 	pg = PHYS_TO_VM_PAGE(pa);
 	pteproto = PG_V | PMAP_T2PTE_4(pa);
@@ -6077,10 +6061,7 @@ pmap_kremove4_4c(vaddr_t va, vsize_t len
 	int vr, vs, s, ctx;
 
 	endva = va + len;
-#ifdef DEBUG
-	if (pmapdebug & PDB_REMOVE)
-		printf("pmap_kremove(0x%lx, 0x%lx)\n", va, endva);
-#endif
+	DPRINTF(PDB_REMOVE, "pmap_kremove(0x%lx, 0x%lx)", va, endva);
 
 	write_user_windows();
 
@@ -6226,14 +6207,11 @@ pmap_enter4m(struct pmap *pm, vaddr_t va
 	int pteproto;
 	int error;
 
-#ifdef DEBUG
-	if (pmapdebug & PDB_ENTER)
-		printf("pmap_enter[curcpu %d, curpid %d, ctx %d,%d]"
-			"(%p, 0x%lx, 0x%lx, 0x%x, 0x%x)\n",
-			cpu_number(), curproc==NULL ? -1 : curproc->p_pid,
-			getcontext4m(), pm->pm_ctx==NULL ? -1 : pm->pm_ctxnum,
-			pm, va, pa, prot, flags);
-#endif
+	DPRINTF(PDB_ENTER, "pmap_enter[curcpu %d, curpid %d, ctx %d,%d]"
+	    "(%p, 0x%lx, 0x%lx, 0x%x, 0x%x)",
+	    cpu_number(), curproc == NULL ? -1 : curproc->p_pid,
+	    getcontext4m(), pm->pm_ctx == NULL ? -1 : pm->pm_ctxnum,
+	    pm, va, pa, prot, flags);
 
 	pg = PHYS_TO_VM_PAGE(pa);
 
@@ -6494,13 +6472,12 @@ pmap_enu4m(struct pmap *pm, vaddr_t va, 
 			 * If old pa was managed, remove from pvlist.
 			 * If old page was cached, flush cache.
 			 */
-#ifdef DEBUG
-			if (pmapdebug & PDB_SWITCHMAP)
-				printf("%s[%d]: pmap_enu: changing existing "
-					"va 0x%x: pte 0x%x=>0x%x\n",
-					curproc->p_comm, curproc->p_pid,
-					(int)va, tpte, pteproto);
-#endif
+			DPRINTF(PDB_SWITCHMAP,
+			    "%s[%d]: pmap_enu: changing existing "
+			    "va 0x%x: pte 0x%x=>0x%x",
+			    curproc->p_comm, curproc->p_pid,
+			    (int)va, tpte, pteproto);
+
 			if ((tpte & SRMMU_PGTYPE) == PG_SUN4M_OBMEM) {
 				struct vm_page *opg;
 				if ((opg = pvhead4m(tpte)) != NULL) {
@@ -6761,28 +6738,19 @@ pmap_extract4_4c(struct pmap *pm, vaddr_
 	vs = VA_VSEG(va);
 	rp = &pm->pm_regmap[vr];
 	if (rp->rg_segmap == NULL) {
-#ifdef DEBUG
-		if (pmapdebug & PDB_FOLLOW)
-			printf("pmap_extract: invalid segment (%d)\n", vr);
-#endif
+		DPRINTF(PDB_FOLLOW, "pmap_extract: invalid segment (%d)", vr);
 		return (false);
 	}
 	sp = &rp->rg_segmap[vs];
 	ptep = sp->sg_pte;
 	if (ptep == NULL) {
-#ifdef DEBUG
-		if (pmapdebug & PDB_FOLLOW)
-			printf("pmap_extract: invalid segment\n");
-#endif
+		DPRINTF(PDB_FOLLOW, "pmap_extract: invalid segment");
 		return (false);
 	}
 	pte = ptep[VA_VPG(va)];
 
 	if ((pte & PG_V) == 0) {
-#ifdef DEBUG
-		if (pmapdebug & PDB_FOLLOW)
-			printf("pmap_extract: invalid pte\n");
-#endif
+		DPRINTF(PDB_FOLLOW, "pmap_extract: invalid pte");
 		return (false);
 	}
 	pte &= PG_PFNUM;
@@ -6821,29 +6789,20 @@ pmap_extract4m(struct pmap *pm, vaddr_t 
 
 	rp = &pm->pm_regmap[vr];
 	if (rp->rg_segmap == NULL) {
-#ifdef DEBUG
-		if (pmapdebug & PDB_FOLLOW)
-			printf("pmap_extract: no segmap\n");
-#endif
+		DPRINTF(PDB_FOLLOW, "pmap_extract: no segmap");
 		goto out;
 	}
 
 	sp = &rp->rg_segmap[vs];
 	if (sp->sg_pte == NULL) {
-#ifdef DEBUG
-		if (pmapdebug & PDB_FOLLOW)
-			printf("pmap_extract: no ptes\n");
-#endif
+		DPRINTF(PDB_FOLLOW, "pmap_extract: no ptes");
 		goto out;
 	}
 
 	pte = sp->sg_pte[VA_SUN4M_VPG(va)];
 	if ((pte & SRMMU_TETYPE) != SRMMU_TEPTE) {
-#ifdef DEBUG
-		if (pmapdebug & PDB_FOLLOW)
-			printf("pmap_extract: invalid pte of type %d\n",
-			       pte & SRMMU_TETYPE);
-#endif
+		DPRINTF(PDB_FOLLOW, "pmap_extract: invalid pte of type %d",
+		    pte & SRMMU_TETYPE);
 		/*
 		 * We can read a spurious invalid pte if the system is in
 		 * the middle of the PTE update protocol. So, acquire the

Reply via email to