Source-Changes-HG archive

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

[src/trunk]: src/sys/dev/raidframe Those of us who might be interested in deb...



details:   https://anonhg.NetBSD.org/src/rev/da72dc528afd
branches:  trunk
changeset: 536489:da72dc528afd
user:      oster <oster%NetBSD.org@localhost>
date:      Mon Sep 16 23:40:57 2002 +0000

description:
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:

 sys/dev/raidframe/rf_debugMem.c |  21 ++++++++++++++++-----
 sys/dev/raidframe/rf_debugMem.h |  21 ++++++++++++++++++++-
 sys/dev/raidframe/rf_driver.c   |   6 ++++--
 3 files changed, 40 insertions(+), 8 deletions(-)

diffs (157 lines):

diff -r b659ba82265b -r da72dc528afd sys/dev/raidframe/rf_debugMem.c
--- a/sys/dev/raidframe/rf_debugMem.c   Mon Sep 16 23:37:18 2002 +0000
+++ b/sys/dev/raidframe/rf_debugMem.c   Mon Sep 16 23:40:57 2002 +0000
@@ -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 @@
 #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 @@
 };
 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 @@
                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 @@
                        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 @@
        p->allocated = 0;
        return (p->size);
 }
+#endif /* RF_DEBUG_MEM */
+
+
diff -r b659ba82265b -r da72dc528afd sys/dev/raidframe/rf_debugMem.h
--- a/sys/dev/raidframe/rf_debugMem.h   Mon Sep 16 23:37:18 2002 +0000
+++ b/sys/dev/raidframe/rf_debugMem.h   Mon Sep 16 23:40:57 2002 +0000
@@ -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 -r b659ba82265b -r da72dc528afd sys/dev/raidframe/rf_driver.c
--- a/sys/dev/raidframe/rf_driver.c     Mon Sep 16 23:37:18 2002 +0000
+++ b/sys/dev/raidframe/rf_driver.c     Mon Sep 16 23:40:57 2002 +0000
@@ -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 @@
                 * 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);
 }



Home | Main Index | Thread Index | Old Index