debuggers.hg

changeset 22256:4d95192b2fc8

libxl: Introduce a maximum limit for free_mem_slack (re (dom0) ballooning)

This fixes this message:
libxl: error: libxl.c:2921:libxl_set_memory_target new target
for dom0 is below the minimum threshold
which can occur spuriously if dom0_mem is specified and xl
autoballoning is left turned on.

Signed-off-by: Stefano Stabellini <stefano.stabellini@eu.citrix.com>
Tested-by: Ian Jackson <ian.jackson@eu.citrix.com>
Signed-off-by: Ian Jackson <ian.jackson@eu.citrix.com>
author Stefano Stabellini <stefano.stabellini@eu.citrix.com>
date Thu Sep 23 19:01:37 2010 +0100 (2010-09-23)
parents 50c1cc209f8f
children 07c1d958eee0
files tools/libxl/libxl.c
line diff
     1.1 --- a/tools/libxl/libxl.c	Wed Sep 22 18:29:24 2010 +0100
     1.2 +++ b/tools/libxl/libxl.c	Thu Sep 23 19:01:37 2010 +0100
     1.3 @@ -2785,6 +2785,7 @@ static int libxl__fill_dom0_memory_info(
     1.4      char *free_mem_slack_path = "/local/domain/0/memory/freemem-slack";
     1.5      xs_transaction_t t;
     1.6      libxl_ctx *ctx = libxl__gc_owner(gc);
     1.7 +    uint32_t free_mem_slack = 0;
     1.8  
     1.9  retry_transaction:
    1.10      t = xs_transaction_start(ctx->xsh);
    1.11 @@ -2814,8 +2815,14 @@ retry_transaction:
    1.12              (uint32_t) info.current_memkb);
    1.13      libxl__xs_write(gc, t, max_path, "%"PRIu32,
    1.14              (uint32_t) info.max_memkb);
    1.15 -    libxl__xs_write(gc, t, free_mem_slack_path, "%"PRIu32, (uint32_t)
    1.16 -            (PAGE_TO_MEMKB(physinfo.total_pages) - info.current_memkb));
    1.17 +
    1.18 +    free_mem_slack = (uint32_t) (PAGE_TO_MEMKB(physinfo.total_pages) -
    1.19 +            info.current_memkb);
    1.20 +    /* From empirical measurements the free_mem_slack shouldn't be more
    1.21 +     * than 15% of the total memory present on the system. */
    1.22 +    if (free_mem_slack > PAGE_TO_MEMKB(physinfo.total_pages) * 0.15)
    1.23 +        free_mem_slack = PAGE_TO_MEMKB(physinfo.total_pages) * 0.15;
    1.24 +    libxl__xs_write(gc, t, free_mem_slack_path, "%"PRIu32, free_mem_slack);
    1.25  
    1.26      *target_memkb = (uint32_t) info.current_memkb;
    1.27      rc = 0;