• Dan Magenheimer's avatar
    xen: Fix selfballooning and ensure it doesn't go too far · 38a1ed4f
    Dan Magenheimer authored
    The balloon driver's "current_pages" is very different from
    totalram_pages.  Self-ballooning needs to be driven by
    the latter.  Also, Committed_AS doesn't account for pages
    used by the kernel so:
    1) Add totalreserve_pages to Committed_AS for the normal target.
    2) Enforce a floor for when there are little or no user-space threads
       using memory (e.g. single-user mode) to avoid OOMs.  The floor
       function includes a "min_usable_mb" tuneable in case we discover
       later that the floor function is still too aggressive in some
       workloads, though likely it will not be needed.
    
    Changes since version 4:
    - change floor calculation so that it is not as aggressive; this version
      uses a piecewise linear function similar to minimum_target in the 2.6.18
      balloon driver, but modified to add to totalreserve_pages instead of
      subtract from max_pfn, the 2.6.18 version causes OOMs on recent kernels
      because the kernel has expanded over time
    - change safety_margin to min_usable_mb and comment on its use
    - since committed_as does NOT include kernel space (and other reserved
      pages), totalreserve_pages is now added to committed_as.  The result is
      less aggressive self-ballooning, but theoretically more appropriate.
    Changes since version 3:
    - missing include causes compile problem when CONFIG_FRONTSWAP is disabled
    - add comments after includes
    Changes since version 2:
    - missing include causes compile problem only on 32-bit
    Changes since version 1:
    - tuneable safety margin added
    
    [v5: avi.miller@oracle.com: still too aggressive, seeing some OOMs]
    [v4: konrad.wilk@oracle.com: fix compile when CONFIG_FRONTSWAP is disabled]
    [v3: guru.anbalagane@oracle.com: fix 32-bit compile]
    [v2: konrad.wilk@oracle.com: make safety margin tuneable]
    Signed-off-by: default avatarDan Magenheimer <dan.magenheimer@oracle.com>
    [v1: Altered description and added an extra include]
    Signed-off-by: default avatarKonrad Rzeszutek Wilk <konrad.wilk@oracle.com>
    38a1ed4f
xen-selfballoon.c 16.9 KB