Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/sys Rather than performing lazy initialization, statically i...



details:   https://anonhg.NetBSD.org/src/rev/d6d6e3a3be1e
branches:  trunk
changeset: 837914:d6d6e3a3be1e
user:      thorpej <thorpej%NetBSD.org@localhost>
date:      Wed Dec 26 22:16:26 2018 +0000

description:
Rather than performing lazy initialization, statically initialize early
in the respective kernel startup routines.

diffstat:

 sys/kern/init_main.c             |   8 ++++++--
 sys/kern/kern_threadpool.c       |  28 +++-------------------------
 sys/rump/librump/rumpkern/rump.c |   7 +++++--
 sys/sys/threadpool.h             |   4 +++-
 4 files changed, 17 insertions(+), 30 deletions(-)

diffs (180 lines):

diff -r 595e178154ca -r d6d6e3a3be1e sys/kern/init_main.c
--- a/sys/kern/init_main.c      Wed Dec 26 21:48:55 2018 +0000
+++ b/sys/kern/init_main.c      Wed Dec 26 22:16:26 2018 +0000
@@ -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 @@
 #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 @@
        /* Disable preemption during boot. */
        kpreempt_disable();
 
+       /* Initialize the threadpool system. */
+       threadpools_init();
+
        /* Initialize the UID hash table. */
        uid_init();
 
diff -r 595e178154ca -r d6d6e3a3be1e sys/kern/kern_threadpool.c
--- a/sys/kern/kern_threadpool.c        Wed Dec 26 21:48:55 2018 +0000
+++ b/sys/kern/kern_threadpool.c        Wed Dec 26 22:16:26 2018 +0000
@@ -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 @@
 #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 @@
 #define        TP_LOG(x)               /* nothing */
 #endif /* THREADPOOL_VERBOSE */
 
-static int
+void
 threadpools_init(void)
 {
 
@@ -245,11 +236,6 @@
        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 @@
        struct threadpool_unbound *tpu, *tmp = NULL;
        int error;
 
-       THREADPOOL_INIT();
-
        ASSERT_SLEEPABLE();
 
        if (! threadpool_pri_is_valid(pri))
@@ -422,8 +406,6 @@
        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 @@
        struct threadpool_percpu *pool_percpu, *tmp = NULL;
        int error;
 
-       THREADPOOL_INIT();
-
        ASSERT_SLEEPABLE();
 
        if (! threadpool_pri_is_valid(pri))
@@ -497,8 +477,6 @@
 threadpool_percpu_put(struct threadpool_percpu *pool_percpu, pri_t pri)
 {
 
-       THREADPOOL_INIT();
-
        ASSERT_SLEEPABLE();
 
        KASSERT(threadpool_pri_is_valid(pri));
diff -r 595e178154ca -r d6d6e3a3be1e sys/rump/librump/rumpkern/rump.c
--- a/sys/rump/librump/rumpkern/rump.c  Wed Dec 26 21:48:55 2018 +0000
+++ b/sys/rump/librump/rumpkern/rump.c  Wed Dec 26 22:16:26 2018 +0000
@@ -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 @@
 #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 @@
        lwpinit_specificdata();
        lwp_initspecific(&lwp0);
 
+       threadpools_init();
+
        loginit();
 
        rump_biglock_init();
diff -r 595e178154ca -r d6d6e3a3be1e sys/sys/threadpool.h
--- a/sys/sys/threadpool.h      Wed Dec 26 21:48:55 2018 +0000
+++ b/sys/sys/threadpool.h      Wed Dec 26 22:16:26 2018 +0000
@@ -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 @@
        char                            job_name[MAXCOMLEN];
 };
 
+void   threadpools_init(void);
+
 int    threadpool_get(struct threadpool **, pri_t);
 void   threadpool_put(struct threadpool *, pri_t);
 



Home | Main Index | Thread Index | Old Index