Re: svn commit: r321790 - head/sbin/sysctl

2017-08-01 Thread Andrew Gallatin via svn-src-head

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=DwICAg=imBPVzF25OnBgGmVOlcsiEgHoG1i6YHLR0Sj_gZ4adc=Ed-falealxPeqc22ehgAUCLh8zlZbibZLSMWJeZro4A=6pTZhALOHVMuNxvC0RsuEoG4j_dKwjmuXgxC_aZLwj4=iX60l0OLjrKSEAZM1J0IrtmCEX_ZvHr2sMgDd4SdHxg=

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=DwICAg=imBPVzF25OnBgGmVOlcsiEgHoG1i6YHLR0Sj_gZ4adc=Ed-falealxPeqc22ehgAUCLh8zlZbibZLSMWJeZro4A=6pTZhALOHVMuNxvC0RsuEoG4j_dKwjmuXgxC_aZLwj4=b-hXEv1EHJwVhKxSsmgugUz3RBcGHN7oxcMcI3Dbp_c=

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



___
svn-src-head@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


Re: svn commit: r321790 - head/sbin/sysctl

2017-07-31 Thread John Baldwin
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
___
svn-src-head@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


svn commit: r321790 - head/sbin/sysctl

2017-07-31 Thread Andrew Gallatin
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) {
if (!nflag)
printf("%s%s", name, sep);
___
svn-src-head@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"