From owner-svn-src-all@freebsd.org Tue Aug 1 12:53:50 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 6BB94DAB8CB for ; Tue, 1 Aug 2017 12:53:50 +0000 (UTC) (envelope-from gallatin@netflix.com) Received: from mail-qt0-x22a.google.com (mail-qt0-x22a.google.com [IPv6:2607:f8b0:400d:c0d::22a]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (Client CN "smtp.gmail.com", Issuer "Google Internet Authority G2" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 23D4475FC8 for ; Tue, 1 Aug 2017 12:53:50 +0000 (UTC) (envelope-from gallatin@netflix.com) Received: by mail-qt0-x22a.google.com with SMTP id p3so8229372qtg.2 for ; Tue, 01 Aug 2017 05:53:50 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=netflix.com; s=google; h=subject:to:cc:references:from:message-id:date:user-agent :mime-version:in-reply-to:content-language:content-transfer-encoding; bh=jBWRATGDZ5jUs5MVQ/lpm+onmF8HCFmpJ5GgOyvTk1w=; b=LLLRkvF6ZtH2dHhgcWFRflzmR3iAxZvWQGcJ52/ZAhIlBS8ojd4LLnbnL16WLtGxTR 2td3P625bK6Ad7ZIB2hANqhl1Z4enrvgUzk2SEOylPeKjhJMXRWr1VYvDEKpHhDgx1Jo pjHnbaDHGCP1/lvKoAlrnEUbZYdaM8+PPrLpw= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:subject:to:cc:references:from:message-id:date :user-agent:mime-version:in-reply-to:content-language :content-transfer-encoding; bh=jBWRATGDZ5jUs5MVQ/lpm+onmF8HCFmpJ5GgOyvTk1w=; b=bN6+plkAeWeZ+OJ/oWhRqQbyqUJXSNpijN3HRwh4RLDaosaDjVPDVIjhD0qxj9+h96 G65NN1VbzWDANd307YW0NFOb+imxY91P852rDkPuY89u9iiCz4x1G9YdgjInLdV/byXK upnk5LSI5rc+li1xGXxBkDg30l+Sakl1HKa23QPaOzBfEdjVQKCyG5Zd0QBi5zCuddrG AZzqsvtX4+k44ROLqJpqwHEtR5WVWYxoWm9Y8PqUq0fD14ag9lnxs1j62stIi2D8dr9w 8Zy3cMoDPNd1n8ZozXu22j/qZ1blPdUskNSKZV4Dz6deB4TzL31P+FrNkTg23bOXmyMO ICJg== X-Gm-Message-State: AIVw112ff1tZOW6ssg3Mb9knXJsl2yE2PDL3w7V9EJXyDjgf2w/WZLO9 zxb/36Pc2slu7UtV X-Received: by 10.237.35.179 with SMTP id j48mr25711901qtc.59.1501592029179; Tue, 01 Aug 2017 05:53:49 -0700 (PDT) Received: from ?IPv6:2601:5ca:c302:a71:ec4:7aff:fe71:9cc0? ([2601:5ca:c302:a71:ec4:7aff:fe71:9cc0]) by smtp.gmail.com with ESMTPSA id c5sm21282893qkd.27.2017.08.01.05.53.48 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 01 Aug 2017 05:53:48 -0700 (PDT) Subject: Re: svn commit: r321790 - head/sbin/sysctl To: John Baldwin Cc: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org References: <201707311456.v6VEuZvT083622@repo.freebsd.org> <2175723.Ple0o0TTz8@ralph.baldwin.cx> From: Andrew Gallatin Message-ID: <0519c48d-c6e0-4dd3-9b37-56b0f211e408@netflix.com> Date: Tue, 1 Aug 2017 08:53:47 -0400 User-Agent: Mozilla/5.0 (X11; FreeBSD amd64; rv:52.0) Gecko/20100101 Thunderbird/52.1.1 MIME-Version: 1.0 In-Reply-To: <2175723.Ple0o0TTz8@ralph.baldwin.cx> Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-US Content-Transfer-Encoding: 7bit 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: Tue, 01 Aug 2017 12:53:50 -0000 On 07/31/17 13:20, John Baldwin wrote: > 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://urldefense.proofpoint.com/v2/url?u=https-3A__svnweb.freebsd.org_changeset_base_321790&d=DwICAg&c=imBPVzF25OnBgGmVOlcsiEgHoG1i6YHLR0Sj_gZ4adc&r=Ed-falealxPeqc22ehgAUCLh8zlZbibZLSMWJeZro4A&m=6pTZhALOHVMuNxvC0RsuEoG4j_dKwjmuXgxC_aZLwj4&s=iX60l0OLjrKSEAZM1J0IrtmCEX_ZvHr2sMgDd4SdHxg&e= >> >> 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://urldefense.proofpoint.com/v2/url?u=https-3A__reviews.freebsd.org_D11461&d=DwICAg&c=imBPVzF25OnBgGmVOlcsiEgHoG1i6YHLR0Sj_gZ4adc&r=Ed-falealxPeqc22ehgAUCLh8zlZbibZLSMWJeZro4A&m=6pTZhALOHVMuNxvC0RsuEoG4j_dKwjmuXgxC_aZLwj4&s=b-hXEv1EHJwVhKxSsmgugUz3RBcGHN7oxcMcI3Dbp_c&e= >> >> 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? > Not if you've set one of the flags to dump raw data. Eg, try sysctl -o net.inet.tcp.pcblist Drew