Source-Changes-HG archive

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

[src/trunk]: src/sys ipi: Split up initialization into two parts.



details:   https://anonhg.NetBSD.org/src/rev/86809566e12d
branches:  trunk
changeset: 975913:86809566e12d
user:      riastradh <riastradh%NetBSD.org@localhost>
date:      Tue Sep 08 16:00:35 2020 +0000

description:
ipi: Split up initialization into two parts.

First part runs early so ipi_register can be used in module
initialization, e.g. via pktqueue_create; second part runs after CPUs
have been detected.

diffstat:

 sys/kern/init_main.c |  10 +++++++---
 sys/kern/subr_ipi.c  |  30 ++++++++++++++++++------------
 sys/sys/ipi.h        |   3 ++-
 3 files changed, 27 insertions(+), 16 deletions(-)

diffs (117 lines):

diff -r bc40a5c1743f -r 86809566e12d sys/kern/init_main.c
--- a/sys/kern/init_main.c      Tue Sep 08 15:36:37 2020 +0000
+++ b/sys/kern/init_main.c      Tue Sep 08 16:00:35 2020 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: init_main.c,v 1.530 2020/09/07 03:50:41 thorpej Exp $  */
+/*     $NetBSD: init_main.c,v 1.531 2020/09/08 16:00:35 riastradh Exp $        */
 
 /*-
  * Copyright (c) 2008, 2009, 2019 The NetBSD Foundation, Inc.
@@ -97,7 +97,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: init_main.c,v 1.530 2020/09/07 03:50:41 thorpej Exp $");
+__KERNEL_RCSID(0, "$NetBSD: init_main.c,v 1.531 2020/09/08 16:00:35 riastradh Exp $");
 
 #include "opt_cnmagic.h"
 #include "opt_ddb.h"
@@ -362,6 +362,9 @@
         */
        bpf_setops();
 
+       /* Initialize what we can in ipi(9) before CPUs are detected. */
+       ipi_sysinit();
+
        /* Start module system. */
        module_init();
        module_hook_init();
@@ -546,7 +549,8 @@
 
        configure2();
 
-       ipi_sysinit();
+       /* Initialize the rest of ipi(9) after CPUs have been detected. */
+       ipi_percpu_init();
 
        futex_sys_init();
 
diff -r bc40a5c1743f -r 86809566e12d sys/kern/subr_ipi.c
--- a/sys/kern/subr_ipi.c       Tue Sep 08 15:36:37 2020 +0000
+++ b/sys/kern/subr_ipi.c       Tue Sep 08 16:00:35 2020 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: subr_ipi.c,v 1.7 2019/10/16 18:29:49 christos Exp $    */
+/*     $NetBSD: subr_ipi.c,v 1.8 2020/09/08 16:00:35 riastradh Exp $   */
 
 /*-
  * Copyright (c) 2014 The NetBSD Foundation, Inc.
@@ -36,7 +36,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: subr_ipi.c,v 1.7 2019/10/16 18:29:49 christos Exp $");
+__KERNEL_RCSID(0, "$NetBSD: subr_ipi.c,v 1.8 2020/09/08 16:00:35 riastradh Exp $");
 
 #include <sys/param.h>
 #include <sys/types.h>
@@ -93,20 +93,10 @@
 void
 ipi_sysinit(void)
 {
-       const size_t len = ncpu * sizeof(ipi_mbox_t);
 
-       /* Initialise the per-CPU bit fields. */
-       for (u_int i = 0; i < ncpu; i++) {
-               struct cpu_info *ci = cpu_lookup(i);
-               memset(&ci->ci_ipipend, 0, sizeof(ci->ci_ipipend));
-       }
        mutex_init(&ipi_mngmt_lock, MUTEX_DEFAULT, IPL_NONE);
        memset(ipi_intrs, 0, sizeof(ipi_intrs));
 
-       /* Allocate per-CPU IPI mailboxes. */
-       ipi_mboxes = kmem_zalloc(len, KM_SLEEP);
-       KASSERT(ipi_mboxes != NULL);
-
        /*
         * Register the handler for synchronous IPIs.  This mechanism
         * is built on top of the asynchronous interface.  Slot zero is
@@ -119,6 +109,22 @@
           "ipi", "full");
 }
 
+void
+ipi_percpu_init(void)
+{
+       const size_t len = ncpu * sizeof(ipi_mbox_t);
+
+       /* Initialise the per-CPU bit fields. */
+       for (u_int i = 0; i < ncpu; i++) {
+               struct cpu_info *ci = cpu_lookup(i);
+               memset(&ci->ci_ipipend, 0, sizeof(ci->ci_ipipend));
+       }
+
+       /* Allocate per-CPU IPI mailboxes. */
+       ipi_mboxes = kmem_zalloc(len, KM_SLEEP);
+       KASSERT(ipi_mboxes != NULL);
+}
+
 /*
  * ipi_register: register an asynchronous IPI handler.
  *
diff -r bc40a5c1743f -r 86809566e12d sys/sys/ipi.h
--- a/sys/sys/ipi.h     Tue Sep 08 15:36:37 2020 +0000
+++ b/sys/sys/ipi.h     Tue Sep 08 16:00:35 2020 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: ipi.h,v 1.4 2019/04/06 02:59:05 thorpej Exp $  */
+/*     $NetBSD: ipi.h,v 1.5 2020/09/08 16:00:35 riastradh Exp $        */
 
 /*-
  * Copyright (c) 2014 The NetBSD Foundation, Inc.
@@ -60,6 +60,7 @@
 #define        IPI_BITWORDS    (IPI_MAXREG >> IPI_BITW_SHIFT)
 
 void   ipi_sysinit(void);
+void   ipi_percpu_init(void);
 void   ipi_cpu_handler(void);
 void   cpu_ipi(struct cpu_info *);
 



Home | Main Index | Thread Index | Old Index