[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [xen master] xl: move freemem()'s "credit expired" loop exit
commit d8f8cb8bdd02fad3b6986ae93511f750fa7f7e6a Author: Jan Beulich <jbeulich@xxxxxxxx> AuthorDate: Mon Jul 18 17:48:18 2022 +0200 Commit: Jan Beulich <jbeulich@xxxxxxxx> CommitDate: Mon Jul 18 17:48:18 2022 +0200 xl: move freemem()'s "credit expired" loop exit Move the "credit expired" loop exit to the middle of the loop, immediately after "return true". This way having reached the goal on the last iteration would be reported as success to the caller, rather than as "timed out". Signed-off-by: Jan Beulich <jbeulich@xxxxxxxx> Reviewed-by: Anthony PERARD <anthony.perard@xxxxxxxxxx> --- tools/xl/xl_vmcontrol.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/tools/xl/xl_vmcontrol.c b/tools/xl/xl_vmcontrol.c index cd338a5422..8c29923f62 100644 --- a/tools/xl/xl_vmcontrol.c +++ b/tools/xl/xl_vmcontrol.c @@ -332,7 +332,7 @@ static bool freemem(uint32_t domid, libxl_domain_config *d_config) if (rc < 0) return false; - do { + for (;;) { time_t start; rc = libxl_get_free_memory(ctx, &free_memkb); @@ -342,6 +342,9 @@ static bool freemem(uint32_t domid, libxl_domain_config *d_config) if (free_memkb >= need_memkb) return true; + if (credit <= 0) + return false; + rc = libxl_set_memory_target(ctx, 0, free_memkb - need_memkb, 1, 0); if (rc < 0) return false; @@ -354,9 +357,7 @@ static bool freemem(uint32_t domid, libxl_domain_config *d_config) return false; credit -= difftime(time(NULL), start); - } while (credit > 0); - - return false; + } } static void reload_domain_config(uint32_t domid, -- generated by git-patchbot for /home/xen/git/xen.git#master
|
Lists.xenproject.org is hosted with RackSpace, monitoring our |