From nobody Fri Dec 10 00:05:11 2021 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 8501918C9127; Fri, 10 Dec 2021 00:05:12 +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 4J9B4807Bpz4VQq; Fri, 10 Dec 2021 00:05:12 +0000 (UTC) (envelope-from git@FreeBSD.org) 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 C728910B0C; Fri, 10 Dec 2021 00:05:11 +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 1BA05BUE060461; Fri, 10 Dec 2021 00:05:11 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 1BA05Bfn060460; Fri, 10 Dec 2021 00:05:11 GMT (envelope-from git) Date: Fri, 10 Dec 2021 00:05:11 GMT Message-Id: <202112100005.1BA05Bfn060460@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Warner Losh Subject: git: 815a0973b23c - main - bus: mark sysctls MPSAFE 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: imp X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: 815a0973b23cf97e3e6c2d8bd34d98d54e318873 Auto-Submitted: auto-generated ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1639094712; 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=+KAbFQ+hJDIunc8rzZmerQXismdxwQnBRhEmyhIBwkQ=; b=cYo4nG1SzNK877WY0YyRzsmcAgKhTQT6hdoGkKkkq5S/OCDevX5uSibLKo/oymLpmQnBMy 8wNJWL1TlpYmjbk/7cIZgOb36H/Uh4zZWMezcZriciiumgFW1xxwoXTJE/UsAJacEc6zUv cRnuVht1KXljLNtW4/y1L9TqtM/8r1QRGDSjz12tlwA6UhZHEZGLZ+rGH1pbmrnk6ox+5O fBgsCgVTm4F94YiI/RLi7Twn7f5QosIz8fiXGIbsMf7PsYvrrQJMb2oqXx/RIdWfg+ucpS 9GIS+4G4S126NoSMPiuREWw9/NPKXdiYMDwL7JQCWOqQ45TbIYJGTY/8aOBplA== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1639094712; a=rsa-sha256; cv=none; b=ZB4Rp6TE5wgARh7KpuP/bJfInxpWFY21HhC4Wolkf1EaMKA6n91CnvOfni6fh52HqbM3Ou 21rU0crlXDE1q7+2uVyZmsou8BZjLkEShsNy5+0KMWz/DuMIK7ZsSeHATBgGi+pKFa1shd XYiVRHWMKgfQyiKuTHWH6n5YTGkpankqn2SO88z/M9RCX4SRo42oGlPOVMXYXZVLJMZoLL FXyjoRoFYekEI7hyG+0X9+sHQEG0I9bSwCez03Uch6rldE7GsjO518HR4UU3VzVXfmGckH 1qAme8GWrLLUUnKn9oiHDBdaBKcRLe3zO1M4GwlTxti0SFd2lP2VCgDKzpF0Dg== ARC-Authentication-Results: i=1; mx1.freebsd.org; none X-ThisMailContainsUnwantedMimeParts: N The branch main has been updated by imp: URL: https://cgit.FreeBSD.org/src/commit/?id=815a0973b23cf97e3e6c2d8bd34d98d54e318873 commit 815a0973b23cf97e3e6c2d8bd34d98d54e318873 Author: Warner Losh AuthorDate: 2021-12-09 23:52:34 +0000 Commit: Warner Losh CommitDate: 2021-12-10 00:04:57 +0000 bus: mark sysctls MPSAFE Mark the sysctls MPSAFE and pickup the bus topo lock while processing them. Sponsored by: Netflix Reviewed by: mav, jhb Differential Revision: https://reviews.freebsd.org/D31832 --- sys/kern/subr_bus.c | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-) diff --git a/sys/kern/subr_bus.c b/sys/kern/subr_bus.c index 008cec6b5417..2544826e9028 100644 --- a/sys/kern/subr_bus.c +++ b/sys/kern/subr_bus.c @@ -267,6 +267,7 @@ device_sysctl_handler(SYSCTL_HANDLER_ARGS) sbuf_new_for_sysctl(&sb, NULL, 1024, req); sbuf_clear_flags(&sb, SBUF_INCLUDENUL); + bus_topo_lock(); switch (arg2) { case DEVICE_SYSCTL_DESC: sbuf_cat(&sb, dev->desc ? dev->desc : ""); @@ -284,10 +285,12 @@ device_sysctl_handler(SYSCTL_HANDLER_ARGS) sbuf_cat(&sb, dev->parent ? dev->parent->nameunit : ""); break; default: - sbuf_delete(&sb); - return (EINVAL); + error = EINVAL; + goto out; } error = sbuf_finish(&sb); +out: + bus_topo_unlock(); sbuf_delete(&sb); return (error); } @@ -307,33 +310,33 @@ device_sysctl_init(device_t dev) dev->nameunit + strlen(dc->name), CTLFLAG_RD | CTLFLAG_MPSAFE, NULL, "", "device_index"); SYSCTL_ADD_PROC(&dev->sysctl_ctx, SYSCTL_CHILDREN(dev->sysctl_tree), - OID_AUTO, "%desc", CTLTYPE_STRING | CTLFLAG_RD | CTLFLAG_NEEDGIANT, + OID_AUTO, "%desc", CTLTYPE_STRING | CTLFLAG_RD | CTLFLAG_MPSAFE, dev, DEVICE_SYSCTL_DESC, device_sysctl_handler, "A", "device description"); SYSCTL_ADD_PROC(&dev->sysctl_ctx, SYSCTL_CHILDREN(dev->sysctl_tree), OID_AUTO, "%driver", - CTLTYPE_STRING | CTLFLAG_RD | CTLFLAG_NEEDGIANT, + CTLTYPE_STRING | CTLFLAG_RD | CTLFLAG_MPSAFE, dev, DEVICE_SYSCTL_DRIVER, device_sysctl_handler, "A", "device driver name"); SYSCTL_ADD_PROC(&dev->sysctl_ctx, SYSCTL_CHILDREN(dev->sysctl_tree), OID_AUTO, "%location", - CTLTYPE_STRING | CTLFLAG_RD | CTLFLAG_NEEDGIANT, + CTLTYPE_STRING | CTLFLAG_RD | CTLFLAG_MPSAFE, dev, DEVICE_SYSCTL_LOCATION, device_sysctl_handler, "A", "device location relative to parent"); SYSCTL_ADD_PROC(&dev->sysctl_ctx, SYSCTL_CHILDREN(dev->sysctl_tree), OID_AUTO, "%pnpinfo", - CTLTYPE_STRING | CTLFLAG_RD | CTLFLAG_NEEDGIANT, + CTLTYPE_STRING | CTLFLAG_RD | CTLFLAG_MPSAFE, dev, DEVICE_SYSCTL_PNPINFO, device_sysctl_handler, "A", "device identification"); SYSCTL_ADD_PROC(&dev->sysctl_ctx, SYSCTL_CHILDREN(dev->sysctl_tree), OID_AUTO, "%parent", - CTLTYPE_STRING | CTLFLAG_RD | CTLFLAG_NEEDGIANT, + CTLTYPE_STRING | CTLFLAG_RD | CTLFLAG_MPSAFE, dev, DEVICE_SYSCTL_PARENT, device_sysctl_handler, "A", "parent device"); if (bus_get_domain(dev, &domain) == 0) SYSCTL_ADD_INT(&dev->sysctl_ctx, SYSCTL_CHILDREN(dev->sysctl_tree), OID_AUTO, "%domain", - CTLFLAG_RD, NULL, domain, "NUMA domain"); + CTLFLAG_RD | CTLFLAG_MPSAFE, NULL, domain, "NUMA domain"); } static void