ram.c (51b07548f7c31793adc178c7460c5f4369733c61) | ram.c (87dca0c9bb63014ef73ad82f7aedea1cb5a822e7) |
---|---|
1/* 2 * QEMU System Emulator 3 * 4 * Copyright (c) 2003-2008 Fabrice Bellard 5 * Copyright (c) 2011-2015 Red Hat Inc 6 * 7 * Authors: 8 * Juan Quintela <quintela@redhat.com> --- 142 unchanged lines hidden (view full) --- 151 /* it will store a page full of zeros */ 152 uint8_t *zero_target_page; 153 /* buffer used for XBZRLE decoding */ 154 uint8_t *decoded_buf; 155} XBZRLE; 156 157static void XBZRLE_cache_lock(void) 158{ | 1/* 2 * QEMU System Emulator 3 * 4 * Copyright (c) 2003-2008 Fabrice Bellard 5 * Copyright (c) 2011-2015 Red Hat Inc 6 * 7 * Authors: 8 * Juan Quintela <quintela@redhat.com> --- 142 unchanged lines hidden (view full) --- 151 /* it will store a page full of zeros */ 152 uint8_t *zero_target_page; 153 /* buffer used for XBZRLE decoding */ 154 uint8_t *decoded_buf; 155} XBZRLE; 156 157static void XBZRLE_cache_lock(void) 158{ |
159 if (migrate_use_xbzrle()) { | 159 if (migrate_xbzrle()) { |
160 qemu_mutex_lock(&XBZRLE.lock); 161 } 162} 163 164static void XBZRLE_cache_unlock(void) 165{ | 160 qemu_mutex_lock(&XBZRLE.lock); 161 } 162} 163 164static void XBZRLE_cache_unlock(void) 165{ |
166 if (migrate_use_xbzrle()) { | 166 if (migrate_xbzrle()) { |
167 qemu_mutex_unlock(&XBZRLE.lock); 168 } 169} 170 171/** 172 * xbzrle_cache_resize: resize the xbzrle cache 173 * 174 * This function is called from migrate_params_apply in main --- 957 unchanged lines hidden (view full) --- 1132 /* calculate period counters */ 1133 ram_counters.dirty_pages_rate = rs->num_dirty_pages_period * 1000 1134 / (end_time - rs->time_last_bitmap_sync); 1135 1136 if (!page_count) { 1137 return; 1138 } 1139 | 167 qemu_mutex_unlock(&XBZRLE.lock); 168 } 169} 170 171/** 172 * xbzrle_cache_resize: resize the xbzrle cache 173 * 174 * This function is called from migrate_params_apply in main --- 957 unchanged lines hidden (view full) --- 1132 /* calculate period counters */ 1133 ram_counters.dirty_pages_rate = rs->num_dirty_pages_period * 1000 1134 / (end_time - rs->time_last_bitmap_sync); 1135 1136 if (!page_count) { 1137 return; 1138 } 1139 |
1140 if (migrate_use_xbzrle()) { | 1140 if (migrate_xbzrle()) { |
1141 double encoded_size, unencoded_size; 1142 1143 xbzrle_counters.cache_miss_rate = (double)(xbzrle_counters.cache_miss - 1144 rs->xbzrle_cache_miss_prev) / page_count; 1145 rs->xbzrle_cache_miss_prev = xbzrle_counters.cache_miss; 1146 unencoded_size = (xbzrle_counters.pages - rs->xbzrle_pages_prev) * 1147 TARGET_PAGE_SIZE; 1148 encoded_size = xbzrle_counters.bytes - rs->xbzrle_bytes_prev; --- 472 unchanged lines hidden (view full) --- 1621 */ 1622 flush_compressed_data(rs); 1623 1624 /* Hit the end of the list */ 1625 pss->block = QLIST_FIRST_RCU(&ram_list.blocks); 1626 /* Flag that we've looped */ 1627 pss->complete_round = true; 1628 /* After the first round, enable XBZRLE. */ | 1141 double encoded_size, unencoded_size; 1142 1143 xbzrle_counters.cache_miss_rate = (double)(xbzrle_counters.cache_miss - 1144 rs->xbzrle_cache_miss_prev) / page_count; 1145 rs->xbzrle_cache_miss_prev = xbzrle_counters.cache_miss; 1146 unencoded_size = (xbzrle_counters.pages - rs->xbzrle_pages_prev) * 1147 TARGET_PAGE_SIZE; 1148 encoded_size = xbzrle_counters.bytes - rs->xbzrle_bytes_prev; --- 472 unchanged lines hidden (view full) --- 1621 */ 1622 flush_compressed_data(rs); 1623 1624 /* Hit the end of the list */ 1625 pss->block = QLIST_FIRST_RCU(&ram_list.blocks); 1626 /* Flag that we've looped */ 1627 pss->complete_round = true; 1628 /* After the first round, enable XBZRLE. */ |
1629 if (migrate_use_xbzrle()) { | 1629 if (migrate_xbzrle()) { |
1630 rs->xbzrle_enabled = true; 1631 } 1632 } 1633 /* Didn't find anything this time, but try again on the new block */ 1634 return PAGE_TRY_AGAIN; 1635 } else { 1636 /* We've found something */ 1637 return PAGE_DIRTY_FOUND; --- 1336 unchanged lines hidden (view full) --- 2974/* 2975 * For every allocation, we will try not to crash the VM if the 2976 * allocation failed. 2977 */ 2978static int xbzrle_init(void) 2979{ 2980 Error *local_err = NULL; 2981 | 1630 rs->xbzrle_enabled = true; 1631 } 1632 } 1633 /* Didn't find anything this time, but try again on the new block */ 1634 return PAGE_TRY_AGAIN; 1635 } else { 1636 /* We've found something */ 1637 return PAGE_DIRTY_FOUND; --- 1336 unchanged lines hidden (view full) --- 2974/* 2975 * For every allocation, we will try not to crash the VM if the 2976 * allocation failed. 2977 */ 2978static int xbzrle_init(void) 2979{ 2980 Error *local_err = NULL; 2981 |
2982 if (!migrate_use_xbzrle()) { | 2982 if (!migrate_xbzrle()) { |
2983 return 0; 2984 } 2985 2986 XBZRLE_cache_lock(); 2987 2988 XBZRLE.zero_target_page = g_try_malloc0(TARGET_PAGE_SIZE); 2989 if (!XBZRLE.zero_target_page) { 2990 error_report("%s: Error allocating zero page", __func__); --- 1738 unchanged lines hidden --- | 2983 return 0; 2984 } 2985 2986 XBZRLE_cache_lock(); 2987 2988 XBZRLE.zero_target_page = g_try_malloc0(TARGET_PAGE_SIZE); 2989 if (!XBZRLE.zero_target_page) { 2990 error_report("%s: Error allocating zero page", __func__); --- 1738 unchanged lines hidden --- |