Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/sys/uvm clean up DIAGNOSTIC checks, use KASSERT().
details: https://anonhg.NetBSD.org/src/rev/6492a8873649
branches: trunk
changeset: 503954:6492a8873649
user: chs <chs%NetBSD.org@localhost>
date: Sun Feb 18 21:19:08 2001 +0000
description:
clean up DIAGNOSTIC checks, use KASSERT().
diffstat:
sys/uvm/uvm_amap.c | 14 +++-----------
sys/uvm/uvm_amap.h | 13 ++++---------
sys/uvm/uvm_anon.c | 9 +--------
sys/uvm/uvm_aobj.c | 36 +++++++-----------------------------
sys/uvm/uvm_fault.c | 20 ++++++--------------
sys/uvm/uvm_map.h | 7 ++-----
sys/uvm/uvm_mmap.c | 21 +++++----------------
sys/uvm/uvm_pglist.c | 18 +++++-------------
sys/uvm/uvm_swap.c | 42 +++++++++---------------------------------
9 files changed, 42 insertions(+), 138 deletions(-)
diffs (truncated from 417 to 300 lines):
diff -r 7a48c4fd967c -r 6492a8873649 sys/uvm/uvm_amap.c
--- a/sys/uvm/uvm_amap.c Sun Feb 18 21:02:54 2001 +0000
+++ b/sys/uvm/uvm_amap.c Sun Feb 18 21:19:08 2001 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: uvm_amap.c,v 1.29 2001/01/23 02:27:39 thorpej Exp $ */
+/* $NetBSD: uvm_amap.c,v 1.30 2001/02/18 21:19:09 chs Exp $ */
/*
*
@@ -255,11 +255,7 @@
{
UVMHIST_FUNC("amap_free"); UVMHIST_CALLED(maphist);
-#ifdef DIAGNOSTIC
- if (amap->am_ref || amap->am_nused)
- panic("amap_free");
-#endif
-
+ KASSERT(amap->am_ref == 0 && amap->am_nused == 0);
LOCK_ASSERT(simple_lock_held(&amap->am_l));
free(amap->am_slots, M_UVMAMAP);
@@ -384,11 +380,7 @@
newover = malloc(slotneed * sizeof(struct vm_anon *),
M_UVMAMAP, M_WAITOK);
amap_lock(amap); /* re-lock! */
-
-#ifdef DIAGNOSTIC
- if (amap->am_maxslot >= slotneed)
- panic("amap_extend: amap changed during malloc");
-#endif
+ KASSERT(amap->am_maxslot < slotneed);
/*
* now copy everything over to new malloc'd areas...
diff -r 7a48c4fd967c -r 6492a8873649 sys/uvm/uvm_amap.h
--- a/sys/uvm/uvm_amap.h Sun Feb 18 21:02:54 2001 +0000
+++ b/sys/uvm/uvm_amap.h Sun Feb 18 21:19:08 2001 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: uvm_amap.h,v 1.13 2000/11/25 06:27:59 chs Exp $ */
+/* $NetBSD: uvm_amap.h,v 1.14 2001/02/18 21:19:08 chs Exp $ */
/*
*
@@ -247,15 +247,10 @@
*/
/* AMAP_B2SLOT: convert byte offset to slot */
-#ifdef DIAGNOSTIC
-#define AMAP_B2SLOT(S,B) { \
- if ((B) & (PAGE_SIZE - 1)) \
- panic("AMAP_B2SLOT: invalid byte count"); \
- (S) = (B) >> PAGE_SHIFT; \
+#define AMAP_B2SLOT(S,B) { \
+ KASSERT(((B) & (PAGE_SIZE - 1)) == 0); \
+ (S) = (B) >> PAGE_SHIFT; \
}
-#else
-#define AMAP_B2SLOT(S,B) (S) = (B) >> PAGE_SHIFT
-#endif
/*
* lock/unlock/refs/flags macros
diff -r 7a48c4fd967c -r 6492a8873649 sys/uvm/uvm_anon.c
--- a/sys/uvm/uvm_anon.c Sun Feb 18 21:02:54 2001 +0000
+++ b/sys/uvm/uvm_anon.c Sun Feb 18 21:19:08 2001 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: uvm_anon.c,v 1.14 2001/01/28 23:30:42 thorpej Exp $ */
+/* $NetBSD: uvm_anon.c,v 1.15 2001/02/18 21:19:08 chs Exp $ */
/*
*
@@ -501,13 +501,6 @@
*/
return FALSE;
-
- default:
-#ifdef DIAGNOSTIC
- panic("anon_pagein: uvmfault_anonget -> %d", rv);
-#else
- return FALSE;
-#endif
}
/*
diff -r 7a48c4fd967c -r 6492a8873649 sys/uvm/uvm_aobj.c
--- a/sys/uvm/uvm_aobj.c Sun Feb 18 21:02:54 2001 +0000
+++ b/sys/uvm/uvm_aobj.c Sun Feb 18 21:19:08 2001 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: uvm_aobj.c,v 1.38 2001/01/28 23:30:42 thorpej Exp $ */
+/* $NetBSD: uvm_aobj.c,v 1.39 2001/02/18 21:19:08 chs Exp $ */
/*
* Copyright (c) 1998 Chuck Silvers, Charles D. Cranor and
@@ -338,18 +338,17 @@
*/
if (UAO_USES_SWHASH(aobj)) {
+
/*
* Avoid allocating an entry just to free it again if
* the page had not swap slot in the first place, and
* we are freeing.
*/
+
struct uao_swhash_elt *elt =
uao_find_swhash_elt(aobj, pageidx, slot ? TRUE : FALSE);
if (elt == NULL) {
-#ifdef DIAGNOSTIC
- if (slot)
- panic("uao_set_swslot: didn't create elt");
-#endif
+ KASSERT(slot == 0);
return (0);
}
@@ -920,9 +919,6 @@
default:
panic("uao_flush: weird flags");
}
-#ifdef DIAGNOSTIC
- panic("uao_flush: unreachable code");
-#endif
}
uvm_unlock_pageq();
@@ -1261,10 +1257,7 @@
{
struct uvm_aobj *aobj = (struct uvm_aobj *) pg->uobject;
-#ifdef DIAGNOSTIC
- if ((pg->flags & PG_RELEASED) == 0)
- panic("uao_releasepg: page not released!");
-#endif
+ KASSERT(pg->flags & PG_RELEASED);
/*
* dispose of the page [caller handles PG_WANTED] and swap slot.
@@ -1291,10 +1284,7 @@
if (aobj->u_obj.uo_npages != 0)
return TRUE;
-#ifdef DIAGNOSTIC
- if (TAILQ_FIRST(&aobj->u_obj.memq))
- panic("uvn_releasepg: pages in object with npages == 0");
-#endif
+ KASSERT(TAILQ_EMPTY(&aobj->u_obj.memq));
/*
* finally, free the rest.
@@ -1513,20 +1503,8 @@
*/
return FALSE;
-#ifdef DIAGNOSTIC
- default:
- panic("uao_pagein_page: uao_get -> %d\n", rv);
-#endif
}
-
-#ifdef DIAGNOSTIC
- /*
- * this should never happen, since we have a reference on the aobj.
- */
- if (pg->flags & PG_RELEASED) {
- panic("uao_pagein_page: found PG_RELEASED page?\n");
- }
-#endif
+ KASSERT((pg->flags & PG_RELEASED) == 0);
/*
* ok, we've got the page now.
diff -r 7a48c4fd967c -r 6492a8873649 sys/uvm/uvm_fault.c
--- a/sys/uvm/uvm_fault.c Sun Feb 18 21:02:54 2001 +0000
+++ b/sys/uvm/uvm_fault.c Sun Feb 18 21:19:08 2001 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: uvm_fault.c,v 1.55 2001/01/28 23:30:43 thorpej Exp $ */
+/* $NetBSD: uvm_fault.c,v 1.56 2001/02/18 21:19:08 chs Exp $ */
/*
*
@@ -1870,10 +1870,7 @@
/*
* find the beginning map entry for the region.
*/
-#ifdef DIAGNOSTIC
- if (start < vm_map_min(map) || end > vm_map_max(map))
- panic("uvm_fault_unwire_locked: address out of range");
-#endif
+ KASSERT(start >= vm_map_min(map) && end <= vm_map_max(map));
if (uvm_map_lookup_entry(map, start, &entry) == FALSE)
panic("uvm_fault_unwire_locked: address not in map");
@@ -1886,16 +1883,11 @@
* make sure the current entry is for the address we're
* dealing with. if not, grab the next entry.
*/
-#ifdef DIAGNOSTIC
- if (va < entry->start)
- panic("uvm_fault_unwire_locked: hole 1");
-#endif
+
+ KASSERT(va >= entry->start);
if (va >= entry->end) {
-#ifdef DIAGNOSTIC
- if (entry->next == &map->header ||
- entry->next->start > entry->end)
- panic("uvm_fault_unwire_locked: hole 2");
-#endif
+ KASSERT(entry->next != &map->header &&
+ entry->next->start <= entry->end);
entry = entry->next;
}
diff -r 7a48c4fd967c -r 6492a8873649 sys/uvm/uvm_map.h
--- a/sys/uvm/uvm_map.h Sun Feb 18 21:02:54 2001 +0000
+++ b/sys/uvm/uvm_map.h Sun Feb 18 21:19:08 2001 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: uvm_map.h,v 1.23 2000/12/13 08:06:12 enami Exp $ */
+/* $NetBSD: uvm_map.h,v 1.24 2001/02/18 21:19:08 chs Exp $ */
/*
* Copyright (c) 1997 Charles D. Cranor and Washington University.
@@ -433,10 +433,7 @@
&map->flags_lock);
if (error) {
-#ifdef DIAGNOSTIC
- if (error != ENOLCK)
- panic("vm_map_lock: failed to get lock");
-#endif
+ KASSERT(error == ENOLCK);
goto try_again;
}
diff -r 7a48c4fd967c -r 6492a8873649 sys/uvm/uvm_mmap.c
--- a/sys/uvm/uvm_mmap.c Sun Feb 18 21:02:54 2001 +0000
+++ b/sys/uvm/uvm_mmap.c Sun Feb 18 21:19:08 2001 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: uvm_mmap.c,v 1.48 2001/01/08 01:35:03 thorpej Exp $ */
+/* $NetBSD: uvm_mmap.c,v 1.49 2001/02/18 21:19:08 chs Exp $ */
/*
* Copyright (c) 1997 Charles D. Cranor and Washington University.
@@ -176,12 +176,9 @@
for (/* nothing */;
entry != &map->header && entry->start < end;
entry = entry->next) {
-#ifdef DIAGNOSTIC
- if (UVM_ET_ISSUBMAP(entry))
- panic("mincore: user map has submap");
- if (start < entry->start)
- panic("mincore: hole");
-#endif
+ KASSERT(!UVM_ET_ISSUBMAP(entry));
+ KASSERT(start >= entry->start);
+
/* Make sure there are no holes. */
if (entry->end < end &&
(entry->next == &map->header ||
@@ -197,10 +194,7 @@
* are always considered resident (mapped devices).
*/
if (UVM_ET_ISOBJ(entry)) {
-#ifdef DIAGNOSTIC
- if (UVM_OBJ_IS_KERN_OBJECT(entry->object.uvm_obj))
- panic("mincore: user map has kernel object");
-#endif
+ KASSERT(!UVM_OBJ_IS_KERN_OBJECT(entry->object.uvm_obj));
if (entry->object.uvm_obj->pgops->pgo_releasepg
== NULL) {
for (/* nothing */; start < lim;
@@ -416,11 +410,6 @@
* so just change it to MAP_SHARED.
*/
if (vp->v_type == VCHR && (flags & MAP_PRIVATE) != 0) {
-#if defined(DIAGNOSTIC)
- printf("WARNING: converted MAP_PRIVATE device mapping "
- "to MAP_SHARED (pid %d comm %s)\n", p->p_pid,
- p->p_comm);
-#endif
flags = (flags & ~MAP_PRIVATE) | MAP_SHARED;
}
diff -r 7a48c4fd967c -r 6492a8873649 sys/uvm/uvm_pglist.c
--- a/sys/uvm/uvm_pglist.c Sun Feb 18 21:02:54 2001 +0000
+++ b/sys/uvm/uvm_pglist.c Sun Feb 18 21:19:08 2001 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: uvm_pglist.c,v 1.12 2000/11/25 06:28:00 chs Exp $ */
+/* $NetBSD: uvm_pglist.c,v 1.13 2001/02/18 21:19:08 chs Exp $ */
/*-
* Copyright (c) 1997 The NetBSD Foundation, Inc.
@@ -98,13 +98,8 @@
vm_page_t tp;
#endif
-#ifdef DIAGNOSTIC
- if ((alignment & (alignment - 1)) != 0)
Home |
Main Index |
Thread Index |
Old Index