From: Stefano Stabellini Date: Thu, 23 Sep 2010 18:01:37 +0000 (+0100) Subject: libxl: Introduce a maximum limit for free_mem_slack (re (dom0) ballooning) X-Git-Tag: archive/raspbian/4.8.0-1+rpi1~1^2~11432 X-Git-Url: https://dgit.raspbian.org/?a=commitdiff_plain;h=a39b5bc64ba246b851be97c07514a76e34689d4b;p=xen.git 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 Tested-by: Ian Jackson Signed-off-by: Ian Jackson --- diff --git a/tools/libxl/libxl.c b/tools/libxl/libxl.c index 31535af788..8b086b9123 100644 --- a/tools/libxl/libxl.c +++ b/tools/libxl/libxl.c @@ -2785,6 +2785,7 @@ static int libxl__fill_dom0_memory_info(libxl__gc *gc, uint32_t *target_memkb) char *free_mem_slack_path = "/local/domain/0/memory/freemem-slack"; xs_transaction_t t; libxl_ctx *ctx = libxl__gc_owner(gc); + uint32_t free_mem_slack = 0; retry_transaction: t = xs_transaction_start(ctx->xsh); @@ -2814,8 +2815,14 @@ retry_transaction: (uint32_t) info.current_memkb); libxl__xs_write(gc, t, max_path, "%"PRIu32, (uint32_t) info.max_memkb); - libxl__xs_write(gc, t, free_mem_slack_path, "%"PRIu32, (uint32_t) - (PAGE_TO_MEMKB(physinfo.total_pages) - info.current_memkb)); + + free_mem_slack = (uint32_t) (PAGE_TO_MEMKB(physinfo.total_pages) - + info.current_memkb); + /* From empirical measurements the free_mem_slack shouldn't be more + * than 15% of the total memory present on the system. */ + if (free_mem_slack > PAGE_TO_MEMKB(physinfo.total_pages) * 0.15) + free_mem_slack = PAGE_TO_MEMKB(physinfo.total_pages) * 0.15; + libxl__xs_write(gc, t, free_mem_slack_path, "%"PRIu32, free_mem_slack); *target_memkb = (uint32_t) info.current_memkb; rc = 0;