Module Name: src
Committed By: thorpej
Date: Wed Dec 26 22:16:27 UTC 2018
Modified Files:
src/sys/kern: init_main.c kern_threadpool.c
src/sys/rump/librump/rumpkern: rump.c
src/sys/sys: threadpool.h
Log Message:
Rather than performing lazy initialization, statically initialize early
in the respective kernel startup routines.
To generate a diff of this commit:
cvs rdiff -u -r1.500 -r1.501 src/sys/kern/init_main.c
cvs rdiff -u -r1.10 -r1.11 src/sys/kern/kern_threadpool.c
cvs rdiff -u -r1.331 -r1.332 src/sys/rump/librump/rumpkern/rump.c
cvs rdiff -u -r1.5 -r1.6 src/sys/sys/threadpool.h
Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.
Modified files:
Index: src/sys/kern/init_main.c
diff -u src/sys/kern/init_main.c:1.500 src/sys/kern/init_main.c:1.501
--- src/sys/kern/init_main.c:1.500 Tue Oct 30 19:40:35 2018
+++ src/sys/kern/init_main.c Wed Dec 26 22:16:26 2018
@@ -1,4 +1,4 @@
-/* $NetBSD: init_main.c,v 1.500 2018/10/30 19:40:35 kre Exp $ */
+/* $NetBSD: init_main.c,v 1.501 2018/12/26 22:16:26 thorpej 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.500 2018/10/30 19:40:35 kre Exp $");
+__KERNEL_RCSID(0, "$NetBSD: init_main.c,v 1.501 2018/12/26 22:16:26 thorpej Exp $");
#include "opt_ddb.h"
#include "opt_inet.h"
@@ -178,6 +178,7 @@ extern void *_binary_splash_image_end;
#include <sys/uidinfo.h>
#include <sys/kprintf.h>
#include <sys/bufq.h>
+#include <sys/threadpool.h>
#ifdef IPSEC
#include <netipsec/ipsec.h>
#endif
@@ -405,6 +406,9 @@ main(void)
/* Disable preemption during boot. */
kpreempt_disable();
+ /* Initialize the threadpool system. */
+ threadpools_init();
+
/* Initialize the UID hash table. */
uid_init();
Index: src/sys/kern/kern_threadpool.c
diff -u src/sys/kern/kern_threadpool.c:1.10 src/sys/kern/kern_threadpool.c:1.11
--- src/sys/kern/kern_threadpool.c:1.10 Wed Dec 26 21:43:39 2018
+++ src/sys/kern/kern_threadpool.c Wed Dec 26 22:16:26 2018
@@ -1,4 +1,4 @@
-/* $NetBSD: kern_threadpool.c,v 1.10 2018/12/26 21:43:39 thorpej Exp $ */
+/* $NetBSD: kern_threadpool.c,v 1.11 2018/12/26 22:16:26 thorpej Exp $ */
/*-
* Copyright (c) 2014, 2018 The NetBSD Foundation, Inc.
@@ -81,7 +81,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: kern_threadpool.c,v 1.10 2018/12/26 21:43:39 thorpej Exp $");
+__KERNEL_RCSID(0, "$NetBSD: kern_threadpool.c,v 1.11 2018/12/26 22:16:26 thorpej Exp $");
#include <sys/types.h>
#include <sys/param.h>
@@ -100,15 +100,6 @@ __KERNEL_RCSID(0, "$NetBSD: kern_threadp
#include <sys/systm.h>
#include <sys/threadpool.h>
-static ONCE_DECL(threadpool_init_once)
-
-#define THREADPOOL_INIT() \
-do { \
- int threadpool_init_error __diagused = \
- RUN_ONCE(&threadpool_init_once, threadpools_init); \
- KASSERT(threadpool_init_error == 0); \
-} while (/*CONSTCOND*/0)
-
/* Data structures */
TAILQ_HEAD(job_head, threadpool_job);
@@ -234,7 +225,7 @@ threadpool_remove_percpu(struct threadpo
#define TP_LOG(x) /* nothing */
#endif /* THREADPOOL_VERBOSE */
-static int
+void
threadpools_init(void)
{
@@ -245,11 +236,6 @@ threadpools_init(void)
LIST_INIT(&unbound_threadpools);
LIST_INIT(&percpu_threadpools);
mutex_init(&threadpools_lock, MUTEX_DEFAULT, IPL_NONE);
-
- TP_LOG(("%s: sizeof(threadpool_job) = %zu\n",
- __func__, sizeof(struct threadpool_job)));
-
- return 0;
}
/* Thread pool creation */
@@ -373,8 +359,6 @@ threadpool_get(struct threadpool **poolp
struct threadpool_unbound *tpu, *tmp = NULL;
int error;
- THREADPOOL_INIT();
-
ASSERT_SLEEPABLE();
if (! threadpool_pri_is_valid(pri))
@@ -422,8 +406,6 @@ threadpool_put(struct threadpool *pool,
struct threadpool_unbound *tpu =
container_of(pool, struct threadpool_unbound, tpu_pool);
- THREADPOOL_INIT();
-
ASSERT_SLEEPABLE();
KASSERT(threadpool_pri_is_valid(pri));
@@ -454,8 +436,6 @@ threadpool_percpu_get(struct threadpool_
struct threadpool_percpu *pool_percpu, *tmp = NULL;
int error;
- THREADPOOL_INIT();
-
ASSERT_SLEEPABLE();
if (! threadpool_pri_is_valid(pri))
@@ -497,8 +477,6 @@ void
threadpool_percpu_put(struct threadpool_percpu *pool_percpu, pri_t pri)
{
- THREADPOOL_INIT();
-
ASSERT_SLEEPABLE();
KASSERT(threadpool_pri_is_valid(pri));
Index: src/sys/rump/librump/rumpkern/rump.c
diff -u src/sys/rump/librump/rumpkern/rump.c:1.331 src/sys/rump/librump/rumpkern/rump.c:1.332
--- src/sys/rump/librump/rumpkern/rump.c:1.331 Tue Jan 9 04:55:43 2018
+++ src/sys/rump/librump/rumpkern/rump.c Wed Dec 26 22:16:27 2018
@@ -1,4 +1,4 @@
-/* $NetBSD: rump.c,v 1.331 2018/01/09 04:55:43 msaitoh Exp $ */
+/* $NetBSD: rump.c,v 1.332 2018/12/26 22:16:27 thorpej Exp $ */
/*
* Copyright (c) 2007-2011 Antti Kantee. All Rights Reserved.
@@ -26,7 +26,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: rump.c,v 1.331 2018/01/09 04:55:43 msaitoh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: rump.c,v 1.332 2018/12/26 22:16:27 thorpej Exp $");
#include <sys/systm.h>
#define ELFSIZE ARCH_ELFSIZE
@@ -65,6 +65,7 @@ __KERNEL_RCSID(0, "$NetBSD: rump.c,v 1.3
#include <sys/sysctl.h>
#include <sys/syscall.h>
#include <sys/syscallvar.h>
+#include <sys/threadpool.h>
#include <sys/timetc.h>
#include <sys/tty.h>
#include <sys/uidinfo.h>
@@ -341,6 +342,8 @@ rump_init(void)
lwpinit_specificdata();
lwp_initspecific(&lwp0);
+ threadpools_init();
+
loginit();
rump_biglock_init();
Index: src/sys/sys/threadpool.h
diff -u src/sys/sys/threadpool.h:1.5 src/sys/sys/threadpool.h:1.6
--- src/sys/sys/threadpool.h:1.5 Wed Dec 26 21:43:39 2018
+++ src/sys/sys/threadpool.h Wed Dec 26 22:16:27 2018
@@ -1,4 +1,4 @@
-/* $NetBSD: threadpool.h,v 1.5 2018/12/26 21:43:39 thorpej Exp $ */
+/* $NetBSD: threadpool.h,v 1.6 2018/12/26 22:16:27 thorpej Exp $ */
/*-
* Copyright (c) 2014 The NetBSD Foundation, Inc.
@@ -58,6 +58,8 @@ struct threadpool_job {
char job_name[MAXCOMLEN];
};
+void threadpools_init(void);
+
int threadpool_get(struct threadpool **, pri_t);
void threadpool_put(struct threadpool *, pri_t);