#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
#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
#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
/* 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
}
spl_mutex_init(void)
{
ENTRY;
+#ifdef DEBUG_MUTEX
+ init_rwsem(&mutex_stats_sem);
+ INIT_LIST_HEAD(&mutex_stats_list);
+#endif
RETURN(0);
}