From nobody Tue Aug 30 02:24:55 2022 X-Original-To: dev-commits-src-all@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id 4MGrk01KdMz4bJ89; Tue, 30 Aug 2022 02:24:56 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4MGrk00MdGz431l; Tue, 30 Aug 2022 02:24:56 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1661826296; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=dCoBKuaU1m7HfWQy4uYMb2shcj2nZUS8TDVWKzLdk98=; b=vSsp0GnQRMnIOrwTuuxRgxtf98wsRoFJwTJ7RCtHRMHzp530mL1Vp2NJmQ2AsJfDBawlKN ycldSXgXPVjI9blPdOFP3w+f9bLcuKIi9HDuOcVGqQp7aQZ3/eP/aX5yWBWktaoHKmpKIx Hx3y1yO07/pd2Epjkb+Pns4ZrNXvSy/P2bwpy474sETcDXEL5u/OG+rWkYbOAVW/ATsp96 IkOqa1xwiuIVdxAk5ssqHgLWTTwXDu18oSXnPYTv9vDRKjvCUg42mhdOZ7NMkLsiusf4Mg MSJFNh0yZmJxvkCVkolQncyJo0h18RyZJBUzA2jGTxpH5AN7xVBgRGDjgtzRxQ== Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 4MGrjz6ZfQzdcM; Tue, 30 Aug 2022 02:24:55 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.16.1/8.16.1) with ESMTP id 27U2OtSV008125; Tue, 30 Aug 2022 02:24:55 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 27U2OtmP008124; Tue, 30 Aug 2022 02:24:55 GMT (envelope-from git) Date: Tue, 30 Aug 2022 02:24:55 GMT Message-Id: <202208300224.27U2OtmP008124@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Gleb Smirnoff Subject: git: 244e1aeaec9a - main - domains: merge domain_init() into domain_add() List-Id: Commit messages for all branches of the src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-all List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-dev-commits-src-all@freebsd.org X-BeenThere: dev-commits-src-all@freebsd.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: glebius X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: 244e1aeaec9a6f34e27377a35bdf39ddd4c72191 Auto-Submitted: auto-generated ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1661826296; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=dCoBKuaU1m7HfWQy4uYMb2shcj2nZUS8TDVWKzLdk98=; b=AHoSuZem4TFV4PCKEEZUQ+55Is9CGeRXMp28r6Ck/M8LSXsySpGB/OsxNm2fT7PL4V3PEk qWw73gqu15V/otsZtFO47Woe6jY14Q0VUrBTzcQdQ/kLth4Xj45xjtJqETTVQquGKM72zc tLgcaRH7m5VXw6W4Ig5Tfev2PPiKQf2iRoeHJICL3ievY27lZ61vVE1K/Tc1OGxUynxshN CXfV3hLhJdMKP+eHfrp26tAd40R+4A1O4paCGuBll4PJKRqt8rEmbFXEMZ9PhhPBX/Y4b9 YrpcJpIC4bvpJWkguc5wIM6/jhM6xHYOBad/zQu1l17atEkupz+jTjjaWR+oEQ== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1661826296; a=rsa-sha256; cv=none; b=sy/xGvjyB1Nxk/R3dN62+LnM0lbyx8qg/P11xZ0GkhKNGAsUfoiL4N3KntDfJCorL8Kxxv EV5bCbKwnEfFtYqvtrlVWug0hsYvFDs+eg33TNCX/nh3Fzc28hp3F0abi2YkePtWKP50hh NUj6M7UYO9qqeIau/llvPkhwUk5JbMCTLsfnQJukihoJ2TubXqL8fDQ98wj+w7m/bcKtgl 9NrIBLRjXGy/2ATmg7L4WihOT6YnqrDfgJJNrSZu3AESa3PL/Hg6BbZWmMGKksN7q2oLg1 Xkcykujfm2bUNi59H1JfBMNopLIvJONpyHsewqssViQqI7k/095raNBv7cNqyA== ARC-Authentication-Results: i=1; mx1.freebsd.org; none X-ThisMailContainsUnwantedMimeParts: N The branch main has been updated by glebius: URL: https://cgit.FreeBSD.org/src/commit/?id=244e1aeaec9a6f34e27377a35bdf39ddd4c72191 commit 244e1aeaec9a6f34e27377a35bdf39ddd4c72191 Author: Gleb Smirnoff AuthorDate: 2022-08-30 02:15:01 +0000 Commit: Gleb Smirnoff CommitDate: 2022-08-30 02:15:01 +0000 domains: merge domain_init() into domain_add() domain_init() called at SI_SUB_PROTO_DOMAIN/SI_ORDER_SECOND is always called right after domain_add(), that had been called at SI_ORDER_FIRST. Note that protocols aren't initialized yet at this point, since they are usually scheduled to initialize at SI_ORDER_THIRD. After this merge it becomes clear that DOMF_SUPPORTED / DOMF_INITED can be garbage collected as they are set & checked in the same function. For initialization of the domain system itself it is now clear that domaininit() can be garbage collected and static initializer is enough. --- sys/kern/uipc_domain.c | 71 +++++++------------------------------------------- sys/sys/domain.h | 7 +---- 2 files changed, 11 insertions(+), 67 deletions(-) diff --git a/sys/kern/uipc_domain.c b/sys/kern/uipc_domain.c index b12aefbd2a2d..5fb602226bae 100644 --- a/sys/kern/uipc_domain.c +++ b/sys/kern/uipc_domain.c @@ -52,27 +52,8 @@ __FBSDID("$FreeBSD$"); #include -/* - * System initialization - * - * Note: domain initialization takes place on a per domain basis - * as a result of traversing a SYSINIT linker set. Most likely, - * each domain would want to call DOMAIN_SET(9) itself, which - * would cause the domain to be added just after domaininit() - * is called during startup. - * - * See DOMAIN_SET(9) for details on its use. - */ - -static void domaininit(void *); -SYSINIT(domain, SI_SUB_PROTO_DOMAININIT, SI_ORDER_ANY, domaininit, NULL); - -static void domainfinalize(void *); -SYSINIT(domainfin, SI_SUB_PROTO_IFATTACHDOMAIN, SI_ORDER_FIRST, domainfinalize, - NULL); - struct domainhead domains = SLIST_HEAD_INITIALIZER(&domains); -int domain_init_status = 0; +int domain_init_status = 1; static struct mtx dom_mtx; /* domain list lock */ MTX_SYSINIT(domain, &dom_mtx, "domain list", MTX_DEF); @@ -250,48 +231,26 @@ pr_init(struct domain *dom, struct protosw *pr) * XXX can't fail at this time. */ void -domain_init(struct domain *dp) +domain_add(struct domain *dp) { struct protosw *pr; - int flags; MPASS(IS_DEFAULT_VNET(curvnet)); - flags = atomic_load_acq_int(&dp->dom_flags); - if ((flags & DOMF_SUPPORTED) == 0) + if (dp->dom_probe != NULL && (*dp->dom_probe)() != 0) return; - MPASS((flags & DOMF_INITED) == 0); for (int i = 0; i < dp->dom_nprotosw; i++) if ((pr = dp->dom_protosw[i]) != NULL) pr_init(dp, pr); - atomic_set_rel_int(&dp->dom_flags, DOMF_INITED); -} - -/* - * Add a new protocol domain to the list of supported domains - * Note: you cant unload it again because a socket may be using it. - * XXX can't fail at this time. - */ -void -domain_add(struct domain *dp) -{ - - if (dp->dom_probe != NULL && (*dp->dom_probe)() != 0) - return; - atomic_set_rel_int(&dp->dom_flags, DOMF_SUPPORTED); mtx_lock(&dom_mtx); - SLIST_INSERT_HEAD(&domains, dp, dom_next); - - KASSERT(domain_init_status >= 1, - ("attempt to domain_add(%s) before domaininit()", - dp->dom_name)); -#ifndef INVARIANTS - if (domain_init_status < 1) - printf("WARNING: attempt to domain_add(%s) before " - "domaininit()\n", dp->dom_name); +#ifdef INVARIANTS + struct domain *tmp; + SLIST_FOREACH(tmp, &domains, dom_next) + MPASS(tmp->dom_family != dp->dom_family); #endif + SLIST_INSERT_HEAD(&domains, dp, dom_next); mtx_unlock(&dom_mtx); } @@ -307,18 +266,6 @@ domain_remove(struct domain *dp) mtx_unlock(&dom_mtx); } -/* ARGSUSED*/ -static void -domaininit(void *dummy) -{ - - mtx_lock(&dom_mtx); - KASSERT(domain_init_status == 0, ("domaininit called too late!")); - domain_init_status = 1; - mtx_unlock(&dom_mtx); -} - -/* ARGSUSED*/ static void domainfinalize(void *dummy) { @@ -328,6 +275,8 @@ domainfinalize(void *dummy) domain_init_status = 2; mtx_unlock(&dom_mtx); } +SYSINIT(domainfin, SI_SUB_PROTO_IFATTACHDOMAIN, SI_ORDER_FIRST, domainfinalize, + NULL); struct domain * pffinddomain(int family) diff --git a/sys/sys/domain.h b/sys/sys/domain.h index 9b0e28137e18..4570f25201fa 100644 --- a/sys/sys/domain.h +++ b/sys/sys/domain.h @@ -71,8 +71,6 @@ struct domain { }; /* dom_flags */ -#define DOMF_SUPPORTED 0x0001 /* System supports this domain. */ -#define DOMF_INITED 0x0002 /* Initialized in the default vnet. */ #define DOMF_UNLOADABLE 0x0004 /* Can be unloaded */ #ifdef _KERNEL @@ -80,7 +78,6 @@ extern int domain_init_status; extern SLIST_HEAD(domainhead, domain) domains; void domain_add(struct domain *); void domain_remove(struct domain *); -void domain_init(struct domain *); #ifdef VIMAGE void vnet_domain_init(void *); void vnet_domain_uninit(void *); @@ -90,9 +87,7 @@ void vnet_domain_uninit(void *); SYSINIT(domain_add_ ## name, SI_SUB_PROTO_DOMAIN, \ SI_ORDER_FIRST, domain_add, & name ## domain); \ SYSUNINIT(domain_remove_ ## name, SI_SUB_PROTO_DOMAIN, \ - SI_ORDER_FIRST, domain_remove, & name ## domain); \ - SYSINIT(domain_init_ ## name, SI_SUB_PROTO_DOMAIN, \ - SI_ORDER_SECOND, domain_init, & name ## domain); + SI_ORDER_FIRST, domain_remove, & name ## domain); #endif /* _KERNEL */ #endif /* !_SYS_DOMAIN_H_ */