From 5a33ed71ceb2e788038ac77ef0136433d14a1895 Mon Sep 17 00:00:00 2001 From: Rafal Wojtczuk Date: Thu, 9 Sep 2010 10:36:13 +0200 Subject: [PATCH] qmemman: use the fact that balloon driver retries Apparently even if there is not enough xen memory to balloon up, balloon driver will try to fulfill the request later, when some memory is freed. Thus, in do_balloon, do not limit mem_set to the available memory. --- dom0/qmemman/qmemman.py | 34 ++++++---------------------------- 1 file changed, 6 insertions(+), 28 deletions(-) diff --git a/dom0/qmemman/qmemman.py b/dom0/qmemman/qmemman.py index aca537d3..8ec73715 100755 --- a/dom0/qmemman/qmemman.py +++ b/dom0/qmemman/qmemman.py @@ -12,6 +12,7 @@ class DomainState: self.mem_used = None self.id = id self.meminfo_updated = False + self.last_target = 0 class SystemState: def __init__(self): @@ -64,6 +65,7 @@ class SystemState: #the below works (and is fast), but then 'xm list' shows unchanged memory value def mem_set(self, id, val): print 'mem-set domain', id, 'to', val + self.domdict[id].last_target = val self.xs.write('', '/local/domain/' + id + '/memory/target', str(val/1024)) #can happen in the middle of domain shutdown #apparently xc.lowlevel throws exceptions too @@ -118,24 +120,12 @@ class SystemState: self.domdict[domid].meminfo = self.parse_meminfo(val) self.domdict[domid].meminfo_updated = True - def adjust_inflates_to_xenfree(self, reqs, idx): - i = idx - memory_needed = 0 - while i < len(reqs): - dom, mem = reqs[i] - memory_needed += mem - self.domdict[dom].memory_actual - i = i + 1 - scale = 1.0*self.get_free_xen_memory()/memory_needed - dom, mem = reqs[idx] - scaled_req = self.domdict[dom].memory_actual + scale*(mem - self.domdict[dom].memory_actual) - return int(scaled_req) - def is_balance_req_significant(self, memset_reqs): total_memory_transfer = 0 MIN_TOTAL_MEMORY_TRANSFER = 150*1024*1024 for rq in memset_reqs: dom, mem = rq - memory_change = mem - self.domdict[dom].memory_actual + memory_change = mem - self.domdict[dom].last_target total_memory_transfer += abs(memory_change) return total_memory_transfer > MIN_TOTAL_MEMORY_TRANSFER @@ -155,22 +145,10 @@ class SystemState: return self.print_stats(xenfree, memset_reqs) - wait_before_first_inflate = False - i = 0 - while i < len(memset_reqs): - dom, mem = memset_reqs[i] - memory_change = mem - self.domdict[dom].memory_actual - if memory_change < 0: - wait_before_first_inflate = True - else: - if wait_before_first_inflate: - time.sleep(self.BALOON_DELAY) - wait_before_first_inflate = False - #the following is called before _each_ inflate, to account for possibility that - #previously triggered memory release is in progress - mem = self.adjust_inflates_to_xenfree(memset_reqs, i) + + for rq in memset_reqs: + dom, mem = rq self.mem_set(dom, mem) - i = i + 1 # for i in self.domdict.keys(): # print 'domain ', i, ' meminfo=', self.domdict[i].meminfo, 'actual mem', self.domdict[i].memory_actual