kernel - Add flexibility to the RSS rlimit
authorMatthew Dillon <dillon@apollo.backplane.com>
Wed, 28 Dec 2016 22:07:02 +0000 (14:07 -0800)
committerMatthew Dillon <dillon@apollo.backplane.com>
Wed, 28 Dec 2016 22:07:02 +0000 (14:07 -0800)
commit486b807a221da48a97f879876c53696f68ca20c7
tree8a7d7cbc60f4132ed47e372d7381fc4cb62dc71b
parentaedf552349c8a21eff780d1d8e1680830110e695
kernel - Add flexibility to the RSS rlimit

* Add sysctl vm.pageout_memuse_mode, defaulting to 1:

  0 - disable (behavior prior to memoryuse rlimit commits).  RLIMIT_RSS
      is ignored.  Pagedaemon operates normally based on global page
      queues.

  1 - passive mode (default).  Pagedaemon operates normally, but additional
      actions are taken for processes exceeding their RLIMIT_RSS.

      Enforces RSS on a per-process basis by removing pages from the pmap,
      but simply deactivates the page and does not synchronously free it
      or page it out to swap.  The deactivated pages are more likely to be
      cleaned out by the system by the pagedaemon verses what it would
      normally choose from the global page queues.

      This mode has the smoothest results for the process being limited,
      as well as a lower impact on actual paging to swap, but this mode
      has the similar impact on alloctable memory for other unrelated
      processes if the limited process continues to allocate large amounts
      of memory.

  2 - active mode.  Pagedaemon operates normally, but additional actions
      are taken for processes exceeding their RLIMIT_RSS.

      Enforces RSS on a per-process basis by actively freeing clean pages
      and actively paging out dirty pages.  This has the least impact on
      other unrelated processes but can cause the limited process to stall
      for short periods of time.  This mode has the least impact on
      allocatable memory.

      However, this mode can cause excessive paging to swap, and thus is
      not the default.
sys/vm/vm_fault.c
sys/vm/vm_pageout.c
sys/vm/vm_pageout.h