Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/sys/dev/raidframe convert rf_debug_mem_mutex to a kmutex, an...
details: https://anonhg.NetBSD.org/src/rev/2608278ac2af
branches: trunk
changeset: 764698:2608278ac2af
user: mrg <mrg%NetBSD.org@localhost>
date: Sun May 01 06:49:43 2011 +0000
description:
convert rf_debug_mem_mutex to a kmutex, and fix RF_DEBUG_MEM option.
diffstat:
sys/dev/raidframe/rf_debugMem.c | 34 ++++++++++++++++++++++------------
sys/dev/raidframe/rf_debugMem.h | 4 ++--
2 files changed, 24 insertions(+), 14 deletions(-)
diffs (128 lines):
diff -r 562175eff9a1 -r 2608278ac2af sys/dev/raidframe/rf_debugMem.c
--- a/sys/dev/raidframe/rf_debugMem.c Sun May 01 06:42:29 2011 +0000
+++ b/sys/dev/raidframe/rf_debugMem.c Sun May 01 06:49:43 2011 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: rf_debugMem.c,v 1.20 2009/03/18 10:22:41 cegger Exp $ */
+/* $NetBSD: rf_debugMem.c,v 1.21 2011/05/01 06:49:43 mrg Exp $ */
/*
* Copyright (c) 1995 Carnegie-Mellon University.
* All rights reserved.
@@ -32,7 +32,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: rf_debugMem.c,v 1.20 2009/03/18 10:22:41 cegger Exp $");
+__KERNEL_RCSID(0, "$NetBSD: rf_debugMem.c,v 1.21 2011/05/01 06:49:43 mrg Exp $");
#include <dev/raidframe/raidframevar.h>
@@ -40,6 +40,7 @@
#include "rf_options.h"
#include "rf_debugMem.h"
#include "rf_general.h"
+#include "rf_shutdown.h"
#if RF_DEBUG_MEM
@@ -52,26 +53,26 @@
void *address;
int size;
int line;
- char *filen;
+ const char *filen;
char allocated;
struct mh_struct *next;
};
static struct mh_struct *mh_table[RF_MH_TABLESIZE];
-RF_DECLARE_MUTEX(rf_debug_mem_mutex)
+static rf_declare_mutex2(rf_debug_mem_mutex);
static int mh_table_initialized = 0;
-static void memory_hash_insert(void *addr, int size, int line, char *filen);
+static void memory_hash_insert(void *addr, int size, int line, const char *filen);
static int memory_hash_remove(void *addr, int sz);
void
-rf_record_malloc(void *p, int size, int line, char *filen)
+rf_record_malloc(void *p, int size, int line, const char *filen)
{
RF_ASSERT(size != 0);
- /* RF_LOCK_MUTEX(rf_debug_mem_mutex); */
+ /* rf_lock_mutex2(rf_debug_mem_mutex); */
memory_hash_insert(p, size, line, filen);
tot_mem_in_use += size;
- /* RF_UNLOCK_MUTEX(rf_debug_mem_mutex); */
+ /* rf_unlock_mutex2(rf_debug_mem_mutex); */
if ((long) p == rf_memDebugAddress) {
printf("Allocate: debug address allocated from line %d file %s\n", line, filen);
}
@@ -82,10 +83,10 @@
{
int size;
- /* RF_LOCK_MUTEX(rf_debug_mem_mutex); */
+ /* rf_lock_mutex2(rf_debug_mem_mutex); */
size = memory_hash_remove(p, sz);
tot_mem_in_use -= size;
- /* RF_UNLOCK_MUTEX(rf_debug_mem_mutex); */
+ /* rf_unlock_mutex2(rf_debug_mem_mutex); */
if ((long) p == rf_memDebugAddress) {
printf("Free: Found debug address\n"); /* this is really only a
* flag line for gdb */
@@ -114,18 +115,27 @@
}
#endif /* RF_DEBUG_MEM */
+#if RF_DEBUG_MEM
+static void
+rf_ShutdownDebugMem(void *unused)
+{
+ rf_destroy_mutex2(rf_debug_mem_mutex);
+}
+#endif
+
int
rf_ConfigureDebugMem(RF_ShutdownList_t **listp)
{
#if RF_DEBUG_MEM
int i;
- rf_mutex_init(&rf_debug_mem_mutex);
+ rf_init_mutex2(rf_debug_mem_mutex, IPL_VM);
if (rf_memDebug) {
for (i = 0; i < RF_MH_TABLESIZE; i++)
mh_table[i] = NULL;
mh_table_initialized = 1;
}
+ rf_ShutdownCreate(listp, rf_ShutdownDebugMem, NULL);
#endif
return (0);
}
@@ -135,7 +145,7 @@
#define HASHADDR(_a_) ( (((unsigned long) _a_)>>3) % RF_MH_TABLESIZE )
static void
-memory_hash_insert(void *addr, int size, int line, char *filen)
+memory_hash_insert(void *addr, int size, int line, const char *filen)
{
unsigned long bucket = HASHADDR(addr);
struct mh_struct *p;
diff -r 562175eff9a1 -r 2608278ac2af sys/dev/raidframe/rf_debugMem.h
--- a/sys/dev/raidframe/rf_debugMem.h Sun May 01 06:42:29 2011 +0000
+++ b/sys/dev/raidframe/rf_debugMem.h Sun May 01 06:49:43 2011 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: rf_debugMem.h,v 1.12 2005/12/11 12:23:37 christos Exp $ */
+/* $NetBSD: rf_debugMem.h,v 1.13 2011/05/01 06:49:43 mrg Exp $ */
/*
* Copyright (c) 1995 Carnegie-Mellon University.
* All rights reserved.
@@ -80,7 +80,7 @@
}
#endif
-void rf_record_malloc(void *p, int size, int line, char *filen);
+void rf_record_malloc(void *p, int size, int line, const char *filen);
void rf_unrecord_malloc(void *p, int sz);
void rf_print_unfreed(void);
int rf_ConfigureDebugMem(RF_ShutdownList_t ** listp);
Home |
Main Index |
Thread Index |
Old Index