Module Name: src
Committed By: riastradh
Date: Tue Sep 8 16:00:35 UTC 2020
Modified Files:
src/sys/kern: init_main.c subr_ipi.c
src/sys/sys: ipi.h
Log Message:
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.
To generate a diff of this commit:
cvs rdiff -u -r1.530 -r1.531 src/sys/kern/init_main.c
cvs rdiff -u -r1.7 -r1.8 src/sys/kern/subr_ipi.c
cvs rdiff -u -r1.4 -r1.5 src/sys/sys/ipi.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.530 src/sys/kern/init_main.c:1.531
--- src/sys/kern/init_main.c:1.530 Mon Sep 7 03:50:41 2020
+++ src/sys/kern/init_main.c Tue Sep 8 16:00:35 2020
@@ -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 @@ main(void)
*/
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 @@ main(void)
configure2();
- ipi_sysinit();
+ /* Initialize the rest of ipi(9) after CPUs have been detected. */
+ ipi_percpu_init();
futex_sys_init();
Index: src/sys/kern/subr_ipi.c
diff -u src/sys/kern/subr_ipi.c:1.7 src/sys/kern/subr_ipi.c:1.8
--- src/sys/kern/subr_ipi.c:1.7 Wed Oct 16 18:29:49 2019
+++ src/sys/kern/subr_ipi.c Tue Sep 8 16:00:35 2020
@@ -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 @@ static void ipi_msg_cpu_handler(void *)
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_sysinit(void)
"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.
*
Index: src/sys/sys/ipi.h
diff -u src/sys/sys/ipi.h:1.4 src/sys/sys/ipi.h:1.5
--- src/sys/sys/ipi.h:1.4 Sat Apr 6 02:59:05 2019
+++ src/sys/sys/ipi.h Tue Sep 8 16:00:35 2020
@@ -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 @@ typedef struct {
#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 *);