From bf4306b815a5c0e84ebcb8b58a3449fbac962f88 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marek=20Marczykowski-G=C3=B3recki?= Date: Thu, 11 Jan 2018 02:15:15 +0100 Subject: [PATCH] qmemman: clear "not responding" flags when VM require more memory Clear slow_memset_react/no_progress flags when VM request more memory than it have assigned. If there is some available, it may be given to such VM, solving the original problem (not reacting to balloon down request). In any case, qmemman algorithm should not try to take away memory from under-provisioned VM. Fixes QubesOS/qubes-issues#3265 --- qubes/qmemman/__init__.py | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/qubes/qmemman/__init__.py b/qubes/qmemman/__init__.py index cdb2d2da..51cc9b05 100644 --- a/qubes/qmemman/__init__.py +++ b/qubes/qmemman/__init__.py @@ -140,14 +140,16 @@ class SystemState(object): def clear_outdated_error_markers(self): # Clear outdated errors for i in self.domdict.keys(): - if self.domdict[i].slow_memset_react and \ - self.domdict[i].memory_actual <= \ - self.domdict[i].last_target + self.XEN_FREE_MEM_LEFT/4: + # clear markers excluding VM from memory balance, if: + # - VM have responded to previous request (with some safety margin) + # - VM request more memory than it has assigned + # The second condition avoids starving a VM, even when there is + # some free memory available + if self.domdict[i].memory_actual <= \ + self.domdict[i].last_target + self.XEN_FREE_MEM_LEFT/2 or \ + self.domdict[i].memory_actual < \ + qubes.qmemman.algo.prefmem(self.domdict[i]): self.domdict[i].slow_memset_react = False - - if self.domdict[i].no_progress and \ - self.domdict[i].memory_actual <= \ - self.domdict[i].last_target + self.XEN_FREE_MEM_LEFT/4: self.domdict[i].no_progress = False # the below works (and is fast), but then 'xm list' shows unchanged