#ifdef DEBUG_MUTEX
int mutex_stats[MUTEX_STATS_SIZE] = { 0 };
-struct rw_semaphore mutex_stats_sem;
+spinlock_t mutex_stats_lock;
struct list_head mutex_stats_list;
#endif
return;
}
- /* We may be called when there is a non-zero preempt_count or
- * interrupts are disabled is which case we must not sleep.
- */
- if (flags == KM_SLEEP)
- down_write(&mutex_stats_sem);
- else
- while (!down_write_trylock(&mutex_stats_sem));
-
+ spin_lock(&mutex_stats_lock);
list_add_tail(&mp->km_list, &mutex_stats_list);
-
- up_write(&mutex_stats_sem);
+ spin_unlock(&mutex_stats_lock);
#endif
}
EXPORT_SYMBOL(__spl_mutex_init);
ASSERT(mp->km_magic == KM_MAGIC);
#ifdef DEBUG_MUTEX
- /* 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));
+ spin_lock(&mutex_stats_lock);
list_del_init(&mp->km_list);
- up_write(&mutex_stats_sem);
+ spin_unlock(&mutex_stats_lock);
kmem_free(mp->km_stats, sizeof(int) * MUTEX_STATS_SIZE);
#endif
{
ENTRY;
#ifdef DEBUG_MUTEX
- init_rwsem(&mutex_stats_sem);
+ spin_lock_init(&mutex_stats_lock);
INIT_LIST_HEAD(&mutex_stats_list);
#endif
RETURN(0);
#define DEBUG_SUBSYSTEM S_PROC
-static struct ctl_table_header *spl_header = NULL;
+#ifdef DEBUG_KMEM
static unsigned long table_min = 0;
static unsigned long table_max = ~0;
+#endif
+
+#ifdef CONFIG_SYSCTL
+static struct ctl_table_header *spl_header = NULL;
+static struct proc_dir_entry *proc_sys = NULL;
+static struct proc_dir_entry *proc_sys_spl = NULL;
+#ifdef DEBUG_MUTEX
+static struct proc_dir_entry *proc_sys_spl_mutex = NULL;
+static struct proc_dir_entry *proc_sys_spl_mutex_stats = NULL;
+#endif
+#endif
#define CTL_SPL 0x87
#define CTL_SPL_DEBUG 0x88
loff_t n = *pos;
ENTRY;
- down_read(&mutex_stats_sem);
+ spin_lock(&mutex_stats_lock);
if (!n)
mutex_seq_show_headers(f);
static void
mutex_seq_stop(struct seq_file *f, void *v)
{
- up_read(&mutex_stats_sem);
+ spin_unlock(&mutex_stats_lock);
}
static struct seq_operations mutex_seq_ops = {
{0}
};
+static int
+proc_dir_entry_match(int len, const char *name, struct proc_dir_entry *de)
+{
+ if (de->namelen != len)
+ return 0;
+
+ return !memcmp(name, de->name, len);
+}
+
+static struct proc_dir_entry *
+proc_dir_entry_find(struct proc_dir_entry *root, const char *str)
+{
+ struct proc_dir_entry *de;
+
+ for (de = root->subdir; de; de = de->next)
+ if (proc_dir_entry_match(strlen(str), str, de))
+ return de;
+
+ return NULL;
+}
+
int
proc_init(void)
{
+ int rc = 0;
ENTRY;
#ifdef CONFIG_SYSCTL
if (spl_header == NULL)
RETURN(-EUNATCH);
+ proc_sys = proc_dir_entry_find(&proc_root, "sys");
+ if (proc_sys == NULL)
+ GOTO(out, rc = -EUNATCH);
+
+ proc_sys_spl = proc_dir_entry_find(proc_sys, "spl");
+ if (proc_sys_spl == NULL)
+ GOTO(out, rc = -EUNATCH);
+
#ifdef DEBUG_MUTEX
- {
- struct proc_dir_entry *entry = create_proc_entry("mutex_stats",
- 0444, NULL);
- if (entry) {
- entry->proc_fops = &proc_mutex_operations;
- } else {
- unregister_sysctl_table(spl_header);
- RETURN(-EUNATCH);
- }
- }
+ proc_sys_spl_mutex = proc_dir_entry_find(proc_sys_spl, "mutex");
+ if (proc_sys_spl_mutex == NULL)
+ GOTO(out, rc = -EUNATCH);
+
+ proc_sys_spl_mutex_stats = create_proc_entry("stats_per", 0444,
+ proc_sys_spl_mutex);
+ if (proc_sys_spl_mutex_stats == NULL)
+ GOTO(out, rc = -EUNATCH);
+
+ proc_sys_spl_mutex_stats->proc_fops = &proc_mutex_operations;
#endif /* DEBUG_MUTEX */
-#endif
- RETURN(0);
+ RETURN(rc);
+out:
+ unregister_sysctl_table(spl_header);
+#endif /* CONFIG_SYSCTL */
+ RETURN(rc);
}
void
#ifdef CONFIG_SYSCTL
ASSERT(spl_header != NULL);
- remove_proc_entry("mutex_stats", NULL);
+ remove_proc_entry("stats_per", proc_sys_spl_mutex);
unregister_sysctl_table(spl_header);
#endif
EXIT;