[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[PATCH] xl: move freemem()'s "credit expired" loop exit


  • To: "xen-devel@xxxxxxxxxxxxxxxxxxxx" <xen-devel@xxxxxxxxxxxxxxxxxxxx>
  • From: Jan Beulich <jbeulich@xxxxxxxx>
  • Date: Tue, 12 Jul 2022 16:08:12 +0200
  • Arc-authentication-results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=suse.com; dmarc=pass action=none header.from=suse.com; dkim=pass header.d=suse.com; arc=none
  • Arc-message-signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=TRbyhNYHEVlPFuK/oWbifwn8qoUX0JXA1pqeJcMgsQ4=; b=d1OLKd9rxDmPoHqTYXD6+cdapJ+p4NWeKZ8gYJiTQyt1zUiwIp1BztS57aNnApEikRQn08saYo8y+P0yh0UZzya9vqVneIK+Z3aZ2XSTzQ4PmitqmHlpvJCtLTG3R3K64XIwVAqbS/BTwq7P8XymNuUbF2+iZ3yxTXGQRe5haUg5Uwvd3DxElQz3mQ+GjaLUDLoFzc8ZNopolpbAPTnkKCORC/AennKwNYfP1cxFtzAUgOu4Bm6xpv/cab3PU1/AyD8vZtmbMyByoXWdbtUS8aV8qNqlbWW6OIT93jf4yhpJJ/DzFvnRIPwM0B1VP2prRnIEX4e/IqEPyu+YOF1CDQ==
  • Arc-seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=Vs82eWsh1zv1WvGq+ozhg8iqLxuv3u/CgtN/VGY87qTPzI+cxdbZVdA8WZDWgCkLFWH6uLiJZozssjO+RBWo3Iq0QKRh6CKaGJAe8ZsC/DyORSoIQBHboe8xp3m3eOKFDPvNvnD1sQJ4sUrGDDWXgL9+AKGIVOmZxknG8i06+ls35J/M6LM+/QUj10MnI0KF1lTqs5frsF3mq6TuYxbDpQD8nFMUX3zsT+erNhBR8vwmaaDBlwMWxHT7IEEwG0ktTAxIPHdjj5WrOo9IPM6/4uV90Ku51LceutHniK8w1FmGfs27n2QjTwwgujeoLM7+kJA77twWMtvuuRnr+hSpNg==
  • Authentication-results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=suse.com;
  • Cc: Anthony Perard <anthony.perard@xxxxxxxxxx>, Wei Liu <wl@xxxxxxx>
  • Delivery-date: Tue, 12 Jul 2022 14:08:43 +0000
  • List-id: Xen developer discussion <xen-devel.lists.xenproject.org>

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>

--- a/tools/xl/xl_vmcontrol.c
+++ b/tools/xl/xl_vmcontrol.c
@@ -332,7 +332,7 @@ static bool freemem(uint32_t domid, libx
     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, libx
         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, libx
             return false;
 
         credit -= difftime(time(NULL), start);
-    } while (credit > 0);
-
-    return false;
+    }
 }
 
 static void reload_domain_config(uint32_t domid,



 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.