From 2d8a8094ed1724e4727da946c06d240a44782dbd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marek=20Marczykowski-G=C3=B3recki?= Date: Fri, 9 Oct 2015 19:29:15 +0200 Subject: [PATCH] qmemman: add some comments about new condition for failing request QubesOS/qubes-issues#1136 --- qmemman/qmemman.py | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/qmemman/qmemman.py b/qmemman/qmemman.py index 3de81d75..9bfdd52a 100755 --- a/qmemman/qmemman.py +++ b/qmemman/qmemman.py @@ -145,8 +145,13 @@ class SystemState(object): for i in self.domdict.keys(): self.domdict[i].no_progress = False + #: number of loop iterations for CHECK_PERIOD_S seconds check_period = max(1, int((CHECK_PERIOD_S + 0.0) / self.BALOON_DELAY)) + #: number of free memory bytes expected to get during CHECK_PERIOD_S + #: seconds check_delta = CHECK_PERIOD_S * CHECK_MB_S * 1024 * 1024 + #: helper array for holding free memory size, CHECK_PERIOD_S seconds + #: ago, at every loop iteration xenfree_ring = [0] * check_period while True: @@ -157,6 +162,8 @@ class SystemState(object): if xenfree >= memsize + self.XEN_FREE_MEM_MIN: self.inhibit_balloon_up() return True + # fail the request if over past CHECK_PERIOD_S seconds, + # we got less than CHECK_MB_S MB/s on average ring_slot = niter % check_period if niter >= check_period and xenfree < xenfree_ring[ring_slot] + check_delta: return False