From nobody Mon Jan 10 00:30:28 2022 X-Original-To: dev-commits-src-branches@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 CC21A194138C; Mon, 10 Jan 2022 00:30:29 +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 4JXF905pJjz56PP; Mon, 10 Jan 2022 00:30:28 +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 4D2611BD3A; Mon, 10 Jan 2022 00:30:28 +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 20A0USou054849; Mon, 10 Jan 2022 00:30:28 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 20A0USZ0054848; Mon, 10 Jan 2022 00:30:28 GMT (envelope-from git) Date: Mon, 10 Jan 2022 00:30:28 GMT Message-Id: <202201100030.20A0USZ0054848@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Alexander Motin Subject: git: 034c2781d511 - stable/13 - kern: Remove CTLFLAG_NEEDGIANT from some more sysctls. List-Id: Commits to the stable branches of the FreeBSD src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-branches List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-dev-commits-src-branches@freebsd.org X-BeenThere: dev-commits-src-branches@freebsd.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: mav X-Git-Repository: src X-Git-Refname: refs/heads/stable/13 X-Git-Reftype: branch X-Git-Commit: 034c2781d511a769439667743b279ba9907a1d2b Auto-Submitted: auto-generated ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1641774629; 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=5BBDxHQOCP/aCpsa/umT6zYbWZhco+GPVoS55FCqidg=; b=mlCGMU+Dahy4DxzW3AJZtVervjOKk+3S0J2UQxsJzmPRhRq2lWvCInTQ0f4wMp8ximhUXM fDzQfe6puOgqDF1G4dq+XrlmGgVIwodE6v5rnam8GYzDb6kePYBa4uJ5eUIcARcw1KHeFx xWXjz8kh/GIJR4MGamOQS6iYWtRMMYuIuCnOLSHdgfUIkfqCvZQGF3M60EPvZPlNwNHCHQ VqvpqQoD6whqN1Xpxku9kqnHHflZKe+sSnvEVJkrEPntUTL3g9IvjVXvjGg7LbH0ZKPt3+ CAI0qoF0H9E/FtSLZUldh1MuYLHe5vJ0CfVZgYKK8PLU0x7kBxP+FrP32c/tkQ== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1641774629; a=rsa-sha256; cv=none; b=j253s+SrH7SLOUkv+Odld47HwWLAf0n1ioppvK46R0iWDXUC4PqwdI0jycb8GT+9zqe/SL eWyEuMVwqjtmz/HYWVmjiAuPSxFOiq76nnLicNkDR871Ieh6VDLEOKU1O5iBjuafWxdHZE BuaGX737TXaC/lbygy7fe3KDX8acvSKeFuCgU0mmHS4a3/7a4+Shqh3jrB6lsDIBxsADDb wPmpeW9+VaSSAL8xQ+LrsHDUJzCugrYUYpe8ELUZ4X5b+3d71GenBlqvzF7uucQ8zYzWXE T99glZS8ztMszknrgLHKova0kc+MXVvdsZVDKnKpB8EB6BoUlCRZpcZi8m0MVQ== ARC-Authentication-Results: i=1; mx1.freebsd.org; none X-ThisMailContainsUnwantedMimeParts: N The branch stable/13 has been updated by mav: URL: https://cgit.FreeBSD.org/src/commit/?id=034c2781d511a769439667743b279ba9907a1d2b commit 034c2781d511a769439667743b279ba9907a1d2b Author: Alexander Motin AuthorDate: 2021-12-27 04:07:33 +0000 Commit: Alexander Motin CommitDate: 2022-01-10 00:30:09 +0000 kern: Remove CTLFLAG_NEEDGIANT from some more sysctls. MFC after: 2 weeks (cherry picked from commit c6c52d8e39b2dbee573bc80f32b5b7019cef1973) --- sys/kern/kern_mbuf.c | 10 +++++----- sys/kern/kern_switch.c | 2 +- sys/kern/subr_bus.c | 2 +- sys/kern/uipc_mbuf.c | 54 +++++++++++++++++--------------------------------- 4 files changed, 25 insertions(+), 43 deletions(-) diff --git a/sys/kern/kern_mbuf.c b/sys/kern/kern_mbuf.c index 3a389e1f2fd3..997ad16b211b 100644 --- a/sys/kern/kern_mbuf.c +++ b/sys/kern/kern_mbuf.c @@ -223,7 +223,7 @@ sysctl_nmbclusters(SYSCTL_HANDLER_ARGS) return (error); } SYSCTL_PROC(_kern_ipc, OID_AUTO, nmbclusters, - CTLTYPE_INT | CTLFLAG_RW | CTLFLAG_NEEDGIANT, &nmbclusters, 0, + CTLTYPE_INT | CTLFLAG_RW | CTLFLAG_MPSAFE, &nmbclusters, 0, sysctl_nmbclusters, "IU", "Maximum number of mbuf clusters allowed"); @@ -245,7 +245,7 @@ sysctl_nmbjumbop(SYSCTL_HANDLER_ARGS) return (error); } SYSCTL_PROC(_kern_ipc, OID_AUTO, nmbjumbop, - CTLTYPE_INT | CTLFLAG_RW | CTLFLAG_NEEDGIANT, &nmbjumbop, 0, + CTLTYPE_INT | CTLFLAG_RW | CTLFLAG_MPSAFE, &nmbjumbop, 0, sysctl_nmbjumbop, "IU", "Maximum number of mbuf page size jumbo clusters allowed"); @@ -267,7 +267,7 @@ sysctl_nmbjumbo9(SYSCTL_HANDLER_ARGS) return (error); } SYSCTL_PROC(_kern_ipc, OID_AUTO, nmbjumbo9, - CTLTYPE_INT | CTLFLAG_RW | CTLFLAG_NEEDGIANT, &nmbjumbo9, 0, + CTLTYPE_INT | CTLFLAG_RW | CTLFLAG_MPSAFE, &nmbjumbo9, 0, sysctl_nmbjumbo9, "IU", "Maximum number of mbuf 9k jumbo clusters allowed"); @@ -289,7 +289,7 @@ sysctl_nmbjumbo16(SYSCTL_HANDLER_ARGS) return (error); } SYSCTL_PROC(_kern_ipc, OID_AUTO, nmbjumbo16, - CTLTYPE_INT | CTLFLAG_RW | CTLFLAG_NEEDGIANT, &nmbjumbo16, 0, + CTLTYPE_INT | CTLFLAG_RW | CTLFLAG_MPSAFE, &nmbjumbo16, 0, sysctl_nmbjumbo16, "IU", "Maximum number of mbuf 16k jumbo clusters allowed"); @@ -311,7 +311,7 @@ sysctl_nmbufs(SYSCTL_HANDLER_ARGS) return (error); } SYSCTL_PROC(_kern_ipc, OID_AUTO, nmbufs, - CTLTYPE_INT | CTLFLAG_RW | CTLFLAG_NEEDGIANT, + CTLTYPE_INT | CTLFLAG_RW | CTLFLAG_MPSAFE, &nmbufs, 0, sysctl_nmbufs, "IU", "Maximum number of mbufs allowed"); diff --git a/sys/kern/kern_switch.c b/sys/kern/kern_switch.c index d8b735ccda7c..aec3b3d10e04 100644 --- a/sys/kern/kern_switch.c +++ b/sys/kern/kern_switch.c @@ -143,7 +143,7 @@ sysctl_stats_reset(SYSCTL_HANDLER_ARGS) } SYSCTL_PROC(_kern_sched_stats, OID_AUTO, reset, - CTLTYPE_INT | CTLFLAG_WR | CTLFLAG_NEEDGIANT, NULL, 0, + CTLTYPE_INT | CTLFLAG_WR | CTLFLAG_MPSAFE, NULL, 0, sysctl_stats_reset, "I", "Reset scheduler statistics"); #endif diff --git a/sys/kern/subr_bus.c b/sys/kern/subr_bus.c index 185a39cdb0ef..84333535dbfc 100644 --- a/sys/kern/subr_bus.c +++ b/sys/kern/subr_bus.c @@ -246,7 +246,7 @@ devclass_sysctl_init(devclass_t dc) CTLFLAG_RD | CTLFLAG_MPSAFE, NULL, ""); SYSCTL_ADD_PROC(&dc->sysctl_ctx, SYSCTL_CHILDREN(dc->sysctl_tree), OID_AUTO, "%parent", - CTLTYPE_STRING | CTLFLAG_RD | CTLFLAG_NEEDGIANT, + CTLTYPE_STRING | CTLFLAG_RD | CTLFLAG_MPSAFE, dc, DEVCLASS_SYSCTL_PARENT, devclass_sysctl_handler, "A", "parent class"); } diff --git a/sys/kern/uipc_mbuf.c b/sys/kern/uipc_mbuf.c index 4fa94fb3019e..d78bddb284f4 100644 --- a/sys/kern/uipc_mbuf.c +++ b/sys/kern/uipc_mbuf.c @@ -50,6 +50,7 @@ __FBSDID("$FreeBSD$"); #include #include #include +#include #include #include #include @@ -2118,16 +2119,6 @@ struct mbufprofile { uintmax_t segments[MP_BUCKETS]; } mbprof; -#define MP_MAXDIGITS 21 /* strlen("16,000,000,000,000,000,000") == 21 */ -#define MP_NUMLINES 6 -#define MP_NUMSPERLINE 16 -#define MP_EXTRABYTES 64 /* > strlen("used:\nwasted:\nsegments:\n") */ -/* work out max space needed and add a bit of spare space too */ -#define MP_MAXLINE ((MP_MAXDIGITS+1) * MP_NUMSPERLINE) -#define MP_BUFSIZE ((MP_MAXLINE * MP_NUMLINES) + 1 + MP_EXTRABYTES) - -char mbprofbuf[MP_BUFSIZE]; - void m_profile(struct mbuf *m) { @@ -2163,16 +2154,18 @@ m_profile(struct mbuf *m) mbprof.wasted[fls(wasted)]++; } -static void -mbprof_textify(void) +static int +mbprof_handler(SYSCTL_HANDLER_ARGS) { - int offset; - char *c; + char buf[256]; + struct sbuf sb; + int error; uint64_t *p; + sbuf_new_for_sysctl(&sb, buf, sizeof(buf), req); + p = &mbprof.wasted[0]; - c = mbprofbuf; - offset = snprintf(c, MP_MAXLINE + 10, + sbuf_printf(&sb, "wasted:\n" "%ju %ju %ju %ju %ju %ju %ju %ju " "%ju %ju %ju %ju %ju %ju %ju %ju\n", @@ -2180,16 +2173,14 @@ mbprof_textify(void) p[8], p[9], p[10], p[11], p[12], p[13], p[14], p[15]); #ifdef BIG_ARRAY p = &mbprof.wasted[16]; - c += offset; - offset = snprintf(c, MP_MAXLINE, + sbuf_printf(&sb, "%ju %ju %ju %ju %ju %ju %ju %ju " "%ju %ju %ju %ju %ju %ju %ju %ju\n", p[0], p[1], p[2], p[3], p[4], p[5], p[6], p[7], p[8], p[9], p[10], p[11], p[12], p[13], p[14], p[15]); #endif p = &mbprof.used[0]; - c += offset; - offset = snprintf(c, MP_MAXLINE + 10, + sbuf_printf(&sb, "used:\n" "%ju %ju %ju %ju %ju %ju %ju %ju " "%ju %ju %ju %ju %ju %ju %ju %ju\n", @@ -2197,16 +2188,14 @@ mbprof_textify(void) p[8], p[9], p[10], p[11], p[12], p[13], p[14], p[15]); #ifdef BIG_ARRAY p = &mbprof.used[16]; - c += offset; - offset = snprintf(c, MP_MAXLINE, + sbuf_printf(&sb, "%ju %ju %ju %ju %ju %ju %ju %ju " "%ju %ju %ju %ju %ju %ju %ju %ju\n", p[0], p[1], p[2], p[3], p[4], p[5], p[6], p[7], p[8], p[9], p[10], p[11], p[12], p[13], p[14], p[15]); #endif p = &mbprof.segments[0]; - c += offset; - offset = snprintf(c, MP_MAXLINE + 10, + sbuf_printf(&sb, "segments:\n" "%ju %ju %ju %ju %ju %ju %ju %ju " "%ju %ju %ju %ju %ju %ju %ju %ju\n", @@ -2214,22 +2203,15 @@ mbprof_textify(void) p[8], p[9], p[10], p[11], p[12], p[13], p[14], p[15]); #ifdef BIG_ARRAY p = &mbprof.segments[16]; - c += offset; - offset = snprintf(c, MP_MAXLINE, + sbuf_printf(&sb, "%ju %ju %ju %ju %ju %ju %ju %ju " "%ju %ju %ju %ju %ju %ju %ju %jju", p[0], p[1], p[2], p[3], p[4], p[5], p[6], p[7], p[8], p[9], p[10], p[11], p[12], p[13], p[14], p[15]); #endif -} - -static int -mbprof_handler(SYSCTL_HANDLER_ARGS) -{ - int error; - mbprof_textify(); - error = SYSCTL_OUT(req, mbprofbuf, strlen(mbprofbuf) + 1); + error = sbuf_finish(&sb); + sbuf_delete(&sb); return (error); } @@ -2251,12 +2233,12 @@ mbprof_clr_handler(SYSCTL_HANDLER_ARGS) } SYSCTL_PROC(_kern_ipc, OID_AUTO, mbufprofile, - CTLTYPE_STRING | CTLFLAG_RD | CTLFLAG_NEEDGIANT, NULL, 0, + CTLTYPE_STRING | CTLFLAG_RD | CTLFLAG_MPSAFE, NULL, 0, mbprof_handler, "A", "mbuf profiling statistics"); SYSCTL_PROC(_kern_ipc, OID_AUTO, mbufprofileclr, - CTLTYPE_INT | CTLFLAG_RW | CTLFLAG_NEEDGIANT, NULL, 0, + CTLTYPE_INT | CTLFLAG_RW | CTLFLAG_MPSAFE, NULL, 0, mbprof_clr_handler, "I", "clear mbuf profiling statistics"); #endif