summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorbehlendo <behlendo@7e1ea52c-4ff2-0310-8f11-9dd32ca42a1c>2008-05-09 22:53:20 +0000
committerbehlendo <behlendo@7e1ea52c-4ff2-0310-8f11-9dd32ca42a1c>2008-05-09 22:53:20 +0000
commitc6dc93d6a8814198165e28364c2941cd55a071a6 (patch)
treeb91c1b3cba383364dce8c4c54217312c9239a339
parent5c2bb9b2c314bcac7579b13a99127eb7050a7b90 (diff)
By default disable extra KMEM and MUTEX debugging to aid performance.
They can easily be re-enabled when new stability issues are uncovered. git-svn-id: https://outreach.scidac.gov/svn/spl/trunk@105 7e1ea52c-4ff2-0310-8f11-9dd32ca42a1c
-rw-r--r--include/sys/kmem.h26
-rw-r--r--include/sys/mutex.h3
-rw-r--r--modules/spl/spl-kmem.c7
-rw-r--r--modules/spl/spl-mutex.c6
-rw-r--r--modules/spl/spl-proc.c6
5 files changed, 31 insertions, 17 deletions
diff --git a/include/sys/kmem.h b/include/sys/kmem.h
index 1dfc0bf1e..319c800b6 100644
--- a/include/sys/kmem.h
+++ b/include/sys/kmem.h
@@ -5,7 +5,8 @@
extern "C" {
#endif
-#define DEBUG_KMEM
+//#define DEBUG_KMEM
+#undef DEBUG_KMEM
#undef DEBUG_KMEM_UNIMPLEMENTED
#include <linux/module.h>
@@ -247,30 +248,25 @@ __kmem_del_init(spinlock_t *lock,struct hlist_head *table,int bits,void *addr)
vfree(ptr); \
})
-#else
+#else /* DEBUG_KMEM */
#define kmem_alloc(size, flags) kmalloc((size), (flags))
#define kmem_zalloc(size, flags) kzalloc((size), (flags))
-#define kmem_free(ptr, size) \
-({ \
- ASSERT((ptr) || (size > 0)); \
- kfree(ptr); \
-})
+#define kmem_free(ptr, size) kfree(ptr)
#define vmem_alloc(size, flags) __vmalloc((size), ((flags) | \
- __GFP_HIGHMEM), PAGE_KERNEL)
-#define vmem_zalloc(size, flags) __vmalloc((size), ((flags) | \
- __GFP_HIGHMEM | __GFP_ZERO) \
- PAGE_KERNEL)
-#define vmem_free(ptr, size) \
+ __GFP_HIGHMEM), PAGE_KERNEL)
+#define vmem_zalloc(size, flags) \
({ \
- ASSERT((ptr) || (size > 0)); \
- vfree(ptr); \
+ void *_ptr_ = __vmalloc((size),((flags)|__GFP_HIGHMEM),PAGE_KERNEL); \
+ if (_ptr_) \
+ memset(_ptr_, 0, (size)); \
+ _ptr_; \
})
+#define vmem_free(ptr, size) vfree(ptr)
#endif /* DEBUG_KMEM */
-
#ifdef DEBUG_KMEM_UNIMPLEMENTED
static __inline__ void *
kmem_alloc_tryhard(size_t size, size_t *alloc_size, int kmflags)
diff --git a/include/sys/mutex.h b/include/sys/mutex.h
index 58d1bf629..b54f495b9 100644
--- a/include/sys/mutex.h
+++ b/include/sys/mutex.h
@@ -10,7 +10,8 @@ extern "C" {
#include <sys/types.h>
#include <sys/kmem.h>
-#define DEBUG_MUTEX
+//#define DEBUG_MUTEX
+#undef DEBUG_MUTEX
#define MUTEX_DEFAULT 0
#define MUTEX_SPIN 1
diff --git a/modules/spl/spl-kmem.c b/modules/spl/spl-kmem.c
index 80c4488b1..f82c1c240 100644
--- a/modules/spl/spl-kmem.c
+++ b/modules/spl/spl-kmem.c
@@ -378,7 +378,9 @@ __kmem_cache_alloc(kmem_cache_t *cache, gfp_t flags)
restart:
rc = kmem_cache_alloc(cache, flags);
if ((rc == NULL) && (flags & KM_SLEEP)) {
+#ifdef DEBUG_KMEM
atomic64_inc(&kmem_cache_alloc_failed);
+#endif /* DEBUG_KMEM */
GOTO(restart, rc);
}
@@ -428,7 +430,9 @@ kmem_init(void)
RETURN(0);
}
-static char *sprintf_addr(kmem_debug_t *kd, char *str, int len, int min)
+#ifdef DEBUG_KMEM
+static char *
+sprintf_addr(kmem_debug_t *kd, char *str, int len, int min)
{
int size = ((len - 1) < kd->kd_size) ? (len - 1) : kd->kd_size;
int i, flag = 1;
@@ -468,6 +472,7 @@ static char *sprintf_addr(kmem_debug_t *kd, char *str, int len, int min)
return str;
}
+#endif /* DEBUG_KMEM */
void
kmem_fini(void)
diff --git a/modules/spl/spl-mutex.c b/modules/spl/spl-mutex.c
index 1eabda610..d9f3c0759 100644
--- a/modules/spl/spl-mutex.c
+++ b/modules/spl/spl-mutex.c
@@ -88,6 +88,12 @@ __spl_mutex_init(kmutex_t *mp, char *name, int type, void *ibc)
return;
}
+ /* XXX - This appears to be a much more contended lock than I
+ * would have expected. To run with this debugging enabled and
+ * get reasonable performance we may need to be more clever and
+ * do something like hash the mutex ptr on to one of several
+ * lists to ease this single point of contention.
+ */
spin_lock(&mutex_stats_lock);
list_add_tail(&mp->km_list, &mutex_stats_list);
spin_unlock(&mutex_stats_lock);
diff --git a/modules/spl/spl-proc.c b/modules/spl/spl-proc.c
index a8d3485a6..4a7dcec96 100644
--- a/modules/spl/spl-proc.c
+++ b/modules/spl/spl-proc.c
@@ -325,6 +325,7 @@ proc_console_backoff(struct ctl_table *table, int write, struct file *filp,
RETURN(rc);
}
+#ifdef DEBUG_KMEM
static int
proc_doatomic64(struct ctl_table *table, int write, struct file *filp,
void __user *buffer, size_t *lenp, loff_t *ppos)
@@ -349,6 +350,7 @@ proc_doatomic64(struct ctl_table *table, int write, struct file *filp,
RETURN(rc);
}
+#endif /* DEBUG_KMEM */
static int
proc_dohostid(struct ctl_table *table, int write, struct file *filp,
@@ -829,7 +831,9 @@ proc_init(void)
RETURN(rc);
out2:
+#ifdef DEBUG_MUTEX
remove_proc_entry("stats_per", proc_sys_spl_mutex);
+#endif /* DEBUG_MUTEX */
out:
unregister_sysctl_table(spl_header);
#endif /* CONFIG_SYSCTL */
@@ -843,7 +847,9 @@ proc_fini(void)
#ifdef CONFIG_SYSCTL
ASSERT(spl_header != NULL);
+#ifdef DEBUG_MUTEX
remove_proc_entry("stats_per", proc_sys_spl_mutex);
+#endif /* DEBUG_MUTEX */
unregister_sysctl_table(spl_header);
#endif
EXIT;