summaryrefslogtreecommitdiff
path: root/sys/dev/raidframe
diff options
context:
space:
mode:
authoroster <oster@NetBSD.org>2002-09-16 23:40:57 +0000
committeroster <oster@NetBSD.org>2002-09-16 23:40:57 +0000
commite8ffb40a0e701984ecbe1b1b3a9a932eeab95898 (patch)
tree796a5e60976cff9cfd62b9d75127747587e6f2f3 /sys/dev/raidframe
parent763ac2f8fec7b90e20844894183f46a2b526c094 (diff)
Those of us who might be interested in debugging internal memory usage
of RAIDframe can use RF_DEBUG_MEM. I suspsect the rest of the world would rather use that 14K of kernel memory for something else.
Diffstat (limited to 'sys/dev/raidframe')
-rw-r--r--sys/dev/raidframe/rf_debugMem.c21
-rw-r--r--sys/dev/raidframe/rf_debugMem.h21
-rw-r--r--sys/dev/raidframe/rf_driver.c6
3 files changed, 40 insertions, 8 deletions
diff --git a/sys/dev/raidframe/rf_debugMem.c b/sys/dev/raidframe/rf_debugMem.c
index 94cc30d09cc..f3f3383f863 100644
--- a/sys/dev/raidframe/rf_debugMem.c
+++ b/sys/dev/raidframe/rf_debugMem.c
@@ -1,4 +1,4 @@
-/* $NetBSD: rf_debugMem.c,v 1.10 2002/09/14 17:53:57 oster Exp $ */
+/* $NetBSD: rf_debugMem.c,v 1.11 2002/09/16 23:40:57 oster Exp $ */
/*
* Copyright (c) 1995 Carnegie-Mellon University.
* All rights reserved.
@@ -37,7 +37,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: rf_debugMem.c,v 1.10 2002/09/14 17:53:57 oster Exp $");
+__KERNEL_RCSID(0, "$NetBSD: rf_debugMem.c,v 1.11 2002/09/16 23:40:57 oster Exp $");
#include <dev/raidframe/raidframevar.h>
@@ -46,6 +46,8 @@ __KERNEL_RCSID(0, "$NetBSD: rf_debugMem.c,v 1.10 2002/09/14 17:53:57 oster Exp $
#include "rf_debugMem.h"
#include "rf_general.h"
+#if RF_DEBUG_MEM
+
static long tot_mem_in_use = 0;
/* Hash table of information about memory allocations */
@@ -61,10 +63,10 @@ struct mh_struct {
};
static struct mh_struct *mh_table[RF_MH_TABLESIZE];
RF_DECLARE_MUTEX(rf_debug_mem_mutex)
- static int mh_table_initialized = 0;
+static int mh_table_initialized = 0;
- static void memory_hash_insert(void *addr, int size, int line, char *filen);
- static int memory_hash_remove(void *addr, int sz);
+static void memory_hash_insert(void *addr, int size, int line, char *filen);
+static int memory_hash_remove(void *addr, int sz);
void
rf_record_malloc(p, size, line, filen)
@@ -120,11 +122,13 @@ rf_print_unfreed()
printf("%ld total bytes in use\n", tot_mem_in_use);
}
}
+#endif /* RF_DEBUG_MEM */
int
rf_ConfigureDebugMem(listp)
RF_ShutdownList_t **listp;
{
+#if RF_DEBUG_MEM
int i, rc;
rc = rf_create_managed_mutex(listp, &rf_debug_mem_mutex);
@@ -137,8 +141,12 @@ rf_ConfigureDebugMem(listp)
mh_table[i] = NULL;
mh_table_initialized = 1;
}
+#endif
return (0);
}
+
+#if RF_DEBUG_MEM
+
#define HASHADDR(_a_) ( (((unsigned long) _a_)>>3) % RF_MH_TABLESIZE )
static void
@@ -200,3 +208,6 @@ memory_hash_remove(addr, sz)
p->allocated = 0;
return (p->size);
}
+#endif /* RF_DEBUG_MEM */
+
+
diff --git a/sys/dev/raidframe/rf_debugMem.h b/sys/dev/raidframe/rf_debugMem.h
index eed40d7fec4..b3d55b1beaa 100644
--- a/sys/dev/raidframe/rf_debugMem.h
+++ b/sys/dev/raidframe/rf_debugMem.h
@@ -1,4 +1,4 @@
-/* $NetBSD: rf_debugMem.h,v 1.9 2001/10/04 15:58:52 oster Exp $ */
+/* $NetBSD: rf_debugMem.h,v 1.10 2002/09/16 23:40:57 oster Exp $ */
/*
* Copyright (c) 1995 Carnegie-Mellon University.
* All rights reserved.
@@ -42,12 +42,24 @@
#include <sys/types.h>
#include <sys/malloc.h>
+#ifndef RF_DEBUG_MEM
+#define RF_DEBUG_MEM 0
+#endif
+
+#if RF_DEBUG_MEM
#define RF_Malloc(_p_, _size_, _cast_) \
{ \
_p_ = _cast_ malloc((u_long)_size_, M_RAIDFRAME, M_WAITOK); \
memset((char *)_p_, 0, _size_); \
if (rf_memDebug) rf_record_malloc(_p_, _size_, __LINE__, __FILE__); \
}
+#else
+#define RF_Malloc(_p_, _size_, _cast_) \
+ { \
+ _p_ = _cast_ malloc((u_long)_size_, M_RAIDFRAME, M_WAITOK); \
+ memset((char *)_p_, 0, _size_); \
+ }
+#endif
#define RF_MallocAndAdd(__p_, __size_, __cast_, __alist_) \
{ \
@@ -66,11 +78,18 @@
if (__alist) rf_AddToAllocList(__alist, __p, (__nel)*(__elsz)); \
}
+#if RF_DEBUG_MEM
#define RF_Free(_p_, _sz_) \
{ \
free((void *)(_p_), M_RAIDFRAME); \
if (rf_memDebug) rf_unrecord_malloc(_p_, (u_int32_t) (_sz_)); \
}
+#else
+#define RF_Free(_p_, _sz_) \
+ { \
+ free((void *)(_p_), M_RAIDFRAME); \
+ }
+#endif
void rf_record_malloc(void *p, int size, int line, char *filen);
void rf_unrecord_malloc(void *p, int sz);
diff --git a/sys/dev/raidframe/rf_driver.c b/sys/dev/raidframe/rf_driver.c
index cabc0870bc7..29177bd9f93 100644
--- a/sys/dev/raidframe/rf_driver.c
+++ b/sys/dev/raidframe/rf_driver.c
@@ -1,4 +1,4 @@
-/* $NetBSD: rf_driver.c,v 1.59 2002/09/15 19:25:07 oster Exp $ */
+/* $NetBSD: rf_driver.c,v 1.60 2002/09/16 23:40:57 oster Exp $ */
/*-
* Copyright (c) 1999 The NetBSD Foundation, Inc.
* All rights reserved.
@@ -73,7 +73,7 @@
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: rf_driver.c,v 1.59 2002/09/15 19:25:07 oster Exp $");
+__KERNEL_RCSID(0, "$NetBSD: rf_driver.c,v 1.60 2002/09/16 23:40:57 oster Exp $");
#include <sys/param.h>
#include <sys/systm.h>
@@ -229,8 +229,10 @@ rf_UnconfigureArray()
* We must wait until now, because the AllocList module
* uses the DebugMem module.
*/
+#if RF_DEBUG_MEM
if (rf_memDebug)
rf_print_unfreed();
+#endif
}
RF_UNLOCK_LKMGR_MUTEX(configureMutex);
}