]> git.proxmox.com Git - mirror_zfs.git/commitdiff
Remaining issues fixed after reenabled mutex debugging.
authorbehlendo <behlendo@7e1ea52c-4ff2-0310-8f11-9dd32ca42a1c>
Tue, 6 May 2008 23:19:27 +0000 (23:19 +0000)
committerbehlendo <behlendo@7e1ea52c-4ff2-0310-8f11-9dd32ca42a1c>
Tue, 6 May 2008 23:19:27 +0000 (23:19 +0000)
- Ensure the mutex_stats_sem and mutex_stats_list are initialized
- Only spin if you have to in mutex_init

git-svn-id: https://outreach.scidac.gov/svn/spl/trunk@97 7e1ea52c-4ff2-0310-8f11-9dd32ca42a1c

include/sys/mutex.h
modules/spl/spl-mutex.c

index dc78edbbc96245fda829225d4d6f6ca166d5db99..23c23409b1bd3d08638bd0e49a1ad1bb4b720f58 100644 (file)
@@ -10,8 +10,7 @@ extern "C" {
 #include <sys/types.h>
 #include <sys/kmem.h>
 
-//#define DEBUG_MUTEX
-#undef DEBUG_MUTEX
+#define DEBUG_MUTEX
 
 #define MUTEX_DEFAULT          0
 #define MUTEX_SPIN             1
@@ -45,7 +44,7 @@ extern int mutex_spin_max;
 
 #ifdef DEBUG_MUTEX
 extern int mutex_stats[MUTEX_STATS_SIZE];
-extern struct mutex mutex_stats_lock;
+extern struct rw_semaphore mutex_stats_sem;
 extern struct list_head mutex_stats_list;
 #define MUTEX_STAT_INC(stats, stat)    ((stats)[stat]++)
 #else
index 5949283e62bdba06b7e8853f9d04b820fe670d2e..c6d83eb21c930e1e8fe2ddbbb7e513d9495d5fe7 100644 (file)
@@ -30,7 +30,7 @@ int mutex_spin_max = 100;
 #ifdef DEBUG_MUTEX
 int mutex_stats[MUTEX_STATS_SIZE] = { 0 };
 struct rw_semaphore mutex_stats_sem;
-LIST_HEAD(mutex_stats_list);
+struct list_head mutex_stats_list;
 #endif
 
 void
@@ -91,8 +91,13 @@ __spl_mutex_init(kmutex_t *mp, char *name, int type, void *ibc)
        /* We may be called when there is a non-zero preempt_count or
         * interrupts are disabled is which case we must not sleep.
         */
-       while (!down_write_trylock(&mutex_stats_sem));
+       if (flags == KM_SLEEP)
+                down_write(&mutex_stats_sem);
+       else
+               while (!down_write_trylock(&mutex_stats_sem));
+
        list_add_tail(&mp->km_list, &mutex_stats_list);
+
        up_write(&mutex_stats_sem);
 #endif
 }
@@ -255,6 +260,10 @@ int
 spl_mutex_init(void)
 {
        ENTRY;
+#ifdef DEBUG_MUTEX
+        init_rwsem(&mutex_stats_sem);
+        INIT_LIST_HEAD(&mutex_stats_list);
+#endif
        RETURN(0);
 }