From owner-svn-src-all@freebsd.org Mon Jul 31 20:35:46 2017 Return-Path: Delivered-To: svn-src-all@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id DB6A1DBD1C9; Mon, 31 Jul 2017 20:35:46 +0000 (UTC) (envelope-from jhb@freebsd.org) Received: from mail.baldwin.cx (bigwig.baldwin.cx [96.47.65.170]) (using TLSv1 with cipher DHE-RSA-CAMELLIA256-SHA (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id B8B89678D2; Mon, 31 Jul 2017 20:35:46 +0000 (UTC) (envelope-from jhb@freebsd.org) Received: from ralph.baldwin.cx (c-73-231-226-104.hsd1.ca.comcast.net [73.231.226.104]) by mail.baldwin.cx (Postfix) with ESMTPSA id 19A9A10AB01; Mon, 31 Jul 2017 16:35:39 -0400 (EDT) From: John Baldwin To: Andrew Gallatin Cc: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: Re: svn commit: r321790 - head/sbin/sysctl Date: Mon, 31 Jul 2017 10:20:50 -0700 Message-ID: <2175723.Ple0o0TTz8@ralph.baldwin.cx> User-Agent: KMail/4.14.10 (FreeBSD/11.1-STABLE; KDE/4.14.30; amd64; ; ) In-Reply-To: <201707311456.v6VEuZvT083622@repo.freebsd.org> References: <201707311456.v6VEuZvT083622@repo.freebsd.org> MIME-Version: 1.0 Content-Transfer-Encoding: 7Bit Content-Type: text/plain; charset="us-ascii" X-Greylist: Sender succeeded SMTP AUTH, not delayed by milter-greylist-4.4.3 (mail.baldwin.cx); Mon, 31 Jul 2017 16:35:39 -0400 (EDT) X-Virus-Scanned: clamav-milter 0.99.2 at mail.baldwin.cx X-Virus-Status: Clean X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 31 Jul 2017 20:35:47 -0000 On Monday, July 31, 2017 02:56:35 PM Andrew Gallatin wrote: > Author: gallatin > Date: Mon Jul 31 14:56:35 2017 > New Revision: 321790 > URL: https://svnweb.freebsd.org/changeset/base/321790 > > Log: > Don't request CTLTYPE_OPAQUE if we can't print them. > > The intent is to skip expensive opaque sysctls like tcp_pcblist unless > they are explicitly requested. Sysctl nodes like this don't show up in > sysctl -a, but they do generate output that winds up being dropped, > unless the user specifically requested binary/hex output or opaques. > > This reduces the runtime of sysctl in many circumstances on a loaded > system. It also reduces the likelihood that simply gathering > diagnostics on a sick machine (stuck lock, etc) via sysctl -a might > push it over the edge into a total lockup. > > Reviewed by: jtl > Sponsored by: Netflix > Differential Revision: https://reviews.freebsd.org/D11461 > > Modified: > head/sbin/sysctl/sysctl.c > > Modified: head/sbin/sysctl/sysctl.c > ============================================================================== > --- head/sbin/sysctl/sysctl.c Mon Jul 31 14:53:03 2017 (r321789) > +++ head/sbin/sysctl/sysctl.c Mon Jul 31 14:56:35 2017 (r321790) > @@ -925,6 +925,32 @@ show_var(int *oid, int nlen) > printf("%s", buf); > return (0); > } > + > + /* don't fetch opaques that we don't know how to print */ > + if (ctltype == CTLTYPE_OPAQUE) { > + if (strcmp(fmt, "S,clockinfo") == 0) > + func = S_clockinfo; > + else if (strcmp(fmt, "S,timeval") == 0) > + func = S_timeval; > + else if (strcmp(fmt, "S,loadavg") == 0) > + func = S_loadavg; > + else if (strcmp(fmt, "S,vmtotal") == 0) > + func = S_vmtotal; > +#ifdef __amd64__ > + else if (strcmp(fmt, "S,efi_map_header") == 0) > + func = S_efi_map; > +#endif > +#if defined(__amd64__) || defined(__i386__) > + else if (strcmp(fmt, "S,bios_smap_xattr") == 0) > + func = S_bios_smap_xattr; > +#endif > + else { > + func = NULL; > + if (!bflag && !oflag && !xflag) > + return (1); > + } > + } > + > /* find an estimate of how much we need for this var */ > if (Bflag) > j = Bflag; > @@ -1045,24 +1071,6 @@ show_var(int *oid, int nlen) > > case CTLTYPE_OPAQUE: > i = 0; > - if (strcmp(fmt, "S,clockinfo") == 0) > - func = S_clockinfo; > - else if (strcmp(fmt, "S,timeval") == 0) > - func = S_timeval; > - else if (strcmp(fmt, "S,loadavg") == 0) > - func = S_loadavg; > - else if (strcmp(fmt, "S,vmtotal") == 0) > - func = S_vmtotal; > -#ifdef __amd64__ > - else if (strcmp(fmt, "S,efi_map_header") == 0) > - func = S_efi_map; > -#endif > -#if defined(__amd64__) || defined(__i386__) > - else if (strcmp(fmt, "S,bios_smap_xattr") == 0) > - func = S_bios_smap_xattr; > -#endif > - else > - func = NULL; > if (func) { func should always be true now? -- John Baldwin