qmemman: when a AppVM is low on memory, allow small adjustments
A small AppVM (say, with 100MB total) can go below prefmem, and still not be assigned memory, because of the MIN_TOTAL_MEMORY_TRANSFER threshold. So, if AppVM is below prefmem, allow for smaller mem-sets.
This commit is contained in:
parent
f6e3607d2d
commit
0c1f21a28e
@ -17,7 +17,8 @@ char *parse(char *buf)
|
||||
static char outbuf[4096];
|
||||
int val;
|
||||
int len;
|
||||
int MemTotal=0, MemFree=0, Buffers=0, Cached=0, SwapTotal=0, SwapFree=0;
|
||||
int MemTotal = 0, MemFree = 0, Buffers = 0, Cached = 0, SwapTotal =
|
||||
0, SwapFree = 0;
|
||||
unsigned long long key;
|
||||
long used_mem, used_mem_diff;
|
||||
int nitems = 0;
|
||||
@ -54,10 +55,12 @@ char *parse(char *buf)
|
||||
return NULL;
|
||||
|
||||
used_mem_diff = used_mem - prev_used_mem;
|
||||
prev_used_mem = used_mem;
|
||||
if (used_mem_diff < 0)
|
||||
used_mem_diff = -used_mem_diff;
|
||||
if (used_mem_diff > used_mem_change_threshold) {
|
||||
if (used_mem_diff > used_mem_change_threshold
|
||||
|| (used_mem > prev_used_mem && used_mem * 13 / 10 > MemTotal
|
||||
&& used_mem_diff > used_mem_change_threshold/2)) {
|
||||
prev_used_mem = used_mem;
|
||||
sprintf(outbuf,
|
||||
"MemTotal: %d kB\nMemFree: %d kB\nBuffers: %d kB\nCached: %d kB\n"
|
||||
"SwapTotal: %d kB\nSwapFree: %d kB\n", MemTotal,
|
||||
@ -82,8 +85,7 @@ void send_to_qmemman(struct xs_handle *xs, char *data)
|
||||
}
|
||||
}
|
||||
|
||||
int
|
||||
main(int argc, char **argv)
|
||||
int main(int argc, char **argv)
|
||||
{
|
||||
char buf[4096];
|
||||
int n;
|
||||
|
@ -101,10 +101,16 @@ class SystemState:
|
||||
def is_balance_req_significant(self, memset_reqs):
|
||||
total_memory_transfer = 0
|
||||
MIN_TOTAL_MEMORY_TRANSFER = 150*1024*1024
|
||||
MIN_MEM_CHANGE_WHEN_UNDER_PREF = 15*1024*1024
|
||||
for rq in memset_reqs:
|
||||
dom, mem = rq
|
||||
memory_change = mem - self.domdict[dom].last_target
|
||||
last_target = self.domdict[dom].last_target
|
||||
memory_change = mem - last_target
|
||||
total_memory_transfer += abs(memory_change)
|
||||
pref = qmemman_algo.prefmem(self.domdict[dom])
|
||||
if last_target > 0 and last_target < pref and memory_change > MIN_MEM_CHANGE_WHEN_UNDER_PREF:
|
||||
print 'dom', dom, 'is below pref, allowing balance'
|
||||
return True
|
||||
return total_memory_transfer > MIN_TOTAL_MEMORY_TRANSFER
|
||||
|
||||
def print_stats(self, xenfree, memset_reqs):
|
||||
|
Loading…
Reference in New Issue
Block a user