Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/sys Replace a home-grown run-once implementation with the re...
details: https://anonhg.NetBSD.org/src/rev/de48ca87c9f0
branches: trunk
changeset: 337778:de48ca87c9f0
user: pgoyette <pgoyette%NetBSD.org@localhost>
date: Mon Apr 27 07:51:28 2015 +0000
description:
Replace a home-grown run-once implementation with the real RUN_ONCE()
diffstat:
sys/dev/sysmon/sysmon_taskq.c | 21 +++++++++++++--------
sys/dev/sysmon/sysmon_taskq.h | 3 +--
sys/kern/init_main.c | 19 ++-----------------
3 files changed, 16 insertions(+), 27 deletions(-)
diffs (143 lines):
diff -r b2295f330b40 -r de48ca87c9f0 sys/dev/sysmon/sysmon_taskq.c
--- a/sys/dev/sysmon/sysmon_taskq.c Mon Apr 27 07:13:44 2015 +0000
+++ b/sys/dev/sysmon/sysmon_taskq.c Mon Apr 27 07:51:28 2015 +0000
@@ -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 @@
#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 @@
*/
/*
- * 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 @@
{
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 @@
switch (cmd) {
case MODULE_CMD_INIT:
-#ifdef _MODULE
- sysmon_task_queue_preinit();
-#endif
sysmon_task_queue_init();
ret = 0;
break;
diff -r b2295f330b40 -r de48ca87c9f0 sys/dev/sysmon/sysmon_taskq.h
--- a/sys/dev/sysmon/sysmon_taskq.h Mon Apr 27 07:13:44 2015 +0000
+++ b/sys/dev/sysmon/sysmon_taskq.h Mon Apr 27 07:51:28 2015 +0000
@@ -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 *);
diff -r b2295f330b40 -r de48ca87c9f0 sys/kern/init_main.c
--- a/sys/kern/init_main.c Mon Apr 27 07:13:44 2015 +0000
+++ b/sys/kern/init_main.c Mon Apr 27 07:51:28 2015 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: init_main.c,v 1.463 2015/04/23 23:23:08 pgoyette Exp $ */
+/* $NetBSD: init_main.c,v 1.464 2015/04/27 07:51:28 pgoyette Exp $ */
/*-
* Copyright (c) 2008, 2009 The NetBSD Foundation, Inc.
@@ -97,7 +97,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: init_main.c,v 1.463 2015/04/23 23:23:08 pgoyette Exp $");
+__KERNEL_RCSID(0, "$NetBSD: init_main.c,v 1.464 2015/04/27 07:51:28 pgoyette Exp $");
#include "opt_ddb.h"
#include "opt_ipsec.h"
@@ -117,7 +117,6 @@
#include "drvctl.h"
#include "ksyms.h"
-#include "sysmon_taskq.h"
#include "veriexec.h"
#include <sys/param.h>
@@ -218,10 +217,6 @@
#include <uvm/uvm.h> /* extern struct uvm uvm */
-#if NSYSMON_TASKQ > 0
-#include <dev/sysmon/sysmon_taskq.h>
-#endif
-
#include <dev/cons.h>
#include <net/bpf.h>
@@ -460,16 +455,6 @@
/* Initialize kqueue. */
kqueue_init();
- /*
- * Initialize sysmon's task queue. It is used by at
- * least one non-modularized component (dev/acpica)
- * and needs to be available early, before the rest
- * of the module(9) subsystem is ready.
- */
-#if NSYSMON_TASKQ > 0
- sysmon_task_queue_preinit();
-#endif
-
inittimecounter();
ntp_init();
Home |
Main Index |
Thread Index |
Old Index