WARNING - OLD ARCHIVES

This is an archived copy of the Xen.org mailing list, which we have preserved to ensure that existing links to archives are not broken. The live archive, which contains the latest emails, can be found at http://lists.xen.org/
   
 
 
Xen 
 
Home Products Support Community News
 
   
 

xen-api

[Xen-API] [PATCH 1 of 2] [CA-39743] Improvements to the wait_xen_free_me

To: xen-api@xxxxxxxxxxxxxxxxxxx
Subject: [Xen-API] [PATCH 1 of 2] [CA-39743] Improvements to the wait_xen_free_mem function
From: Jonathan Knowles <jonathan.knowles@xxxxxxxxxxxxx>
Date: Wed, 31 Mar 2010 10:46:52 +0100
Delivery-date: Wed, 31 Mar 2010 02:49:18 -0700
Envelope-to: www-data@xxxxxxxxxxxxxxxxxxx
In-reply-to: <patchbomb.1270028811@radon>
List-help: <mailto:xen-api-request@lists.xensource.com?subject=help>
List-id: Discussion of API issues surrounding Xen <xen-api.lists.xensource.com>
List-post: <mailto:xen-api@lists.xensource.com>
List-subscribe: <http://lists.xensource.com/mailman/listinfo/xen-api>, <mailto:xen-api-request@lists.xensource.com?subject=subscribe>
List-unsubscribe: <http://lists.xensource.com/mailman/listinfo/xen-api>, <mailto:xen-api-request@lists.xensource.com?subject=unsubscribe>
Sender: xen-api-bounces@xxxxxxxxxxxxxxxxxxx
# HG changeset patch
# User Jonathan Knowles <jonathan.knowles@xxxxxxxxxxxxx>
# Date 1270028088 -3600
# Node ID 73d8b966e6eb5a1f654f75e25387fd1afb184073
# Parent  652da54170ffe4b4d6f3e47bd1215f6811d9ab03
[CA-39743] Improvements to the wait_xen_free_mem function.

Improvements include:
* We read the values of free_memory and scrub_memory atomically (rather than 
separately).
* We exit early if (free_memory < required_memory) and (scrub_memory = 0) as 
it's unlikely that more will become free.
* We time out more quickly than before (64 seconds rather than 256 seconds).

Signed-off-by: Jonathan Knowles <jonathan.knowles@xxxxxxxxxxxxx>

diff -r 652da54170ff -r 73d8b966e6eb ocaml/xenops/memory.ml
--- a/ocaml/xenops/memory.ml    Wed Mar 31 10:34:47 2010 +0100
+++ b/ocaml/xenops/memory.ml    Wed Mar 31 10:34:48 2010 +0100
@@ -216,28 +216,31 @@
        then HVM.footprint_mib target_mib max_mib vcpus shadow_multiplier
        else Linux.footprint_mib target_mib
 
-let wait_xen_free_mem ~xc ?(maximum_wait_time_seconds=256) 
requested_memory_kib =
+let wait_xen_free_mem ~xc ?(maximum_wait_time_seconds=64) required_memory_kib =
        let rec wait accumulated_wait_time_seconds =
-               let free_memory_kib = get_free_memory_kib ~xc in
-               let scrub_memory_kib = get_scrub_memory_kib ~xc in
+               let host_info = Xc.physinfo xc in
+               let free_memory_kib =
+                       kib_of_pages (Int64.of_nativeint 
host_info.Xc.free_pages) in
+               let scrub_memory_kib =
+                       kib_of_pages (Int64.of_nativeint 
host_info.Xc.scrub_pages) in
                (* At exponentially increasing intervals, write  *)
                (* a debug message saying how long we've waited: *)
-               if is_power_of_2 accumulated_wait_time_seconds then
-                       debug
-                               "Waited %i second(s) for memory to become 
available: \
-                               %Ld free, %Ld scrub, %Ld requested"
-                               accumulated_wait_time_seconds free_memory_kib
-                               scrub_memory_kib requested_memory_kib;
-               if free_memory_kib >= requested_memory_kib
-               then true
-               else begin
-                       (* Give up if we've already waited the maximum amount 
of time. *)
-                       if accumulated_wait_time_seconds >= 
maximum_wait_time_seconds
-                       then false
-                       else begin
-                               Thread.delay 1.0;
-                               wait (accumulated_wait_time_seconds + 1)
-                       end
-               end
-       in
+               if is_power_of_2 accumulated_wait_time_seconds then debug
+                       "Waited %i second(s) for memory to become available: \
+                       %Ld KiB free, %Ld KiB scrub, %Ld KiB required"
+                       accumulated_wait_time_seconds
+                       free_memory_kib scrub_memory_kib required_memory_kib;
+               if free_memory_kib >= required_memory_kib
+                       (* We already have enough memory. *)
+                       then true else
+               if scrub_memory_kib = 0L
+                       (* We'll never have enough memory. *)
+                       then false else
+               if accumulated_wait_time_seconds >= maximum_wait_time_seconds
+                       (* We've waited long enough. *)
+                       then false else
+               begin
+                       Thread.delay 1.0;
+                       wait (accumulated_wait_time_seconds + 1)
+               end in
        wait 0
1 file changed, 24 insertions(+), 21 deletions(-)
ocaml/xenops/memory.ml |   45 ++++++++++++++++++++++++---------------------


Attachment: xen-api.hg-2.patch
Description: Text Data

_______________________________________________
xen-api mailing list
xen-api@xxxxxxxxxxxxxxxxxxx
http://lists.xensource.com/mailman/listinfo/xen-api
<Prev in Thread] Current Thread [Next in Thread>