diff options
| author | pgoyette <pgoyette@NetBSD.org> | 2015-04-27 07:51:28 +0000 |
|---|---|---|
| committer | pgoyette <pgoyette@NetBSD.org> | 2015-04-27 07:51:28 +0000 |
| commit | 672cde7bbcb056d3eb7d27a7ef7133d7d1be4d55 (patch) | |
| tree | 3fcd399f481cea4039321d20395de8cf95b8fca0 /sys/dev/sysmon | |
| parent | dd3101b07a823bc898e2392610911e1f15465858 (diff) | |
Replace a home-grown run-once implementation with the real RUN_ONCE()
Diffstat (limited to 'sys/dev/sysmon')
| -rw-r--r-- | sys/dev/sysmon/sysmon_taskq.c | 21 | ||||
| -rw-r--r-- | sys/dev/sysmon/sysmon_taskq.h | 3 |
2 files changed, 14 insertions, 10 deletions
diff --git a/sys/dev/sysmon/sysmon_taskq.c b/sys/dev/sysmon/sysmon_taskq.c index 3c2a37252bc..6a33b30f9cc 100644 --- a/sys/dev/sysmon/sysmon_taskq.c +++ b/sys/dev/sysmon/sysmon_taskq.c @@ -1,4 +1,4 @@ -/* $NetBSD: sysmon_taskq.c,v 1.17 2015/04/24 00:31:04 pgoyette Exp $ */ +/* $NetBSD: sysmon_taskq.c,v 1.18 2015/04/27 07:51:28 pgoyette Exp $ */ /* * Copyright (c) 2001, 2003 Wasabi Systems, Inc. @@ -41,7 +41,7 @@ */ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: sysmon_taskq.c,v 1.17 2015/04/24 00:31:04 pgoyette Exp $"); +__KERNEL_RCSID(0, "$NetBSD: sysmon_taskq.c,v 1.18 2015/04/27 07:51:28 pgoyette Exp $"); #include <sys/param.h> #include <sys/malloc.h> @@ -50,6 +50,7 @@ __KERNEL_RCSID(0, "$NetBSD: sysmon_taskq.c,v 1.17 2015/04/24 00:31:04 pgoyette E #include <sys/kthread.h> #include <sys/systm.h> #include <sys/module.h> +#include <sys/once.h> #include <dev/sysmon/sysmon_taskq.h> @@ -88,18 +89,23 @@ MODULE(MODULE_CLASS_MISC, sysmon_taskq, NULL); */ /* - * sysmon_task_queue_preinit: + * tq_preinit: * * Early one-time initialization of task-queue */ -void -sysmon_task_queue_preinit(void) + +ONCE_DECL(once_tq); + +static int +tq_preinit(void) { mutex_init(&sysmon_task_queue_mtx, MUTEX_DEFAULT, IPL_VM); mutex_init(&sysmon_task_queue_init_mtx, MUTEX_DEFAULT, IPL_NONE); cv_init(&sysmon_task_queue_cv, "smtaskq"); sysmon_task_queue_initialized = 0; + + return 0; } /* @@ -112,6 +118,8 @@ sysmon_task_queue_init(void) { int error; + (void)RUN_ONCE(&once_tq, tq_preinit); + mutex_enter(&sysmon_task_queue_init_mtx); if (sysmon_task_queue_initialized++) { mutex_exit(&sysmon_task_queue_init_mtx); @@ -244,9 +252,6 @@ sysmon_taskq_modcmd(modcmd_t cmd, void *arg) switch (cmd) { case MODULE_CMD_INIT: -#ifdef _MODULE - sysmon_task_queue_preinit(); -#endif sysmon_task_queue_init(); ret = 0; break; diff --git a/sys/dev/sysmon/sysmon_taskq.h b/sys/dev/sysmon/sysmon_taskq.h index 707669741ec..32a4fcd7a2f 100644 --- a/sys/dev/sysmon/sysmon_taskq.h +++ b/sys/dev/sysmon/sysmon_taskq.h @@ -1,4 +1,4 @@ -/* $NetBSD: sysmon_taskq.h,v 1.3 2015/04/24 00:31:04 pgoyette Exp $ */ +/* $NetBSD: sysmon_taskq.h,v 1.4 2015/04/27 07:51:28 pgoyette Exp $ */ /* * Copyright (c) 2003 Wasabi Systems, Inc. @@ -38,7 +38,6 @@ #ifndef _DEV_SYSMON_SYSMON_TASKQ_H_ #define _DEV_SYSMON_SYSMON_TASKQ_H_ -void sysmon_task_queue_preinit(void); void sysmon_task_queue_init(void); int sysmon_task_queue_fini(void); int sysmon_task_queue_sched(u_int, void (*)(void *), void *); |
