From f66d0b978704b4fe9ede789cd2a18e5189e1e28d Mon Sep 17 00:00:00 2001 From: Mark Johnston Date: Mon, 27 Feb 2023 14:04:53 -0500 Subject: [PATCH 51/52] shm: Allow shm_alloc() to be called earlier during boot This allows shm_alloc() to be called at SI_SUB_INTRINSIC or later. --- sys/kern/uipc_shm.c | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/sys/kern/uipc_shm.c b/sys/kern/uipc_shm.c index 8636466ef378..dd422a5f6135 100644 --- a/sys/kern/uipc_shm.c +++ b/sys/kern/uipc_shm.c @@ -939,6 +939,16 @@ shm_access(struct shmfd *shmfd, struct ucred *ucred, int flags) return (error); } +/* + * Allow shm_alloc() to be called before SI_SUB_SYSV_SHM. + */ +static void +shm_init_early(void *arg __unused) +{ + new_unrhdr64(&shm_ino_unr, 1); +} +SYSINIT(shm_init_early, SI_SUB_INTRINSIC, SI_ORDER_ANY, shm_init_early, NULL); + /* * Dictionary management. We maintain an in-kernel dictionary to map * paths to shmfd objects. We use the FNV hash on the path to store @@ -953,7 +963,6 @@ shm_init(void *arg) mtx_init(&shm_timestamp_lock, "shm timestamps", NULL, MTX_DEF); sx_init(&shm_dict_lock, "shm dictionary"); shm_dictionary = hashinit(1024, M_SHMFD, &shm_hash); - new_unrhdr64(&shm_ino_unr, 1); shm_dev_ino = devfs_alloc_cdp_inode(); KASSERT(shm_dev_ino > 0, ("shm dev inode not initialized")); -- 2.41.0