Bug #13822


bhyve memory should exert memory pressure

Added by Patrick Mooney about 2 years ago. Updated almost 2 years ago.

Start date:
Due date:
% Done:


Estimated time:
Gerrit CR:
External Bug:


When bhyve allocates memory for a guest (for the guest RAM, specifically) today, it does so in a KM_NOSLEEP manner. This is to avoid the allocation entering an uninterruptable (by signals) sleep, but also results in the allocation bypassing logic which informs the rest of the system about the memory pressure exerted by the allocation. In order to make timely and reliable allocations, those page reservation mechanisms should be updated to allow requests which can apply that memory pressure (implying KM_SLEEP), but are also fallible and interruptable via signal, so that bhyve may be updated to use them.

Actions #1

Updated by Electric Monk about 2 years ago

  • Gerrit CR set to 1522
Actions #2

Updated by Patrick Mooney almost 2 years ago

The canonical example for bhyve applying memory pressure is its ability to shrink the ARC. In order to test this, I booted up a machine with the proposed fix and then incurred disk activity (sequential data reads) until the ARC grew to an appreciable size (12GB out of the 64GB physmem). I then grew the size of the vmm memory reservoir (from #13833), observing it soaking up the remaining freemem on the system. Once freemem ran low, the dtrace probes I had attached to arc_reap_cb began to fire, indicating that an arc reap (and subsequent shrink) was occurring. As I continued to grow the reservoir, making more memory available for bhyve's use, the ARC continued shrinking. This proceeded until the ARC was roughly 6GB in size, and it would not shrink any further. At that point, attempts to put more memory in the reservoir were unsuccessful and the system started to become unresponsive. The pending allocation was cancelled and the system was well again.

Actions #3

Updated by Electric Monk almost 2 years ago

  • Status changed from In Progress to Closed
  • % Done changed from 0 to 100

git commit b57f5d3e6a2df8d435e606797cf3934811848343

commit  b57f5d3e6a2df8d435e606797cf3934811848343
Author: Patrick Mooney <>
Date:   2021-07-27T19:26:22.000Z

    13833 want bhyve memory reservoir
    13822 bhyve memory should exert memory pressure
    13834 want extensible page_resv
    13821 vmmctl ioctls should have more structure
    Reviewed by: Andy Fiddaman <>
    Reviewed by: Jason King <>
    Reviewed by: Dan Cross <>
    Reviewed by: Hans Rosenfeld <>
    Reviewed by: Mike Zeller <>
    Approved by: Dan McDonald <>


Also available in: Atom PDF