From: ChenLiang <chenlian...@huawei.com> clear the dead code
Signed-off-by: ChenLiang <chenlian...@huawei.com> Signed-off-by: Gonglei <arei.gong...@huawei.com> Reviewed-by: Juan Quintela <quint...@redhat.com> --- arch_init.c | 13 ------------- page_cache.c | 58 ---------------------------------------------------------- 2 files changed, 71 deletions(-) diff --git a/arch_init.c b/arch_init.c index 76e13aa..cf3800c 100644 --- a/arch_init.c +++ b/arch_init.c @@ -163,14 +163,11 @@ static inline bool is_zero_range(uint8_t *p, uint64_t size) static struct { /* buffer used for XBZRLE encoding */ uint8_t *encoded_buf; - /* buffer for storing page content */ - uint8_t *current_buf; /* Cache for XBZRLE, Protected by lock. */ PageCache *cache; QemuMutex lock; } XBZRLE = { .encoded_buf = NULL, - .current_buf = NULL, .cache = NULL, }; /* buffer used for XBZRLE decoding */ @@ -704,10 +701,8 @@ static void migration_end(void) cache_fini(XBZRLE.cache); g_free(XBZRLE.cache); g_free(XBZRLE.encoded_buf); - g_free(XBZRLE.current_buf); XBZRLE.cache = NULL; XBZRLE.encoded_buf = NULL; - XBZRLE.current_buf = NULL; } XBZRLE_cache_unlock(); } @@ -759,14 +754,6 @@ static int ram_save_setup(QEMUFile *f, void *opaque) return -1; } - XBZRLE.current_buf = g_try_malloc(TARGET_PAGE_SIZE); - if (!XBZRLE.current_buf) { - DPRINTF("Error allocating current_buf\n"); - g_free(XBZRLE.encoded_buf); - XBZRLE.encoded_buf = NULL; - return -1; - } - acct_clear(); } diff --git a/page_cache.c b/page_cache.c index 3190c55..7dfa762 100644 --- a/page_cache.c +++ b/page_cache.c @@ -48,7 +48,6 @@ struct PageCache { CacheItem *page_cache; unsigned int page_size; int64_t max_num_items; - uint64_t max_item_age; int64_t num_items; }; @@ -76,7 +75,6 @@ PageCache *cache_init(int64_t num_pages, unsigned int page_size) } cache->page_size = page_size; cache->num_items = 0; - cache->max_item_age = 0; cache->max_num_items = num_pages; DPRINTF("Setting cache buckets to %" PRId64 "\n", cache->max_num_items); @@ -187,59 +185,3 @@ int cache_insert(PageCache *cache, uint64_t addr, const uint8_t *pdata, return 0; } - -int64_t cache_resize(PageCache *cache, int64_t new_num_pages) -{ - PageCache *new_cache; - int64_t i; - - CacheItem *old_it, *new_it; - - g_assert(cache); - - /* cache was not inited */ - if (cache->page_cache == NULL) { - return -1; - } - - /* same size */ - if (pow2floor(new_num_pages) == cache->max_num_items) { - return cache->max_num_items; - } - - new_cache = cache_init(new_num_pages, cache->page_size); - if (!(new_cache)) { - DPRINTF("Error creating new cache\n"); - return -1; - } - - /* move all data from old cache */ - for (i = 0; i < cache->max_num_items; i++) { - old_it = &cache->page_cache[i]; - if (old_it->it_addr != -1) { - /* check for collision, if there is, keep MRU page */ - new_it = cache_get_by_addr(new_cache, old_it->it_addr); - if (new_it->it_data && new_it->it_age >= old_it->it_age) { - /* keep the MRU page */ - g_free(old_it->it_data); - } else { - if (!new_it->it_data) { - new_cache->num_items++; - } - g_free(new_it->it_data); - new_it->it_data = old_it->it_data; - new_it->it_age = old_it->it_age; - new_it->it_addr = old_it->it_addr; - } - } - } - - g_free(cache->page_cache); - cache->page_cache = new_cache->page_cache; - cache->max_num_items = new_cache->max_num_items; - cache->num_items = new_cache->num_items; - - g_free(new_cache); - - return cache->max_num_items; -} -- 1.7.12.4