From abb26d63e7e4492d306c13b7e0e799d4c11a067c Mon Sep 17 00:00:00 2001 From: Paolo Bonzini Date: Wed, 14 Nov 2012 16:00:51 +0100 Subject: exec: sort the memory from biggest to smallest Signed-off-by: Paolo Bonzini Signed-off-by: Juan Quintela --- arch_init.c | 30 ------------------------------ 1 file changed, 30 deletions(-) (limited to 'arch_init.c') diff --git a/arch_init.c b/arch_init.c index 67b14d24c1..5c8df3af41 100644 --- a/arch_init.c +++ b/arch_init.c @@ -505,35 +505,6 @@ uint64_t ram_bytes_total(void) return total; } -static int block_compar(const void *a, const void *b) -{ - RAMBlock * const *ablock = a; - RAMBlock * const *bblock = b; - - return strcmp((*ablock)->idstr, (*bblock)->idstr); -} - -static void sort_ram_list(void) -{ - RAMBlock *block, *nblock, **blocks; - int n; - n = 0; - QTAILQ_FOREACH(block, &ram_list.blocks, next) { - ++n; - } - blocks = g_malloc(n * sizeof *blocks); - n = 0; - QTAILQ_FOREACH_SAFE(block, &ram_list.blocks, next, nblock) { - blocks[n++] = block; - QTAILQ_REMOVE(&ram_list.blocks, block, next); - } - qsort(blocks, n, sizeof *blocks, block_compar); - while (--n >= 0) { - QTAILQ_INSERT_HEAD(&ram_list.blocks, blocks[n], next); - } - g_free(blocks); -} - static void migration_end(void) { if (migration_bitmap) { @@ -562,7 +533,6 @@ static void reset_ram_globals(void) { last_block = NULL; last_offset = 0; - sort_ram_list(); } #define MAX_WAIT 50 /* ms, half buffered_file limit */ -- cgit v1.2.1