From nobody Mon Dec 27 04:08:03 2021 X-Original-To: dev-commits-src-main@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 8CF66190FADC; Mon, 27 Dec 2021 04:08:04 +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 4JMkfX25Knz3jT0; Mon, 27 Dec 2021 04:08:04 +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 23DB61747C; Mon, 27 Dec 2021 04:08:04 +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 1BR484FH024868; Mon, 27 Dec 2021 04:08:04 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 1BR483OP024867; Mon, 27 Dec 2021 04:08:03 GMT (envelope-from git) Date: Mon, 27 Dec 2021 04:08:03 GMT Message-Id: <202112270408.1BR483OP024867@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Alexander Motin Subject: git: c6c52d8e39b2 - main - kern: Remove CTLFLAG_NEEDGIANT from some more sysctls. List-Id: Commit messages for the main branch of the src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-main List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-dev-commits-src-main@freebsd.org X-BeenThere: dev-commits-src-main@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/main X-Git-Reftype: branch X-Git-Commit: c6c52d8e39b2dbee573bc80f32b5b7019cef1973 Auto-Submitted: auto-generated ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1640578084; 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=Ri+CHEVcLO6Ltm9kVSz1GF2weXhKTFDP53wbzg86J54=; b=ab+1n6wvi/lWUlI9MPYbEKvL4ZBXM5S+KXN74/Lmta9dwdzzXUvUXU2VMSjlrVAlzzU41q XOWeBCIMrDTj6ED9SN2w1yvwFD6vZOx6nmFqTDvYpv10eKTrR8nDzdmzNra4cG81y6BNLv 2CgwLMvgyJHfVyK3+af8GGPc58zzYdy3hp9s4KvVi9Mg7MXA9fl1pyo1/fTUf9fK2xz2jC 4ENNxi1dOidBeZgprSl3Exnl6x9PfotpBJMRyaWMAuTgGqpN3SezY3b0yX6FED1V4OGSQ/ ZWKi4ujbJspptILX5rs5bP9ioG7WaAGM4uxQJWzxNCg5IY9HxDRN7MRVGG3cHQ== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1640578084; a=rsa-sha256; cv=none; b=H7s5d7AA7NWg9Z3lvYtiiMWlTnPkvRPDKiAYb4bwVveZ/nCg5nDF4c76/oYaNofesefWMz peG+tB5v3roFlpu9gVtJrXie3EC2RIglO88PqkUdJynUFdH/9p+ZgBTH3rhYmy4BoajRjn I6BmUtK2A5zZgbzqJNhnutVzdrADp4mvjcMEQopNipG79dRCwr9ByT2pSn0yarasim7ZWG 4xgvpJcgGzshuf7JHSG0yybyACQCKLsZ5Vx9ebsBx0oPoHP9Qlfq9qOuzzcQjVucKTe6Dg wVyPQqjRywN8ViwCtN4T5ufkS/rpU8poTdw2F2DlKgnuCnHvrxIIJFPUjsF8cw== ARC-Authentication-Results: i=1; mx1.freebsd.org; none X-ThisMailContainsUnwantedMimeParts: N The branch main has been updated by mav: URL: https://cgit.FreeBSD.org/src/commit/?id=c6c52d8e39b2dbee573bc80f32b5b7019cef1973 commit c6c52d8e39b2dbee573bc80f32b5b7019cef1973 Author: Alexander Motin AuthorDate: 2021-12-27 04:07:33 +0000 Commit: Alexander Motin CommitDate: 2021-12-27 04:07:33 +0000 kern: Remove CTLFLAG_NEEDGIANT from some more sysctls. MFC after: 2 weeks --- 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 f48ec88bbe83..f1e76ef00c65 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 a5d0fc773787..8b0b2de47cf5 100644 --- a/sys/kern/subr_bus.c +++ b/sys/kern/subr_bus.c @@ -245,7 +245,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 1e62de4aef7f..42c94ae4a355 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 @@ -2128,16 +2129,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) { @@ -2173,16 +2164,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", @@ -2190,16 +2183,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", @@ -2207,16 +2198,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", @@ -2224,22 +2213,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); } @@ -2261,12 +2243,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