Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/sys/arch/sparc64/sparc64 reduce the #ifdef DEBUG usage by us...
details: https://anonhg.NetBSD.org/src/rev/ae508517296b
branches: trunk
changeset: 778405:ae508517296b
user: mrg <mrg%NetBSD.org@localhost>
date: Sun Mar 25 02:31:00 2012 +0000
description:
reduce the #ifdef DEBUG usage by using the optimiser.
diffstat:
sys/arch/sparc64/sparc64/pmap.c | 94 ++++++++++++++++++++--------------------
1 files changed, 46 insertions(+), 48 deletions(-)
diffs (292 lines):
diff -r 89f17ad51f10 -r ae508517296b sys/arch/sparc64/sparc64/pmap.c
--- a/sys/arch/sparc64/sparc64/pmap.c Sun Mar 25 01:56:02 2012 +0000
+++ b/sys/arch/sparc64/sparc64/pmap.c Sun Mar 25 02:31:00 2012 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: pmap.c,v 1.277 2012/03/18 23:48:00 mrg Exp $ */
+/* $NetBSD: pmap.c,v 1.278 2012/03/25 02:31:00 mrg Exp $ */
/*
*
* Copyright (C) 1996-1999 Eduardo Horvath.
@@ -26,7 +26,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: pmap.c,v 1.277 2012/03/18 23:48:00 mrg Exp $");
+__KERNEL_RCSID(0, "$NetBSD: pmap.c,v 1.278 2012/03/25 02:31:00 mrg Exp $");
#undef NO_VCACHE /* Don't forget the locked TLB in dostart */
#define HWREF
@@ -260,7 +260,34 @@
struct prom_map *prom_map;
int prom_map_size;
-#ifdef DEBUG
+#define PDB_CREATE 0x000001
+#define PDB_DESTROY 0x000002
+#define PDB_REMOVE 0x000004
+#define PDB_CHANGEPROT 0x000008
+#define PDB_ENTER 0x000010
+#define PDB_DEMAP 0x000020 /* used in locore */
+#define PDB_REF 0x000040
+#define PDB_COPY 0x000080
+#define PDB_MMU_ALLOC 0x000100
+#define PDB_MMU_STEAL 0x000200
+#define PDB_CTX_ALLOC 0x000400
+#define PDB_CTX_STEAL 0x000800
+#define PDB_MMUREG_ALLOC 0x001000
+#define PDB_MMUREG_STEAL 0x002000
+#define PDB_CACHESTUFF 0x004000
+#define PDB_ALIAS 0x008000
+#define PDB_EXTRACT 0x010000
+#define PDB_BOOT 0x020000
+#define PDB_BOOT1 0x040000
+#define PDB_GROW 0x080000
+#define PDB_CTX_FLUSHALL 0x100000
+#define PDB_ACTIVATE 0x200000
+
+#if defined(DEBUG) && !defined(PMAP_DEBUG)
+#define PMAP_DEBUG
+#endif
+
+#ifdef PMAP_DEBUG
struct {
int kernel; /* entering kernel mapping */
int user; /* entering user mapping */
@@ -288,28 +315,8 @@
#define ENTER_STAT(x) do { enter_stats.x ++; } while (0)
#define REMOVE_STAT(x) do { remove_stats.x ++; } while (0)
-#define PDB_CREATE 0x000001
-#define PDB_DESTROY 0x000002
-#define PDB_REMOVE 0x000004
-#define PDB_CHANGEPROT 0x000008
-#define PDB_ENTER 0x000010
-#define PDB_DEMAP 0x000020 /* used in locore */
-#define PDB_REF 0x000040
-#define PDB_COPY 0x000080
-#define PDB_MMU_ALLOC 0x000100
-#define PDB_MMU_STEAL 0x000200
-#define PDB_CTX_ALLOC 0x000400
-#define PDB_CTX_STEAL 0x000800
-#define PDB_MMUREG_ALLOC 0x001000
-#define PDB_MMUREG_STEAL 0x002000
-#define PDB_CACHESTUFF 0x004000
-#define PDB_ALIAS 0x008000
-#define PDB_EXTRACT 0x010000
-#define PDB_BOOT 0x020000
-#define PDB_BOOT1 0x040000
-#define PDB_GROW 0x080000
-#define PDB_CTX_FLUSHALL 0x100000
int pmapdebug = 0;
+//int pmapdebug = 0 | PDB_CTX_ALLOC | PDB_ACTIVATE;
/* Number of H/W pages stolen for page tables */
int pmap_pages_stolen = 0;
@@ -320,6 +327,7 @@
#define REMOVE_STAT(x) do { /* nothing */ } while (0)
#define BDPRINTF(n, f)
#define DPRINTF(n, f)
+#define pmapdebug 0
#endif
#define pv_check()
@@ -420,10 +428,8 @@
BDPRINTF(PDB_BOOT1,
("pseg_set: pm=%p va=%p data=%lx newp %lx\n",
pmap_kernel(), va, (long)data, (long)newp));
-#ifdef DEBUG
if (pmapdebug & PDB_BOOT1)
{int i; for (i=0; i<140000000; i++) ;}
-#endif
}
}
@@ -447,6 +453,8 @@
break;
}
}
+#else
+#define pmap_bootdebug() /* nothing */
#endif
@@ -711,10 +719,7 @@
/* Initialize bootstrap allocator. */
kdata_alloc_init(kernelend + 1 * 1024 * 1024, ekdata);
-#ifdef DEBUG
pmap_bootdebug();
-#endif
-
pmap_alloc_bootargs();
pmap_mp_init();
@@ -761,7 +766,6 @@
phys_installed = prom_memlist;
phys_installed_size = prom_memlist_size / sizeof(*phys_installed);
-#ifdef DEBUG
if (pmapdebug & PDB_BOOT1) {
/* print out mem list */
prom_printf("Installed physical memory:\n");
@@ -771,7 +775,6 @@
(u_long)phys_installed[i].size);
}
}
-#endif
BDPRINTF(PDB_BOOT1, ("Calculating physmem:"));
for (i = 0; i < phys_installed_size; i++)
@@ -797,7 +800,6 @@
prom_map = prom_memlist;
prom_map_size = prom_memlist_size / sizeof(struct prom_map);
-#ifdef DEBUG
if (pmapdebug & PDB_BOOT) {
/* print out mem list */
prom_printf("Prom xlations:\n");
@@ -809,7 +811,6 @@
}
prom_printf("End of prom xlations\n");
}
-#endif
/*
* Here's a quick in-lined reverse bubble sort. It gets rid of
@@ -826,7 +827,6 @@
}
}
}
-#ifdef DEBUG
if (pmapdebug & PDB_BOOT) {
/* print out mem list */
prom_printf("Prom xlations:\n");
@@ -838,7 +838,6 @@
}
prom_printf("End of prom xlations\n");
}
-#endif
/*
* Allocate a ncpu*64KB page for the cpu_info & stack structure now.
@@ -875,7 +874,6 @@
(u_long)ektext, (u_long)ektextp,
(u_long)kdata, (u_long)kdatap,
(u_long)ekdata, (u_long)ekdatap));
-#ifdef DEBUG
if (pmapdebug & PDB_BOOT1) {
/* print out mem list */
prom_printf("Available %lx physical memory before cleanup:\n",
@@ -891,7 +889,7 @@
prom_printf("kernel physical data size %08lx - %08lx\n",
(u_long)kdatap, (u_long)ekdatap);
}
-#endif
+
/*
* Here's a another quick in-lined bubble sort.
*/
@@ -983,7 +981,6 @@
VM_FREELIST_DEFAULT);
}
-#ifdef DEBUG
if (pmapdebug & PDB_BOOT) {
/* print out mem list */
prom_printf("Available physical memory after cleanup:\n");
@@ -993,7 +990,7 @@
}
prom_printf("End of available physical memory after cleanup\n");
}
-#endif
+
/*
* Allocate and clear out pmap_kernel()->pm_segs[]
*/
@@ -1016,12 +1013,10 @@
/*
* Tell pmap about our mesgbuf -- Hope this works already
*/
-#ifdef DEBUG
BDPRINTF(PDB_BOOT1, ("Calling consinit()\n"));
if (pmapdebug & PDB_BOOT1)
consinit();
BDPRINTF(PDB_BOOT1, ("Inserting mesgbuf into pmap_kernel()\n"));
-#endif
/* it's not safe to call pmap_enter so we need to do this ourselves */
va = (vaddr_t)msgbufp;
prom_map_phys(phys_msgbuf, msgbufsiz, (vaddr_t)msgbufp, -1);
@@ -1056,9 +1051,7 @@
prom_map[i].vsize)
break;
}
-#ifdef DEBUG
page_size_map[k].use++;
-#endif
/* Enter PROM map into pmap_kernel() */
pmap_enter_kpage(prom_map[i].vstart + j,
(prom_map[i].tte + j) | TLB_EXEC |
@@ -1529,6 +1522,9 @@
if (pmap_ctx(pmap) == 0) {
(void) ctx_alloc(pmap);
}
+ DPRINTF(PDB_ACTIVATE,
+ ("%s: cpu%d activating ctx %d\n", __func__,
+ cpu_number(), pmap_ctx(pmap)));
dmmu_set_secondary_context(pmap_ctx(pmap));
}
@@ -1538,6 +1534,10 @@
void
pmap_deactivate(struct lwp *l)
{
+
+ DPRINTF(PDB_ACTIVATE,
+ ("%s: cpu%d deactivating ctx %d\n", __func__,
+ cpu_number(), pmap_ctx(l->l_proc->p_vmspace->vm_map.pmap)));
}
/*
@@ -1595,7 +1595,7 @@
(long long)ptp);
pmap_free_page_noflush(ptp);
}
-#ifdef DEBUG
+#ifdef PMAP_DEBUG
i = ptelookup_va(va);
if (pmapdebug & PDB_ENTER)
prom_printf("pmap_kenter_pa: va=%08x data=%08x:%08x "
@@ -1873,7 +1873,7 @@
}
mutex_exit(&pmap_lock);
-#ifdef DEBUG
+#ifdef PMAP_DEBUG
i = ptelookup_va(va);
if (pmapdebug & PDB_ENTER)
prom_printf("pmap_enter: va=%08x data=%08x:%08x "
@@ -2125,7 +2125,7 @@
sva = trunc_page(sva);
mutex_enter(&pmap_lock);
for (; sva < eva; sva += PAGE_SIZE) {
-#ifdef DEBUG
+#ifdef PMAP_DEBUG
/*
* Is this part of the permanent 4MB mapping?
*/
@@ -2222,7 +2222,6 @@
} else {
data = pseg_get(pm, va);
pa = data & TLB_PA_MASK;
-#ifdef DEBUG
if (pmapdebug & PDB_EXTRACT) {
paddr_t npa = ldxa((vaddr_t)&pm->pm_segs[va_to_seg(va)],
ASI_PHYS_CACHED);
@@ -2250,7 +2249,6 @@
}
printf(" pseg_get: %lx\n", (long)pa);
}
-#endif
}
if ((data & TLB_V) == 0)
return (FALSE);
Home |
Main Index |
Thread Index |
Old Index