summaryrefslogtreecommitdiff
path: root/sys/kern/subr_sleepqueue.c
diff options
context:
space:
mode:
authorAttilio Rao <attilio@FreeBSD.org>2014-06-24 15:16:55 +0000
committerAttilio Rao <attilio@FreeBSD.org>2014-06-24 15:16:55 +0000
commite989086b1d379801d659fd24275f62da716cc081 (patch)
tree85313132b1035009d1870974447377fabdfd196a /sys/kern/subr_sleepqueue.c
parent0e1c7b34cc0f5bb5934a3cc076019689d6bbd302 (diff)
Notes
Diffstat (limited to 'sys/kern/subr_sleepqueue.c')
-rw-r--r--sys/kern/subr_sleepqueue.c41
1 files changed, 28 insertions, 13 deletions
diff --git a/sys/kern/subr_sleepqueue.c b/sys/kern/subr_sleepqueue.c
index c9d5123d7883..bbbec920ef0d 100644
--- a/sys/kern/subr_sleepqueue.c
+++ b/sys/kern/subr_sleepqueue.c
@@ -166,24 +166,20 @@ SDT_PROBE_DECLARE(sched, , , sleep);
SDT_PROBE_DECLARE(sched, , , wakeup);
/*
- * Early initialization of sleep queues that is called from the sleepinit()
- * SYSINIT.
+ * Initialize SLEEPQUEUE_PROFILING specific sysctl nodes.
+ * Note that it must happen after sleepinit() has been fully executed, so
+ * it must happen after SI_SUB_KMEM SYSINIT() subsystem setup.
*/
-void
-init_sleepqueues(void)
-{
#ifdef SLEEPQUEUE_PROFILING
- struct sysctl_oid *chain_oid;
+static void
+init_sleepqueue_profiling(void)
+{
char chain_name[10];
-#endif
- int i;
+ struct sysctl_oid *chain_oid;
+ u_int i;
for (i = 0; i < SC_TABLESIZE; i++) {
- LIST_INIT(&sleepq_chains[i].sc_queues);
- mtx_init(&sleepq_chains[i].sc_lock, "sleepq chain", NULL,
- MTX_SPIN | MTX_RECURSE);
-#ifdef SLEEPQUEUE_PROFILING
- snprintf(chain_name, sizeof(chain_name), "%d", i);
+ snprintf(chain_name, sizeof(chain_name), "%u", i);
chain_oid = SYSCTL_ADD_NODE(NULL,
SYSCTL_STATIC_CHILDREN(_debug_sleepq_chains), OID_AUTO,
chain_name, CTLFLAG_RD, NULL, "sleepq chain stats");
@@ -192,7 +188,26 @@ init_sleepqueues(void)
SYSCTL_ADD_UINT(NULL, SYSCTL_CHILDREN(chain_oid), OID_AUTO,
"max_depth", CTLFLAG_RD, &sleepq_chains[i].sc_max_depth, 0,
NULL);
+ }
+}
+
+SYSINIT(sleepqueue_profiling, SI_SUB_LOCK, SI_ORDER_ANY,
+ init_sleepqueue_profiling, NULL);
#endif
+
+/*
+ * Early initialization of sleep queues that is called from the sleepinit()
+ * SYSINIT.
+ */
+void
+init_sleepqueues(void)
+{
+ int i;
+
+ for (i = 0; i < SC_TABLESIZE; i++) {
+ LIST_INIT(&sleepq_chains[i].sc_queues);
+ mtx_init(&sleepq_chains[i].sc_lock, "sleepq chain", NULL,
+ MTX_SPIN | MTX_RECURSE);
}
sleepq_zone = uma_zcreate("SLEEPQUEUE", sizeof(struct sleepqueue),
#ifdef INVARIANTS