]> git.proxmox.com Git - mirror_spl.git/blob - module/spl/spl-kstat.c
Merge branch 'kstat'
[mirror_spl.git] / module / spl / spl-kstat.c
1 /*****************************************************************************\
2 * Copyright (C) 2007-2010 Lawrence Livermore National Security, LLC.
3 * Copyright (C) 2007 The Regents of the University of California.
4 * Produced at Lawrence Livermore National Laboratory (cf, DISCLAIMER).
5 * Written by Brian Behlendorf <behlendorf1@llnl.gov>.
6 * UCRL-CODE-235197
7 *
8 * This file is part of the SPL, Solaris Porting Layer.
9 * For details, see <http://zfsonlinux.org/>.
10 *
11 * The SPL is free software; you can redistribute it and/or modify it
12 * under the terms of the GNU General Public License as published by the
13 * Free Software Foundation; either version 2 of the License, or (at your
14 * option) any later version.
15 *
16 * The SPL is distributed in the hope that it will be useful, but WITHOUT
17 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
18 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
19 * for more details.
20 *
21 * You should have received a copy of the GNU General Public License along
22 * with the SPL. If not, see <http://www.gnu.org/licenses/>.
23 *****************************************************************************
24 * Solaris Porting Layer (SPL) Kstat Implementation.
25 \*****************************************************************************/
26
27 #include <linux/seq_file.h>
28 #include <sys/kstat.h>
29 #include <spl-debug.h>
30
31 #ifdef SS_DEBUG_SUBSYS
32 #undef SS_DEBUG_SUBSYS
33 #endif
34
35 #define SS_DEBUG_SUBSYS SS_KSTAT
36 #ifndef HAVE_PDE_DATA
37 #define PDE_DATA(x) (PDE(x)->data)
38 #endif
39
40 static kmutex_t kstat_module_lock;
41 static struct list_head kstat_module_list;
42 static kid_t kstat_id;
43
44 static int
45 kstat_resize_raw(kstat_t *ksp)
46 {
47 if (ksp->ks_raw_bufsize == KSTAT_RAW_MAX)
48 return ENOMEM;
49
50 vmem_free(ksp->ks_raw_buf, ksp->ks_raw_bufsize);
51 ksp->ks_raw_bufsize = MIN(ksp->ks_raw_bufsize * 2, KSTAT_RAW_MAX);
52 ksp->ks_raw_buf = vmem_alloc(ksp->ks_raw_bufsize, KM_SLEEP);
53
54 return 0;
55 }
56
57 void
58 kstat_waitq_enter(kstat_io_t *kiop)
59 {
60 hrtime_t new, delta;
61 ulong_t wcnt;
62
63 new = gethrtime();
64 delta = new - kiop->wlastupdate;
65 kiop->wlastupdate = new;
66 wcnt = kiop->wcnt++;
67 if (wcnt != 0) {
68 kiop->wlentime += delta * wcnt;
69 kiop->wtime += delta;
70 }
71 }
72 EXPORT_SYMBOL(kstat_waitq_enter);
73
74 void
75 kstat_waitq_exit(kstat_io_t *kiop)
76 {
77 hrtime_t new, delta;
78 ulong_t wcnt;
79
80 new = gethrtime();
81 delta = new - kiop->wlastupdate;
82 kiop->wlastupdate = new;
83 wcnt = kiop->wcnt--;
84 ASSERT((int)wcnt > 0);
85 kiop->wlentime += delta * wcnt;
86 kiop->wtime += delta;
87 }
88 EXPORT_SYMBOL(kstat_waitq_exit);
89
90 void
91 kstat_runq_enter(kstat_io_t *kiop)
92 {
93 hrtime_t new, delta;
94 ulong_t rcnt;
95
96 new = gethrtime();
97 delta = new - kiop->rlastupdate;
98 kiop->rlastupdate = new;
99 rcnt = kiop->rcnt++;
100 if (rcnt != 0) {
101 kiop->rlentime += delta * rcnt;
102 kiop->rtime += delta;
103 }
104 }
105 EXPORT_SYMBOL(kstat_runq_enter);
106
107 void
108 kstat_runq_exit(kstat_io_t *kiop)
109 {
110 hrtime_t new, delta;
111 ulong_t rcnt;
112
113 new = gethrtime();
114 delta = new - kiop->rlastupdate;
115 kiop->rlastupdate = new;
116 rcnt = kiop->rcnt--;
117 ASSERT((int)rcnt > 0);
118 kiop->rlentime += delta * rcnt;
119 kiop->rtime += delta;
120 }
121 EXPORT_SYMBOL(kstat_runq_exit);
122
123 static int
124 kstat_seq_show_headers(struct seq_file *f)
125 {
126 kstat_t *ksp = (kstat_t *)f->private;
127 int rc = 0;
128
129 ASSERT(ksp->ks_magic == KS_MAGIC);
130
131 seq_printf(f, "%d %d 0x%02x %d %d %lld %lld\n",
132 ksp->ks_kid, ksp->ks_type, ksp->ks_flags,
133 ksp->ks_ndata, (int)ksp->ks_data_size,
134 ksp->ks_crtime, ksp->ks_snaptime);
135
136 switch (ksp->ks_type) {
137 case KSTAT_TYPE_RAW:
138 restart:
139 if (ksp->ks_raw_ops.headers) {
140 rc = ksp->ks_raw_ops.headers(
141 ksp->ks_raw_buf, ksp->ks_raw_bufsize);
142 if (rc == ENOMEM && !kstat_resize_raw(ksp))
143 goto restart;
144 if (!rc)
145 seq_puts(f, ksp->ks_raw_buf);
146 } else {
147 seq_printf(f, "raw data\n");
148 }
149 break;
150 case KSTAT_TYPE_NAMED:
151 seq_printf(f, "%-31s %-4s %s\n",
152 "name", "type", "data");
153 break;
154 case KSTAT_TYPE_INTR:
155 seq_printf(f, "%-8s %-8s %-8s %-8s %-8s\n",
156 "hard", "soft", "watchdog",
157 "spurious", "multsvc");
158 break;
159 case KSTAT_TYPE_IO:
160 seq_printf(f,
161 "%-8s %-8s %-8s %-8s %-8s %-8s "
162 "%-8s %-8s %-8s %-8s %-8s %-8s\n",
163 "nread", "nwritten", "reads", "writes",
164 "wtime", "wlentime", "wupdate",
165 "rtime", "rlentime", "rupdate",
166 "wcnt", "rcnt");
167 break;
168 case KSTAT_TYPE_TIMER:
169 seq_printf(f,
170 "%-31s %-8s "
171 "%-8s %-8s %-8s %-8s %-8s\n",
172 "name", "events", "elapsed",
173 "min", "max", "start", "stop");
174 break;
175 default:
176 PANIC("Undefined kstat type %d\n", ksp->ks_type);
177 }
178
179 return -rc;
180 }
181
182 static int
183 kstat_seq_show_raw(struct seq_file *f, unsigned char *p, int l)
184 {
185 int i, j;
186
187 for (i = 0; ; i++) {
188 seq_printf(f, "%03x:", i);
189
190 for (j = 0; j < 16; j++) {
191 if (i * 16 + j >= l) {
192 seq_printf(f, "\n");
193 goto out;
194 }
195
196 seq_printf(f, " %02x", (unsigned char)p[i * 16 + j]);
197 }
198 seq_printf(f, "\n");
199 }
200 out:
201 return 0;
202 }
203
204 static int
205 kstat_seq_show_named(struct seq_file *f, kstat_named_t *knp)
206 {
207 seq_printf(f, "%-31s %-4d ", knp->name, knp->data_type);
208
209 switch (knp->data_type) {
210 case KSTAT_DATA_CHAR:
211 knp->value.c[15] = '\0'; /* NULL terminate */
212 seq_printf(f, "%-16s", knp->value.c);
213 break;
214 /* XXX - We need to be more careful able what tokens are
215 * used for each arch, for now this is correct for x86_64.
216 */
217 case KSTAT_DATA_INT32:
218 seq_printf(f, "%d", knp->value.i32);
219 break;
220 case KSTAT_DATA_UINT32:
221 seq_printf(f, "%u", knp->value.ui32);
222 break;
223 case KSTAT_DATA_INT64:
224 seq_printf(f, "%lld", (signed long long)knp->value.i64);
225 break;
226 case KSTAT_DATA_UINT64:
227 seq_printf(f, "%llu", (unsigned long long)knp->value.ui64);
228 break;
229 case KSTAT_DATA_LONG:
230 seq_printf(f, "%ld", knp->value.l);
231 break;
232 case KSTAT_DATA_ULONG:
233 seq_printf(f, "%lu", knp->value.ul);
234 break;
235 case KSTAT_DATA_STRING:
236 KSTAT_NAMED_STR_PTR(knp)
237 [KSTAT_NAMED_STR_BUFLEN(knp)-1] = '\0';
238 seq_printf(f, "%s", KSTAT_NAMED_STR_PTR(knp));
239 break;
240 default:
241 PANIC("Undefined kstat data type %d\n", knp->data_type);
242 }
243
244 seq_printf(f, "\n");
245
246 return 0;
247 }
248
249 static int
250 kstat_seq_show_intr(struct seq_file *f, kstat_intr_t *kip)
251 {
252 seq_printf(f, "%-8u %-8u %-8u %-8u %-8u\n",
253 kip->intrs[KSTAT_INTR_HARD],
254 kip->intrs[KSTAT_INTR_SOFT],
255 kip->intrs[KSTAT_INTR_WATCHDOG],
256 kip->intrs[KSTAT_INTR_SPURIOUS],
257 kip->intrs[KSTAT_INTR_MULTSVC]);
258
259 return 0;
260 }
261
262 static int
263 kstat_seq_show_io(struct seq_file *f, kstat_io_t *kip)
264 {
265 seq_printf(f,
266 "%-8llu %-8llu %-8u %-8u %-8lld %-8lld "
267 "%-8lld %-8lld %-8lld %-8lld %-8u %-8u\n",
268 kip->nread, kip->nwritten,
269 kip->reads, kip->writes,
270 kip->wtime, kip->wlentime, kip->wlastupdate,
271 kip->rtime, kip->wlentime, kip->rlastupdate,
272 kip->wcnt, kip->rcnt);
273
274 return 0;
275 }
276
277 static int
278 kstat_seq_show_timer(struct seq_file *f, kstat_timer_t *ktp)
279 {
280 seq_printf(f,
281 "%-31s %-8llu %-8lld %-8lld %-8lld %-8lld %-8lld\n",
282 ktp->name, ktp->num_events, ktp->elapsed_time,
283 ktp->min_time, ktp->max_time,
284 ktp->start_time, ktp->stop_time);
285
286 return 0;
287 }
288
289 static int
290 kstat_seq_show(struct seq_file *f, void *p)
291 {
292 kstat_t *ksp = (kstat_t *)f->private;
293 int rc = 0;
294
295 ASSERT(ksp->ks_magic == KS_MAGIC);
296
297 switch (ksp->ks_type) {
298 case KSTAT_TYPE_RAW:
299 restart:
300 if (ksp->ks_raw_ops.data) {
301 rc = ksp->ks_raw_ops.data(
302 ksp->ks_raw_buf, ksp->ks_raw_bufsize, p);
303 if (rc == ENOMEM && !kstat_resize_raw(ksp))
304 goto restart;
305 if (!rc)
306 seq_puts(f, ksp->ks_raw_buf);
307 } else {
308 ASSERT(ksp->ks_ndata == 1);
309 rc = kstat_seq_show_raw(f, ksp->ks_data,
310 ksp->ks_data_size);
311 }
312 break;
313 case KSTAT_TYPE_NAMED:
314 rc = kstat_seq_show_named(f, (kstat_named_t *)p);
315 break;
316 case KSTAT_TYPE_INTR:
317 rc = kstat_seq_show_intr(f, (kstat_intr_t *)p);
318 break;
319 case KSTAT_TYPE_IO:
320 rc = kstat_seq_show_io(f, (kstat_io_t *)p);
321 break;
322 case KSTAT_TYPE_TIMER:
323 rc = kstat_seq_show_timer(f, (kstat_timer_t *)p);
324 break;
325 default:
326 PANIC("Undefined kstat type %d\n", ksp->ks_type);
327 }
328
329 return -rc;
330 }
331
332 int
333 kstat_default_update(kstat_t *ksp, int rw)
334 {
335 ASSERT(ksp != NULL);
336
337 if (rw == KSTAT_WRITE)
338 return (EACCES);
339
340 return 0;
341 }
342
343 static void *
344 kstat_seq_data_addr(kstat_t *ksp, loff_t n)
345 {
346 void *rc = NULL;
347 SENTRY;
348
349 switch (ksp->ks_type) {
350 case KSTAT_TYPE_RAW:
351 if (ksp->ks_raw_ops.addr)
352 rc = ksp->ks_raw_ops.addr(ksp, n);
353 else
354 rc = ksp->ks_data;
355 break;
356 case KSTAT_TYPE_NAMED:
357 rc = ksp->ks_data + n * sizeof(kstat_named_t);
358 break;
359 case KSTAT_TYPE_INTR:
360 rc = ksp->ks_data + n * sizeof(kstat_intr_t);
361 break;
362 case KSTAT_TYPE_IO:
363 rc = ksp->ks_data + n * sizeof(kstat_io_t);
364 break;
365 case KSTAT_TYPE_TIMER:
366 rc = ksp->ks_data + n * sizeof(kstat_timer_t);
367 break;
368 default:
369 PANIC("Undefined kstat type %d\n", ksp->ks_type);
370 }
371
372 SRETURN(rc);
373 }
374
375 static void *
376 kstat_seq_start(struct seq_file *f, loff_t *pos)
377 {
378 loff_t n = *pos;
379 kstat_t *ksp = (kstat_t *)f->private;
380 ASSERT(ksp->ks_magic == KS_MAGIC);
381 SENTRY;
382
383 mutex_enter(ksp->ks_lock);
384
385 if (ksp->ks_type == KSTAT_TYPE_RAW) {
386 ksp->ks_raw_bufsize = PAGE_SIZE;
387 ksp->ks_raw_buf = vmem_alloc(ksp->ks_raw_bufsize, KM_SLEEP);
388 }
389
390 /* Dynamically update kstat, on error existing kstats are used */
391 (void) ksp->ks_update(ksp, KSTAT_READ);
392
393 ksp->ks_snaptime = gethrtime();
394
395 if (!n && kstat_seq_show_headers(f))
396 SRETURN(NULL);
397
398 if (n >= ksp->ks_ndata)
399 SRETURN(NULL);
400
401 SRETURN(kstat_seq_data_addr(ksp, n));
402 }
403
404 static void *
405 kstat_seq_next(struct seq_file *f, void *p, loff_t *pos)
406 {
407 kstat_t *ksp = (kstat_t *)f->private;
408 ASSERT(ksp->ks_magic == KS_MAGIC);
409 SENTRY;
410
411 ++*pos;
412 if (*pos >= ksp->ks_ndata)
413 SRETURN(NULL);
414
415 SRETURN(kstat_seq_data_addr(ksp, *pos));
416 }
417
418 static void
419 kstat_seq_stop(struct seq_file *f, void *v)
420 {
421 kstat_t *ksp = (kstat_t *)f->private;
422 ASSERT(ksp->ks_magic == KS_MAGIC);
423
424 if (ksp->ks_type == KSTAT_TYPE_RAW)
425 vmem_free(ksp->ks_raw_buf, ksp->ks_raw_bufsize);
426
427 mutex_exit(ksp->ks_lock);
428 }
429
430 static struct seq_operations kstat_seq_ops = {
431 .show = kstat_seq_show,
432 .start = kstat_seq_start,
433 .next = kstat_seq_next,
434 .stop = kstat_seq_stop,
435 };
436
437 static kstat_module_t *
438 kstat_find_module(char *name)
439 {
440 kstat_module_t *module;
441
442 list_for_each_entry(module, &kstat_module_list, ksm_module_list)
443 if (strncmp(name, module->ksm_name, KSTAT_STRLEN) == 0)
444 return (module);
445
446 return (NULL);
447 }
448
449 static kstat_module_t *
450 kstat_create_module(char *name)
451 {
452 kstat_module_t *module;
453 struct proc_dir_entry *pde;
454
455 pde = proc_mkdir(name, proc_spl_kstat);
456 if (pde == NULL)
457 return (NULL);
458
459 module = kmem_alloc(sizeof (kstat_module_t), KM_SLEEP);
460 module->ksm_proc = pde;
461 strlcpy(module->ksm_name, name, KSTAT_STRLEN+1);
462 INIT_LIST_HEAD(&module->ksm_kstat_list);
463 list_add_tail(&module->ksm_module_list, &kstat_module_list);
464
465 return (module);
466
467 }
468
469 static void
470 kstat_delete_module(kstat_module_t *module)
471 {
472 ASSERT(list_empty(&module->ksm_kstat_list));
473 remove_proc_entry(module->ksm_name, proc_spl_kstat);
474 list_del(&module->ksm_module_list);
475 kmem_free(module, sizeof(kstat_module_t));
476 }
477
478 static int
479 proc_kstat_open(struct inode *inode, struct file *filp)
480 {
481 struct seq_file *f;
482 int rc;
483
484 rc = seq_open(filp, &kstat_seq_ops);
485 if (rc)
486 return rc;
487
488 f = filp->private_data;
489 f->private = PDE_DATA(inode);
490
491 return rc;
492 }
493
494 static ssize_t
495 proc_kstat_write(struct file *filp, const char __user *buf,
496 size_t len, loff_t *ppos)
497 {
498 struct seq_file *f = filp->private_data;
499 kstat_t *ksp = f->private;
500 int rc;
501
502 ASSERT(ksp->ks_magic == KS_MAGIC);
503
504 mutex_enter(ksp->ks_lock);
505 rc = ksp->ks_update(ksp, KSTAT_WRITE);
506 mutex_exit(ksp->ks_lock);
507
508 if (rc)
509 return (-rc);
510
511 *ppos += len;
512 return (len);
513 }
514
515 static struct file_operations proc_kstat_operations = {
516 .open = proc_kstat_open,
517 .write = proc_kstat_write,
518 .read = seq_read,
519 .llseek = seq_lseek,
520 .release = seq_release,
521 };
522
523 void
524 __kstat_set_raw_ops(kstat_t *ksp,
525 int (*headers)(char *buf, size_t size),
526 int (*data)(char *buf, size_t size, void *data),
527 void *(*addr)(kstat_t *ksp, loff_t index))
528 {
529 ksp->ks_raw_ops.headers = headers;
530 ksp->ks_raw_ops.data = data;
531 ksp->ks_raw_ops.addr = addr;
532 }
533 EXPORT_SYMBOL(__kstat_set_raw_ops);
534
535 kstat_t *
536 __kstat_create(const char *ks_module, int ks_instance, const char *ks_name,
537 const char *ks_class, uchar_t ks_type, uint_t ks_ndata,
538 uchar_t ks_flags)
539 {
540 kstat_t *ksp;
541
542 ASSERT(ks_module);
543 ASSERT(ks_instance == 0);
544 ASSERT(ks_name);
545 ASSERT(!(ks_flags & KSTAT_FLAG_UNSUPPORTED));
546
547 if ((ks_type == KSTAT_TYPE_INTR) || (ks_type == KSTAT_TYPE_IO))
548 ASSERT(ks_ndata == 1);
549
550 ksp = kmem_zalloc(sizeof(*ksp), KM_SLEEP);
551 if (ksp == NULL)
552 return ksp;
553
554 mutex_enter(&kstat_module_lock);
555 ksp->ks_kid = kstat_id;
556 kstat_id++;
557 mutex_exit(&kstat_module_lock);
558
559 ksp->ks_magic = KS_MAGIC;
560 mutex_init(&ksp->ks_private_lock, NULL, MUTEX_DEFAULT, NULL);
561 ksp->ks_lock = &ksp->ks_private_lock;
562 INIT_LIST_HEAD(&ksp->ks_list);
563
564 ksp->ks_crtime = gethrtime();
565 ksp->ks_snaptime = ksp->ks_crtime;
566 strncpy(ksp->ks_module, ks_module, KSTAT_STRLEN);
567 ksp->ks_instance = ks_instance;
568 strncpy(ksp->ks_name, ks_name, KSTAT_STRLEN);
569 strncpy(ksp->ks_class, ks_class, KSTAT_STRLEN);
570 ksp->ks_type = ks_type;
571 ksp->ks_flags = ks_flags;
572 ksp->ks_update = kstat_default_update;
573 ksp->ks_private = NULL;
574 ksp->ks_raw_ops.headers = NULL;
575 ksp->ks_raw_ops.data = NULL;
576 ksp->ks_raw_ops.addr = NULL;
577 ksp->ks_raw_buf = NULL;
578 ksp->ks_raw_bufsize = 0;
579
580 switch (ksp->ks_type) {
581 case KSTAT_TYPE_RAW:
582 ksp->ks_ndata = 1;
583 ksp->ks_data_size = ks_ndata;
584 break;
585 case KSTAT_TYPE_NAMED:
586 ksp->ks_ndata = ks_ndata;
587 ksp->ks_data_size = ks_ndata * sizeof(kstat_named_t);
588 break;
589 case KSTAT_TYPE_INTR:
590 ksp->ks_ndata = ks_ndata;
591 ksp->ks_data_size = ks_ndata * sizeof(kstat_intr_t);
592 break;
593 case KSTAT_TYPE_IO:
594 ksp->ks_ndata = ks_ndata;
595 ksp->ks_data_size = ks_ndata * sizeof(kstat_io_t);
596 break;
597 case KSTAT_TYPE_TIMER:
598 ksp->ks_ndata = ks_ndata;
599 ksp->ks_data_size = ks_ndata * sizeof(kstat_timer_t);
600 break;
601 default:
602 PANIC("Undefined kstat type %d\n", ksp->ks_type);
603 }
604
605 if (ksp->ks_flags & KSTAT_FLAG_VIRTUAL) {
606 ksp->ks_data = NULL;
607 } else {
608 ksp->ks_data = kmem_zalloc(ksp->ks_data_size, KM_SLEEP);
609 if (ksp->ks_data == NULL) {
610 kmem_free(ksp, sizeof(*ksp));
611 ksp = NULL;
612 }
613 }
614
615 return ksp;
616 }
617 EXPORT_SYMBOL(__kstat_create);
618
619 void
620 __kstat_install(kstat_t *ksp)
621 {
622 kstat_module_t *module;
623 kstat_t *tmp;
624
625 ASSERT(ksp);
626
627 mutex_enter(&kstat_module_lock);
628
629 module = kstat_find_module(ksp->ks_module);
630 if (module == NULL) {
631 module = kstat_create_module(ksp->ks_module);
632 if (module == NULL)
633 goto out;
634 }
635
636 /*
637 * Only one entry by this name per-module, on failure the module
638 * shouldn't be deleted because we know it has at least one entry.
639 */
640 list_for_each_entry(tmp, &module->ksm_kstat_list, ks_list)
641 if (strncmp(tmp->ks_name, ksp->ks_name, KSTAT_STRLEN) == 0)
642 goto out;
643
644 list_add_tail(&ksp->ks_list, &module->ksm_kstat_list);
645
646 mutex_enter(ksp->ks_lock);
647 ksp->ks_owner = module;
648 ksp->ks_proc = proc_create_data(ksp->ks_name, 0644,
649 module->ksm_proc, &proc_kstat_operations, (void *)ksp);
650 if (ksp->ks_proc == NULL) {
651 list_del_init(&ksp->ks_list);
652 if (list_empty(&module->ksm_kstat_list))
653 kstat_delete_module(module);
654 }
655 mutex_exit(ksp->ks_lock);
656 out:
657 mutex_exit(&kstat_module_lock);
658 }
659 EXPORT_SYMBOL(__kstat_install);
660
661 void
662 __kstat_delete(kstat_t *ksp)
663 {
664 kstat_module_t *module = ksp->ks_owner;
665
666 mutex_enter(&kstat_module_lock);
667 list_del_init(&ksp->ks_list);
668 mutex_exit(&kstat_module_lock);
669
670 if (ksp->ks_proc) {
671 remove_proc_entry(ksp->ks_name, module->ksm_proc);
672
673 /* Remove top level module directory if it's empty */
674 if (list_empty(&module->ksm_kstat_list))
675 kstat_delete_module(module);
676 }
677
678 if (!(ksp->ks_flags & KSTAT_FLAG_VIRTUAL))
679 kmem_free(ksp->ks_data, ksp->ks_data_size);
680
681 ksp->ks_lock = NULL;
682 mutex_destroy(&ksp->ks_private_lock);
683 kmem_free(ksp, sizeof(*ksp));
684
685 return;
686 }
687 EXPORT_SYMBOL(__kstat_delete);
688
689 int
690 spl_kstat_init(void)
691 {
692 SENTRY;
693 mutex_init(&kstat_module_lock, NULL, MUTEX_DEFAULT, NULL);
694 INIT_LIST_HEAD(&kstat_module_list);
695 kstat_id = 0;
696 SRETURN(0);
697 }
698
699 void
700 spl_kstat_fini(void)
701 {
702 SENTRY;
703 ASSERT(list_empty(&kstat_module_list));
704 mutex_destroy(&kstat_module_lock);
705 SEXIT;
706 }
707