Compare commits
5 Commits
qdev-array
...
zero-page-
Author | SHA1 | Date | |
---|---|---|---|
|
a7e7f47f14 | ||
|
fe9a3b860a | ||
|
ea9609508e | ||
|
9137628939 | ||
|
91d8ade20c |
@@ -561,7 +561,6 @@ void mig_throttle_counter_reset(void)
|
|||||||
/**
|
/**
|
||||||
* xbzrle_cache_zero_page: insert a zero page in the XBZRLE cache
|
* xbzrle_cache_zero_page: insert a zero page in the XBZRLE cache
|
||||||
*
|
*
|
||||||
* @rs: current RAM state
|
|
||||||
* @current_addr: address for the zero page
|
* @current_addr: address for the zero page
|
||||||
*
|
*
|
||||||
* Update the xbzrle cache to reflect a page that's been sent as all 0.
|
* Update the xbzrle cache to reflect a page that's been sent as all 0.
|
||||||
@@ -570,7 +569,7 @@ void mig_throttle_counter_reset(void)
|
|||||||
* As a bonus, if the page wasn't in the cache it gets added so that
|
* As a bonus, if the page wasn't in the cache it gets added so that
|
||||||
* when a small write is made into the 0'd page it gets XBZRLE sent.
|
* when a small write is made into the 0'd page it gets XBZRLE sent.
|
||||||
*/
|
*/
|
||||||
static void xbzrle_cache_zero_page(RAMState *rs, ram_addr_t current_addr)
|
static void xbzrle_cache_zero_page(ram_addr_t current_addr)
|
||||||
{
|
{
|
||||||
/* We don't care if this fails to allocate a new cache page
|
/* We don't care if this fails to allocate a new cache page
|
||||||
* as long as it updated an old one */
|
* as long as it updated an old one */
|
||||||
@@ -1129,51 +1128,46 @@ void ram_release_page(const char *rbname, uint64_t offset)
|
|||||||
ram_discard_range(rbname, offset, TARGET_PAGE_SIZE);
|
ram_discard_range(rbname, offset, TARGET_PAGE_SIZE);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* save_zero_page_to_file: send the zero page to the file
|
|
||||||
*
|
|
||||||
* Returns the size of data written to the file, 0 means the page is not
|
|
||||||
* a zero page
|
|
||||||
*
|
|
||||||
* @pss: current PSS channel
|
|
||||||
* @block: block that contains the page we want to send
|
|
||||||
* @offset: offset inside the block for the page
|
|
||||||
*/
|
|
||||||
static int save_zero_page_to_file(PageSearchStatus *pss, QEMUFile *file,
|
|
||||||
RAMBlock *block, ram_addr_t offset)
|
|
||||||
{
|
|
||||||
uint8_t *p = block->host + offset;
|
|
||||||
int len = 0;
|
|
||||||
|
|
||||||
if (buffer_is_zero(p, TARGET_PAGE_SIZE)) {
|
|
||||||
len += save_page_header(pss, file, block, offset | RAM_SAVE_FLAG_ZERO);
|
|
||||||
qemu_put_byte(file, 0);
|
|
||||||
len += 1;
|
|
||||||
ram_release_page(block->idstr, offset);
|
|
||||||
}
|
|
||||||
return len;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* save_zero_page: send the zero page to the stream
|
* save_zero_page: send the zero page to the stream
|
||||||
*
|
*
|
||||||
* Returns the number of pages written.
|
* Returns the number of pages written.
|
||||||
*
|
*
|
||||||
|
* @rs: current RAM state
|
||||||
* @pss: current PSS channel
|
* @pss: current PSS channel
|
||||||
* @block: block that contains the page we want to send
|
* @block: block that contains the page we want to send
|
||||||
* @offset: offset inside the block for the page
|
* @offset: offset inside the block for the page
|
||||||
*/
|
*/
|
||||||
static int save_zero_page(PageSearchStatus *pss, QEMUFile *f, RAMBlock *block,
|
static int save_zero_page(RAMState *rs, PageSearchStatus *pss, RAMBlock *block,
|
||||||
ram_addr_t offset)
|
ram_addr_t offset)
|
||||||
{
|
{
|
||||||
int len = save_zero_page_to_file(pss, f, block, offset);
|
uint8_t *p = block->host + offset;
|
||||||
|
QEMUFile *file = pss->pss_channel;
|
||||||
|
int len = 0;
|
||||||
|
|
||||||
if (len) {
|
if (!buffer_is_zero(p, TARGET_PAGE_SIZE)) {
|
||||||
stat64_add(&mig_stats.zero_pages, 1);
|
return 0;
|
||||||
ram_transferred_add(len);
|
|
||||||
return 1;
|
|
||||||
}
|
}
|
||||||
return -1;
|
|
||||||
|
len += save_page_header(pss, file, block, offset | RAM_SAVE_FLAG_ZERO);
|
||||||
|
qemu_put_byte(file, 0);
|
||||||
|
len += 1;
|
||||||
|
ram_release_page(block->idstr, offset);
|
||||||
|
|
||||||
|
stat64_add(&mig_stats.zero_pages, 1);
|
||||||
|
ram_transferred_add(len);
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Must let xbzrle know, otherwise a previous (now 0'd) cached
|
||||||
|
* page would be stale.
|
||||||
|
*/
|
||||||
|
if (rs->xbzrle_started) {
|
||||||
|
XBZRLE_cache_lock();
|
||||||
|
xbzrle_cache_zero_page(block->offset + offset);
|
||||||
|
XBZRLE_cache_unlock();
|
||||||
|
}
|
||||||
|
|
||||||
|
return len;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@@ -2141,17 +2135,8 @@ static int ram_save_target_page_legacy(RAMState *rs, PageSearchStatus *pss)
|
|||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
res = save_zero_page(pss, pss->pss_channel, block, offset);
|
if (save_zero_page(rs, pss, block, offset)) {
|
||||||
if (res > 0) {
|
return 1;
|
||||||
/* Must let xbzrle know, otherwise a previous (now 0'd) cached
|
|
||||||
* page would be stale
|
|
||||||
*/
|
|
||||||
if (rs->xbzrle_started) {
|
|
||||||
XBZRLE_cache_lock();
|
|
||||||
xbzrle_cache_zero_page(rs, block->offset + offset);
|
|
||||||
XBZRLE_cache_unlock();
|
|
||||||
}
|
|
||||||
return res;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
Reference in New Issue
Block a user