kernel - Relax requirements for sysctl operations on longs
authorMatthew Dillon <dillon@apollo.backplane.com>
Mon, 18 Dec 2017 05:45:34 +0000 (21:45 -0800)
committerMatthew Dillon <dillon@apollo.backplane.com>
Mon, 18 Dec 2017 05:45:34 +0000 (21:45 -0800)
commit83ed56857dc47610d1c0156612e06093364d3509
treeb3cf86b258dc870de7a58c46aefbb13e469c4f64
parent82726bbd322006f03f0d48d15181ec652573e8cc
kernel - Relax requirements for sysctl operations on longs

* Relax the requirements for sysctl operations on longs.  Allow the
  case where userland is reading the sysctl variable as an integer
  instead of a long.

* Allows us to promote various vm.stats.vm_* fields that must now be
  longs in order to support > 8TB of ram as well as avoid internal
  calculation overflows.

* Fixes an issue where chrome issues this sysctl as an int:

  sysctlbyname("vm.stats.vm.v_page_count", &pages, &size, NULL, 0);

  And fails to check the return value / error code, resulting in
  a garbage value for 'pages' which chrome then uses to size the
  browser's memory restrains.  This in turn was causing chrome
  to give up multiple tabs thinking it had run out of memory when,
  in fact, there is plenty of memory available.

* Generally speaking, I've wanted to have this sort of backwards
  compatibility for a while now.  Userland shouldn't get errors
  accesing integral sysctl values simply because it uses an integer
  of a different size than the sysctl.
sys/kern/kern_sysctl.c