#include <sys/types.h>
#include <sys/time.h>
#include <sys/kmem.h>
+#include <sys/mutex.h>
#define KSTAT_STRLEN 31
struct proc_dir_entry *ks_proc; /* proc linkage */
kstat_update_t *ks_update; /* dynamic updates */
void *ks_private; /* private data */
- spinlock_t ks_lock; /* kstat data lock */
+ kmutex_t ks_lock; /* kstat data lock */
struct list_head ks_list; /* kstat linkage */
} kstat_t;
ASSERT(ksp->ks_magic == KS_MAGIC);
SENTRY;
+ mutex_enter(&ksp->ks_lock);
+
/* Dynamically update kstat, on error existing kstats are used */
(void) ksp->ks_update(ksp, KSTAT_READ);
- spin_lock(&ksp->ks_lock);
ksp->ks_snaptime = gethrtime();
if (!n)
kstat_t *ksp = (kstat_t *)f->private;
ASSERT(ksp->ks_magic == KS_MAGIC);
- spin_unlock(&ksp->ks_lock);
+ mutex_exit(&ksp->ks_lock);
}
static struct seq_operations kstat_seq_ops = {
spin_unlock(&kstat_lock);
ksp->ks_magic = KS_MAGIC;
- spin_lock_init(&ksp->ks_lock);
+ mutex_init(&ksp->ks_lock, NULL, MUTEX_DEFAULT, NULL);
INIT_LIST_HEAD(&ksp->ks_list);
ksp->ks_crtime = gethrtime();
if (de_name == NULL)
SGOTO(out, rc = -EUNATCH);
- spin_lock(&ksp->ks_lock);
+ mutex_enter(&ksp->ks_lock);
ksp->ks_proc = de_name;
de_name->proc_fops = &proc_kstat_operations;
de_name->data = (void *)ksp;
- spin_unlock(&ksp->ks_lock);
+ mutex_exit(&ksp->ks_lock);
out:
if (rc) {
spin_lock(&kstat_lock);
if (!(ksp->ks_flags & KSTAT_FLAG_VIRTUAL))
kmem_free(ksp->ks_data, ksp->ks_data_size);
+ mutex_destroy(&ksp->ks_lock);
kmem_free(ksp, sizeof(*ksp));
return;