Creating RAMState for migration
Re: [Qemu-devel] [PATCH 44/51] ram: reorganize last_sent_block
In reply to Juan QuintelaQuoted 5 lines · * Juan Quintela ([email protected]) wrote:
We were setting it far away of when we changed it. Now everything is done inside
save_page_header. Once there, reorganize code to pass RAMState.Signed-off-by Juan Quintela <[email protected]>
Quoted 121 lines
--- migration/ram.c | 36 +++++++++++++++--------------------- 1 file changed, 15 insertions(+), 21 deletions(-)migration/ram.c +15
-21@@ -453,18 +453,22 @@ void migrate_compress_threads_create(void)* @offset: offset inside the block for the page * in the lower bits, it contains flags */ -static size_t save_page_header (QEMUFile *f,RAMBlock *block,ram_addr_t offset) +static size_t save_page_header (RAMState *rs,RAMBlock *block,ram_addr_t offset) {size_t size, len; -qemu_put_be64 (f, offset); +if (block == rs->last_sent_block) { + offset |=RAM_SAVE_FLAG_CONTINUE ; + } +qemu_put_be64 (rs->f, offset); size =8 ;if (!(offset &RAM_SAVE_FLAG_CONTINUE )) { len =strlen (block->idstr); -qemu_put_byte (f, len); -qemu_put_buffer (f, (uint8_t *)block->idstr, len); +qemu_put_byte (rs->f, len); +qemu_put_buffer (rs->f, (uint8_t *)block->idstr, len); size +=1 + len; + rs->last_sent_block = block; }return size; }@@ -584,7 +588,7 @@ static int save_xbzrle_page(RAMState *rs, uint8_t **current_data, }/* Send XBZRLE based compressed page */ - bytes_xbzrle =save_page_header (rs->f, block, + bytes_xbzrle =save_page_header (rs, block, offset |RAM_SAVE_FLAG_XBZRLE );qemu_put_byte (rs->f,ENCODING_FLAG_XBZRLE );qemu_put_be16 (rs->f, encoded_len);@@ -769,7 +773,7 @@ static int save_zero_page(RAMState *rs, RAMBlock *block, ram_addr_t offset,if (is_zero_range (p,TARGET_PAGE_SIZE )) { rs->zero_pages++; rs->bytes_transferred += -save_page_header (rs->f, block, offset |RAM_SAVE_FLAG_COMPRESS ); +save_page_header (rs, block, offset |RAM_SAVE_FLAG_COMPRESS );qemu_put_byte (rs->f,0 ); rs->bytes_transferred +=1 ; pages =1 ;@@ -826,9 +830,6 @@ static int ram_save_page(RAMState *rs, PageSearchStatus *pss, bool last_stage) current_addr = block->offset + offset; -if (block == rs->last_sent_block) { - offset |=RAM_SAVE_FLAG_CONTINUE ; - }if (ret !=RAM_SAVE_CONTROL_NOT_SUPP ) {if (ret !=RAM_SAVE_CONTROL_DELAYED ) {if (bytes_xmit >0 ) {@@ -860,8 +861,8 @@ static int ram_save_page(RAMState *rs, PageSearchStatus *pss, bool last_stage)/* XBZRLE overflow or normal page */ if (pages ==-1 ) { - rs->bytes_transferred +=save_page_header (rs->f, block, - offset |RAM_SAVE_FLAG_PAGE ); + rs->bytes_transferred +=save_page_header (rs, block, + offset |RAM_SAVE_FLAG_PAGE );if (send_async) { qemu_put_buffer_async(rs->f, p, TARGET_PAGE_SIZE, migrate_release_ram() &@@ -882,10 +883,11 @@ static int ram_save_page(RAMState *rs, PageSearchStatus *pss, bool last_stage)static int do_compress_ram_page (QEMUFile *f,RAMBlock *block,ram_addr_t offset) { +RAMState *rs = &ram_state;int bytes_sent, blen;uint8_t *p = block->host + (offset &TARGET_PAGE_MASK ); - bytes_sent =save_page_header (f, block, offset | + bytes_sent =save_page_header (rs, block, offset |RAM_SAVE_FLAG_COMPRESS_PAGE ); blen =qemu_put_compression_data (f, p,TARGET_PAGE_SIZE ,migrate_compress_level ());@@ -1016,7 +1018,7 @@ static int ram_save_compressed_page(RAMState *rs, PageSearchStatus *pss, pages =save_zero_page (rs, block, offset, p);if (pages ==-1 ) {/* Make sure the first page is sent out before other pages */ - bytes_xmit =save_page_header (rs->f, block, offset | + bytes_xmit =save_page_header (rs, block, offset |RAM_SAVE_FLAG_COMPRESS_PAGE ); blen =qemu_put_compression_data (rs->f, p,TARGET_PAGE_SIZE ,migrate_compress_level ());@@ -1033,7 +1035,6 @@ static int ram_save_compressed_page(RAMState *rs, PageSearchStatus *pss,ram_release_pages (block->idstr, pss->offset, pages); } }else { - offset |=RAM_SAVE_FLAG_CONTINUE ; pages =save_zero_page (rs, block, offset, p);if (pages ==-1 ) { pages =compress_page_with_multi_thread (rs, block, offset);@@ -1330,13 +1331,6 @@ static int ram_save_target_page(RAMState *rs, PageSearchStatus *pss,if (unsentmap) {clear_bit (dirty_ram_abs >>TARGET_PAGE_BITS , unsentmap); } -/* Only update last_sent_block if a block was actually sent; xbzrle -* might have decided the page was identical so didn't bother writing -* to the stream. -*/ -if (res >0 ) { - rs->last_sent_block = pss->block; - } }return res;Signature · 1 line
2.9.3
--
Dr. David Alan Gilbert / [email protected] / Manchester, UK
PATCH v2 45/51 ram: Use page number instead of an address for the bitmap operations
In reply to Juan QuintelaWe use an unsigned long for the page number. Notice that our bitmaps already got that for the index, so we have that limit.
--- migration/ram.c | 76 ++++++++++++++++++++++++++------------------------------- 1 file changed, 34 insertions(+), 42 deletions(-)
migration/ram.c +34 -42
@@ -611,13 +611,12 @@ static int save_xbzrle_page(RAMState *rs, uint8_t **current_data,* @rs: current RAM state * @rb: RAMBlock where to search for dirty pages * @start: starting address (typically so we can continue from previous page) -* @ram_addr_abs: pointer into which to store the address of the dirty page -* within the global ram_addr space +* @page: pointer into where to store the dirty page */ static inline ram_addr_t migration_bitmap_find_dirty (RAMState *rs,RAMBlock *rb,ram_addr_t start, -ram_addr_t *ram_addr_abs) +unsigned long *page) {unsigned long base = rb->offset >>TARGET_PAGE_BITS ;unsigned long nr = base + (start >>TARGET_PAGE_BITS );
@@ -634,17 +633,17 @@ ram_addr_t migration_bitmap_find_dirty(RAMState *rs, RAMBlock *rb, next =find_next_bit (bitmap, size, nr); } - *ram_addr_abs = next <<TARGET_PAGE_BITS ; + *page = next;return (next - base) <<TARGET_PAGE_BITS ; } -static inline bool migration_bitmap_clear_dirty (RAMState *rs,ram_addr_t addr) +static inline bool migration_bitmap_clear_dirty (RAMState *rs, +unsigned long page) {bool ret; -int nr = addr >>TARGET_PAGE_BITS ;unsigned long *bitmap =atomic_rcu_read (&rs->ram_bitmap)->bmap; - ret =test_and_clear_bit (nr, bitmap); + ret =test_and_clear_bit (page, bitmap);if (ret) { rs->migration_dirty_pages--;
@@ -1056,14 +1055,13 @@ static int ram_save_compressed_page(RAMState *rs, PageSearchStatus *pss,* @rs: current RAM state * @pss: data about the state of the current dirty page scan * @again: set to false if the search has scanned the whole of RAM -* @ram_addr_abs: pointer into which to store the address of the dirty page -* within the global ram_addr space +* @page: pointer into where to store the dirty page */ static bool find_dirty_block (RAMState *rs,PageSearchStatus *pss, -bool *again,ram_addr_t *ram_addr_abs) +bool *again,unsigned long *page) { pss->offset =migration_bitmap_find_dirty (rs, pss->block, pss->offset, - ram_addr_abs); + page);if (pss->complete_round && pss->block == rs->last_seen_block && pss->offset >= rs->last_offset) {/*
@@ -1111,11 +1109,10 @@ static bool find_dirty_block(RAMState *rs, PageSearchStatus *pss,* * @rs: current RAM state * @offset: used to return the offset within the RAMBlock -* @ram_addr_abs: pointer into which to store the address of the dirty page -* within the global ram_addr space +* @page: pointer into where to store the dirty page */ static RAMBlock *unqueue_page (RAMState *rs,ram_addr_t *offset, -ram_addr_t *ram_addr_abs) +unsigned long *page) {RAMBlock *block =NULL ;
@@ -1125,8 +1122,7 @@ static RAMBlock *unqueue_page(RAMState *rs, ram_addr_t *offset,QSIMPLEQ_FIRST (&rs->src_page_requests); block = entry->rb; *offset = entry->offset; - *ram_addr_abs = (entry->offset + entry->rb->offset) & -TARGET_PAGE_MASK ; + *page = (entry->offset + entry->rb->offset) >>TARGET_PAGE_BITS ;if (entry->len >TARGET_PAGE_SIZE ) { entry->len -=TARGET_PAGE_SIZE ;
@@ -1151,18 +1147,17 @@ static RAMBlock *unqueue_page(RAMState *rs, ram_addr_t *offset,* * @rs: current RAM state * @pss: data about the state of the current dirty page scan -* @ram_addr_abs: pointer into which to store the address of the dirty page -* within the global ram_addr space +* @page: pointer into where to store the dirty page */ static bool get_queued_page (RAMState *rs,PageSearchStatus *pss, -ram_addr_t *ram_addr_abs) +unsigned long *page) {RAMBlock *block;ram_addr_t offset;bool dirty; do { - block = unqueue_page(rs, &offset, ram_addr_abs); + block = unqueue_page(rs, &offset, page); /* * We're sending this page, and since it's postcopy nothing else * will dirty it, and we must make sure it doesn't get sent again
@@ -1172,17 +1167,15 @@ static bool get_queued_page(RAMState *rs, PageSearchStatus *pss,if (block) {unsigned long *bitmap; bitmap =atomic_rcu_read (&rs->ram_bitmap)->bmap; - dirty =test_bit (*ram_addr_abs >>TARGET_PAGE_BITS , bitmap); + dirty =test_bit (*page, bitmap);if (!dirty) { -trace_get_queued_page_not_dirty ( - block->idstr, (uint64_t )offset, - (uint64_t )*ram_addr_abs, -test_bit (*ram_addr_abs >>TARGET_PAGE_BITS , -atomic_rcu_read (&rs->ram_bitmap)->unsentmap)); +trace_get_queued_page_not_dirty (block->idstr, (uint64_t )offset, + *page, +test_bit (*page, +atomic_rcu_read (&rs->ram_bitmap)->unsentmap)); }else { -trace_get_queued_page (block->idstr, - (uint64_t )offset, - (uint64_t )*ram_addr_abs); +trace_get_queued_page (block->idstr, (uint64_t )offset, + *page); } }
@@ -1308,15 +1301,15 @@ err:* @ms: current migration state * @pss: data about the page we want to send * @last_stage: if we are at the completion stage -* @dirty_ram_abs: address of the start of the dirty page in ram_addr_t space +* @page: page number of the dirty page */ static int ram_save_target_page (RAMState *rs,PageSearchStatus *pss, -bool last_stage,ram_addr_t dirty_ram_abs) +bool last_stage,unsigned long page) {int res =0 ;/* Check the pages is dirty and if it is send it */ -if (migration_bitmap_clear_dirty (rs, dirty_ram_abs)) { +if (migration_bitmap_clear_dirty (rs, page)) {unsigned long *unsentmap;if (!rs->preffer_xbzrle &&migrate_use_compression ()) { res =ram_save_compressed_page (rs, pss, last_stage);
@@ -1329,7 +1322,7 @@ static int ram_save_target_page(RAMState *rs, PageSearchStatus *pss, } unsentmap =atomic_rcu_read (&rs->ram_bitmap)->unsentmap;if (unsentmap) { -clear_bit (dirty_ram_abs >>TARGET_PAGE_BITS , unsentmap); +clear_bit (page, unsentmap); } }
@@ -1351,24 +1344,24 @@ static int ram_save_target_page(RAMState *rs, PageSearchStatus *pss,* @ms: current migration state * @pss: data about the page we want to send * @last_stage: if we are at the completion stage -* @dirty_ram_abs: Address of the start of the dirty page in ram_addr_t space +* @page: Page number of the dirty page */ static int ram_save_host_page (RAMState *rs,PageSearchStatus *pss,bool last_stage, -ram_addr_t dirty_ram_abs) +unsigned long page) {int tmppages, pages =0 ;size_t pagesize =qemu_ram_pagesize (pss->block);do { - tmppages =ram_save_target_page (rs, pss, last_stage, dirty_ram_abs); + tmppages =ram_save_target_page (rs, pss, last_stage, page);if (tmppages <0 ) {return tmppages; } pages += tmppages; pss->offset +=TARGET_PAGE_SIZE ; - dirty_ram_abs +=TARGET_PAGE_SIZE ; + page++; }while (pss->offset & (pagesize -1 ));/* The offset we leave with is the last one we looked at */
@@ -1395,8 +1388,7 @@ static int ram_find_and_save_block(RAMState *rs, bool last_stage)PageSearchStatus pss;int pages =0 ;bool again, found; -ram_addr_t dirty_ram_abs;/* Address of the start of the dirty page in -ram_addr_t space */ +unsigned long page;/* Page number of the dirty page */ /* No dirty page as there is zero RAM */ if (!ram_bytes_total ()) {
@@ -1413,15 +1405,15 @@ static int ram_find_and_save_block(RAMState *rs, bool last_stage)do { again = true; - found =get_queued_page (rs, &pss, &dirty_ram_abs); + found =get_queued_page (rs, &pss, &page);if (!found) {/* priority queue empty, so just search for something dirty */ - found =find_dirty_block (rs, &pss, &again, &dirty_ram_abs); + found =find_dirty_block (rs, &pss, &again, &page); }if (found) { - pages =ram_save_host_page (rs, &pss, last_stage, dirty_ram_abs); + pages =ram_save_host_page (rs, &pss, last_stage, page); } }while (!pages && again);
Signature · 1 line
2.9.3
Re: [Qemu-devel] [PATCH 45/51] ram: Use page number instead of an address for the bitmap operations
Quoted 13 lines · * Juan Quintela ([email protected]) wrote:
We use an unsigned long for the page number. Notice that our bitmaps already got that for the index, so we have that limit.
Signed-off-by Juan Quintela <[email protected]>--- migration/ram.c | 76 ++++++++++++++++++++++++++------------------------------- 1 file changed, 34 insertions(+), 42 deletions(-)migration/ram.c +0
-0
migration/ram.c static int save_xbzrle_page(RAMState *rs, uint8_t **current_data, · line 614
Quoted 6 lines
migration/ram.c +1
-2@@ -611,13 +611,12 @@ static int save_xbzrle_page(RAMState *rs, uint8_t **current_data,* @rs: current RAM state * @rb: RAMBlock where to search for dirty pages * @start: starting address (typically so we can continue from previous page) -* @ram_addr_abs: pointer into which to store the address of the dirty page -* within the global ram_addr space +* @page: pointer into where to store the dirty page
I'd prefer if you could call it 'page_abs' - it often gets tricky to know whether we're talking about a page offset within a RAMBlock or an offset within the whole bitmap.
(I wish we had different index types)
Quoted 107 lines
migration/ram.c +15
-24*/ static inline ram_addr_t migration_bitmap_find_dirty (RAMState *rs,RAMBlock *rb,ram_addr_t start, -ram_addr_t *ram_addr_abs) +unsigned long *page) {unsigned long base = rb->offset >>TARGET_PAGE_BITS ;unsigned long nr = base + (start >>TARGET_PAGE_BITS );@@ -634,17 +633,17 @@ ram_addr_t migration_bitmap_find_dirty(RAMState *rs, RAMBlock *rb, next =find_next_bit (bitmap, size, nr); } - *ram_addr_abs = next <<TARGET_PAGE_BITS ; + *page = next;return (next - base) <<TARGET_PAGE_BITS ; } -static inline bool migration_bitmap_clear_dirty (RAMState *rs,ram_addr_t addr) +static inline bool migration_bitmap_clear_dirty (RAMState *rs, +unsigned long page) {bool ret; -int nr = addr >>TARGET_PAGE_BITS ;unsigned long *bitmap =atomic_rcu_read (&rs->ram_bitmap)->bmap; - ret =test_and_clear_bit (nr, bitmap); + ret =test_and_clear_bit (page, bitmap);if (ret) { rs->migration_dirty_pages--;@@ -1056,14 +1055,13 @@ static int ram_save_compressed_page(RAMState *rs, PageSearchStatus *pss,* @rs: current RAM state * @pss: data about the state of the current dirty page scan * @again: set to false if the search has scanned the whole of RAM -* @ram_addr_abs: pointer into which to store the address of the dirty page -* within the global ram_addr space +* @page: pointer into where to store the dirty page */ static bool find_dirty_block (RAMState *rs,PageSearchStatus *pss, -bool *again,ram_addr_t *ram_addr_abs) +bool *again,unsigned long *page) { pss->offset =migration_bitmap_find_dirty (rs, pss->block, pss->offset, - ram_addr_abs); + page);if (pss->complete_round && pss->block == rs->last_seen_block && pss->offset >= rs->last_offset) {/* @@ -1111,11 +1109,10 @@ static bool find_dirty_block(RAMState *rs, PageSearchStatus *pss,* * @rs: current RAM state * @offset: used to return the offset within the RAMBlock -* @ram_addr_abs: pointer into which to store the address of the dirty page -* within the global ram_addr space +* @page: pointer into where to store the dirty page */ static RAMBlock *unqueue_page (RAMState *rs,ram_addr_t *offset, -ram_addr_t *ram_addr_abs) +unsigned long *page) {RAMBlock *block =NULL ;@@ -1125,8 +1122,7 @@ static RAMBlock *unqueue_page(RAMState *rs, ram_addr_t *offset,QSIMPLEQ_FIRST (&rs->src_page_requests); block = entry->rb; *offset = entry->offset; - *ram_addr_abs = (entry->offset + entry->rb->offset) & -TARGET_PAGE_MASK ; + *page = (entry->offset + entry->rb->offset) >>TARGET_PAGE_BITS ;if (entry->len >TARGET_PAGE_SIZE ) { entry->len -=TARGET_PAGE_SIZE ;@@ -1151,18 +1147,17 @@ static RAMBlock *unqueue_page(RAMState *rs, ram_addr_t *offset,* * @rs: current RAM state * @pss: data about the state of the current dirty page scan -* @ram_addr_abs: pointer into which to store the address of the dirty page -* within the global ram_addr space +* @page: pointer into where to store the dirty page */ static bool get_queued_page (RAMState *rs,PageSearchStatus *pss, -ram_addr_t *ram_addr_abs) +unsigned long *page) {RAMBlock *block;ram_addr_t offset;bool dirty; do { - block = unqueue_page(rs, &offset, ram_addr_abs); + block = unqueue_page(rs, &offset, page); /* * We're sending this page, and since it's postcopy nothing else * will dirty it, and we must make sure it doesn't get sent again@@ -1172,17 +1167,15 @@ static bool get_queued_page(RAMState *rs, PageSearchStatus *pss,if (block) {unsigned long *bitmap; bitmap =atomic_rcu_read (&rs->ram_bitmap)->bmap; - dirty =test_bit (*ram_addr_abs >>TARGET_PAGE_BITS , bitmap); + dirty =test_bit (*page, bitmap);if (!dirty) { -trace_get_queued_page_not_dirty ( - block->idstr, (uint64_t )offset, - (uint64_t )*ram_addr_abs, -test_bit (*ram_addr_abs >>TARGET_PAGE_BITS , -atomic_rcu_read (&rs->ram_bitmap)->unsentmap));
migration/ram.c static bool get_queued_page(RAMState *rs, PageSearchStatus *pss, · line 1178
Quoted 10 lines
migration/ram.c +6
-3+trace_get_queued_page_not_dirty (block->idstr, (uint64_t )offset, + *page, +test_bit (*page, +atomic_rcu_read (&rs->ram_bitmap)->unsentmap)); }else { -trace_get_queued_page (block->idstr, - (uint64_t )offset, - (uint64_t )*ram_addr_abs); +trace_get_queued_page (block->idstr, (uint64_t )offset, + *page);
I think you need to fix the trace_ definitions for get_queued_page and get_queued_page_not_dirty they're currently taking uint64_t's for ram_addr and they now need to be long's (with the format changes).
Dave
Quoted 92 lines
migration/ram.c +12
-13} }@@ -1308,15 +1301,15 @@ err:* @ms: current migration state * @pss: data about the page we want to send * @last_stage: if we are at the completion stage -* @dirty_ram_abs: address of the start of the dirty page in ram_addr_t space +* @page: page number of the dirty page */ static int ram_save_target_page (RAMState *rs,PageSearchStatus *pss, -bool last_stage,ram_addr_t dirty_ram_abs) +bool last_stage,unsigned long page) {int res =0 ;/* Check the pages is dirty and if it is send it */ -if (migration_bitmap_clear_dirty (rs, dirty_ram_abs)) { +if (migration_bitmap_clear_dirty (rs, page)) {unsigned long *unsentmap;if (!rs->preffer_xbzrle &&migrate_use_compression ()) { res =ram_save_compressed_page (rs, pss, last_stage);@@ -1329,7 +1322,7 @@ static int ram_save_target_page(RAMState *rs, PageSearchStatus *pss, } unsentmap =atomic_rcu_read (&rs->ram_bitmap)->unsentmap;if (unsentmap) { -clear_bit (dirty_ram_abs >>TARGET_PAGE_BITS , unsentmap); +clear_bit (page, unsentmap); } }@@ -1351,24 +1344,24 @@ static int ram_save_target_page(RAMState *rs, PageSearchStatus *pss,* @ms: current migration state * @pss: data about the page we want to send * @last_stage: if we are at the completion stage -* @dirty_ram_abs: Address of the start of the dirty page in ram_addr_t space +* @page: Page number of the dirty page */ static int ram_save_host_page (RAMState *rs,PageSearchStatus *pss,bool last_stage, -ram_addr_t dirty_ram_abs) +unsigned long page) {int tmppages, pages =0 ;size_t pagesize =qemu_ram_pagesize (pss->block);do { - tmppages =ram_save_target_page (rs, pss, last_stage, dirty_ram_abs); + tmppages =ram_save_target_page (rs, pss, last_stage, page);if (tmppages <0 ) {return tmppages; } pages += tmppages; pss->offset +=TARGET_PAGE_SIZE ; - dirty_ram_abs +=TARGET_PAGE_SIZE ; + page++; }while (pss->offset & (pagesize -1 ));/* The offset we leave with is the last one we looked at */ @@ -1395,8 +1388,7 @@ static int ram_find_and_save_block(RAMState *rs, bool last_stage)PageSearchStatus pss;int pages =0 ;bool again, found; -ram_addr_t dirty_ram_abs;/* Address of the start of the dirty page in -ram_addr_t space */ +unsigned long page;/* Page number of the dirty page */ /* No dirty page as there is zero RAM */ if (!ram_bytes_total ()) {@@ -1413,15 +1405,15 @@ static int ram_find_and_save_block(RAMState *rs, bool last_stage)do { again = true; - found =get_queued_page (rs, &pss, &dirty_ram_abs); + found =get_queued_page (rs, &pss, &page);if (!found) {/* priority queue empty, so just search for something dirty */ - found =find_dirty_block (rs, &pss, &again, &dirty_ram_abs); + found =find_dirty_block (rs, &pss, &again, &page); }if (found) { - pages =ram_save_host_page (rs, &pss, last_stage, dirty_ram_abs); + pages =ram_save_host_page (rs, &pss, last_stage, page); } }while (!pages && again);Signature · 1 line
2.9.3
--
Dr. David Alan Gilbert / [email protected] / Manchester, UK
Re: [Qemu-devel] [PATCH 45/51] ram: Use page number instead of an address for the bitmap operations
Quoted 9 lines · Dr. David Alan Gilbert
Quoted 8 lines · * Juan Quintela ([email protected]) wrote:
We use an unsigned long for the page number. Notice that our bitmaps already got that for the index, so we have that limit.
Signed-off-by Juan Quintela <[email protected]>--- migration/ram.c | 76 ++++++++++++++++++++++++++------------------------------- 1 file changed, 34 insertions(+), 42 deletions(-)
Quoted 16 lines
migration/ram.c static int save_xbzrle_page(RAMState *rs, uint8_t **current_data, · line 614
Quoted 11 lines
migration/ram.c +1
-2@@ -611,13 +611,12 @@ static int save_xbzrle_page(RAMState *rs, uint8_t **current_data,* @rs: current RAM state * @rb: RAMBlock where to search for dirty pages * @start: starting address (typically so we can continue from previous page) -* @ram_addr_abs: pointer into which to store the address of the dirty page -* within the global ram_addr space +* @page: pointer into where to store the dirty page I'd prefer if you could call it '
page_abs' - it often gets tricky to know whether we're talking about a page offset within a RAMBlock or an offset within
the whole bitmap.
I don't really care. Changed.
Quoted 1 line
(I wish we had different index types)
This is C man!!
Quoted 9 lines
migration/ram.c static bool get_queued_page(RAMState *rs, PageSearchStatus *pss, · line 1178
Quoted 5 lines
migration/ram.c +2
-3-trace_get_queued_page (block->idstr, - (uint64_t )offset, - (uint64_t )*ram_addr_abs); +trace_get_queued_page (block->idstr, (uint64_t )offset, + *page);I think you need to fix the
trace_definitions forget_queued_pageandget_queued_page_not_dirtythey're currently taking uint64_t's forram_addrand they now need to be long's (with the format changes).
Done.
Thanks, Juan.
PATCH v2 46/51 ram: Remember last_page instead of last_offset
In reply to Juan Quintela--- migration/ram.c | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-)
migration/ram.c +7 -7
@@ -171,8 +171,8 @@ struct RAMState {RAMBlock *last_seen_block;/* Last block from where we have sent data */ RAMBlock *last_sent_block; -/* Last offset we have sent data from */ -ram_addr_t last_offset; +/* Last dirty page we have sent */ +ram_addr_t last_page;/* last ram version we have seen */ uint32_t last_version;/* We are in the first round */
@@ -1063,7 +1063,7 @@ static bool find_dirty_block(RAMState *rs, PageSearchStatus *pss, pss->offset =migration_bitmap_find_dirty (rs, pss->block, pss->offset, page);if (pss->complete_round && pss->block == rs->last_seen_block && - pss->offset >= rs->last_offset) { + pss->offset >= rs->last_page) {/* * We've been once around the RAM and haven't found anything. * Give up.
@@ -1396,7 +1396,7 @@ static int ram_find_and_save_block(RAMState *rs, bool last_stage) } pss.block = rs->last_seen_block; - pss.offset = rs->last_offset; + pss.offset = rs->last_page <<TARGET_PAGE_BITS ; pss.complete_round = false;if (!pss.block) {
@@ -1418,7 +1418,7 @@ static int ram_find_and_save_block(RAMState *rs, bool last_stage) }while (!pages && again); rs->last_seen_block = pss.block; - rs->last_offset = pss.offset; + rs->last_page = pss.offset >>TARGET_PAGE_BITS ;return pages; }
@@ -1493,7 +1493,7 @@ static void ram_state_reset(RAMState *rs) { rs->last_seen_block =NULL ; rs->last_sent_block =NULL ; - rs->last_offset =0 ; + rs->last_page =0 ; rs->last_version = ram_list.version; rs->ram_bulk_stage = true; }
@@ -1838,7 +1838,7 @@ static int postcopy_chunk_hostpages(MigrationState *ms)/* Easiest way to make sure we don't resume in the middle of a host-page */ rs->last_seen_block =NULL ; rs->last_sent_block =NULL ; - rs->last_offset =0 ; + rs->last_page =0 ; QLIST_FOREACH_RCU(block, &ram_list.blocks, next) {unsigned long first = block->offset >>TARGET_PAGE_BITS ;
Signature · 1 line
2.9.3
Re: [Qemu-devel] [PATCH 46/51] ram: Remember last_page instead of last_offset
Quoted 10 lines · * Juan Quintela ([email protected]) wrote:
Signed-off-by Juan Quintela <[email protected]>--- migration/ram.c | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-)migration/ram.c +0
-0
migration/ram.c struct RAMState { · line 174
Quoted 6 lines
migration/ram.c +1
-2@@ -171,8 +171,8 @@ struct RAMState {RAMBlock *last_seen_block;/* Last block from where we have sent data */ RAMBlock *last_sent_block; -/* Last offset we have sent data from */ -ram_addr_t last_offset; +/* Last dirty page we have sent */
Can you make that 'Last dirty target page we have sent' just so we know which shape page we're dealing with.
migration/ram.c static bool find_dirty_block(RAMState *rs, PageSearchStatus *pss, · line 1066
Quoted 10 lines
migration/ram.c +2
-1+ram_addr_t last_page;/* last ram version we have seen */ uint32_t last_version;/* We are in the first round */ @@ -1063,7 +1063,7 @@ static bool find_dirty_block(RAMState *rs, PageSearchStatus *pss, pss->offset =migration_bitmap_find_dirty (rs, pss->block, pss->offset, page);if (pss->complete_round && pss->block == rs->last_seen_block && - pss->offset >= rs->last_offset) { + pss->offset >= rs->last_page) {
That's odd; isn't pss->offset still in bytes?
Dave
Quoted 42 lines
migration/ram.c +4
-4/* * We've been once around the RAM and haven't found anything. * Give up. @@ -1396,7 +1396,7 @@ static int ram_find_and_save_block(RAMState *rs, bool last_stage) } pss.block = rs->last_seen_block; - pss.offset = rs->last_offset; + pss.offset = rs->last_page <<TARGET_PAGE_BITS ; pss.complete_round = false;if (!pss.block) {@@ -1418,7 +1418,7 @@ static int ram_find_and_save_block(RAMState *rs, bool last_stage) }while (!pages && again); rs->last_seen_block = pss.block; - rs->last_offset = pss.offset; + rs->last_page = pss.offset >>TARGET_PAGE_BITS ;return pages; }@@ -1493,7 +1493,7 @@ static void ram_state_reset(RAMState *rs) { rs->last_seen_block =NULL ; rs->last_sent_block =NULL ; - rs->last_offset =0 ; + rs->last_page =0 ; rs->last_version = ram_list.version; rs->ram_bulk_stage = true; }@@ -1838,7 +1838,7 @@ static int postcopy_chunk_hostpages(MigrationState *ms)/* Easiest way to make sure we don't resume in the middle of a host-page */ rs->last_seen_block =NULL ; rs->last_sent_block =NULL ; - rs->last_offset =0 ; + rs->last_page =0 ; QLIST_FOREACH_RCU(block, &ram_list.blocks, next) {unsigned long first = block->offset >>TARGET_PAGE_BITS ;Signature · 1 line
2.9.3
--
Dr. David Alan Gilbert / [email protected] / Manchester, UK
Re: [Qemu-devel] [PATCH 46/51] ram: Remember last_page instead of last_offset
Quoted 6 lines · Dr. David Alan Gilbert
Quoted 5 lines · * Juan Quintela ([email protected]) wrote:
Signed-off-by Juan Quintela <[email protected]>--- migration/ram.c | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-)
Quoted 14 lines
migration/ram.c struct RAMState { · line 174
Quoted 11 lines
migration/ram.c +1
-2@@ -171,8 +171,8 @@ struct RAMState {RAMBlock *last_seen_block;/* Last block from where we have sent data */ RAMBlock *last_sent_block; -/* Last offset we have sent data from */ -ram_addr_t last_offset; +/* Last dirty page we have sent */ Can you make that 'Last dirty target page we have sent' just so we know which shape page we're dealing with.
Done.
Quoted 4 lines
Quoted 4 lines
migration/ram.c +1
-0+ram_addr_t last_page;/* last ram version we have seen */ uint32_t last_version;/* We are in the first round */
Quoted 8 lines
migration/ram.c static bool find_dirty_block(RAMState *rs, PageSearchStatus *pss, · line 1066
Quoted 6 lines
migration/ram.c +1
-1@@ -1063,7 +1063,7 @@ static bool find_dirty_block(RAMState *rs, PageSearchStatus *pss, pss->offset =migration_bitmap_find_dirty (rs, pss->block, pss->offset, page);if (pss->complete_round && pss->block == rs->last_seen_block && - pss->offset >= rs->last_offset) { + pss->offset >= rs->last_page) {That's odd; isn't
pss->offsetstill in bytes?
It is not odd, it is wrong.
Fixed.
Thanks, Juan.
PATCH v2 47/51 ram: Change offset field in PageSearchStatus to page
In reply to Juan QuintelaWe are moving everything to work on pages, not addresses.
--- migration/ram.c | 50 +++++++++++++++++++++++++------------------------- 1 file changed, 25 insertions(+), 25 deletions(-)
migration/ram.c +25 -25
@@ -298,8 +298,8 @@ uint64_t ram_postcopy_requests(void)struct PageSearchStatus {/* Current block being searched */ RAMBlock *block; -/* Current offset to search from */ -ram_addr_t offset; +/* Current page to search from */ +unsigned long page;/* Set once we wrap around */ bool complete_round; };
@@ -610,16 +610,16 @@ static int save_xbzrle_page(RAMState *rs, uint8_t **current_data,* * @rs: current RAM state * @rb: RAMBlock where to search for dirty pages -* @start: starting address (typically so we can continue from previous page) +* @start: page where we start the search * @page: pointer into where to store the dirty page */ static inline -ram_addr_t migration_bitmap_find_dirty (RAMState *rs,RAMBlock *rb, -ram_addr_t start, -unsigned long *page) +unsigned long migration_bitmap_find_dirty (RAMState *rs,RAMBlock *rb, +unsigned long start, +unsigned long *page) {unsigned long base = rb->offset >>TARGET_PAGE_BITS ; -unsigned long nr = base + (start >>TARGET_PAGE_BITS ); +unsigned long nr = base + start;uint64_t rb_size = rb->used_length;unsigned long size = base + (rb_size >>TARGET_PAGE_BITS );unsigned long *bitmap;
@@ -634,7 +634,7 @@ ram_addr_t migration_bitmap_find_dirty(RAMState *rs, RAMBlock *rb, } *page = next; -return (next - base) <<TARGET_PAGE_BITS ; +return next - base; } static inline bool migration_bitmap_clear_dirty(RAMState *rs,
@@ -812,7 +812,7 @@ static int ram_save_page(RAMState *rs, PageSearchStatus *pss, bool last_stage)int ret;bool send_async = true;RAMBlock *block = pss->block; -ram_addr_t offset = pss->offset; +ram_addr_t offset = pss->page <<TARGET_PAGE_BITS ; p = block->host + offset;
@@ -844,7 +844,7 @@ static int ram_save_page(RAMState *rs, PageSearchStatus *pss, bool last_stage)* page would be stale */ xbzrle_cache_zero_page (rs, current_addr); -ram_release_pages (block->idstr, pss->offset, pages); +ram_release_pages (block->idstr, offset, pages); }else if (!rs->ram_bulk_stage && !migration_in_postcopy () &&migrate_use_xbzrle ()) { pages = save_xbzrle_page(rs, &p, current_addr, block,
@@ -987,7 +987,7 @@ static int ram_save_compressed_page(RAMState *rs, PageSearchStatus *pss,uint8_t *p;int ret, blen;RAMBlock *block = pss->block; -ram_addr_t offset = pss->offset; +ram_addr_t offset = pss->page <<TARGET_PAGE_BITS ; p = block->host + offset;
@@ -1031,14 +1031,14 @@ static int ram_save_compressed_page(RAMState *rs, PageSearchStatus *pss, } }if (pages >0 ) { -ram_release_pages (block->idstr, pss->offset, pages); +ram_release_pages (block->idstr, offset, pages); } }else { pages =save_zero_page (rs, block, offset, p);if (pages ==-1 ) { pages =compress_page_with_multi_thread (rs, block, offset); }else { -ram_release_pages (block->idstr, pss->offset, pages); +ram_release_pages (block->idstr, offset, pages); } } }
@@ -1060,10 +1060,9 @@ static int ram_save_compressed_page(RAMState *rs, PageSearchStatus *pss,static bool find_dirty_block (RAMState *rs,PageSearchStatus *pss,bool *again,unsigned long *page) { - pss->offset =migration_bitmap_find_dirty (rs, pss->block, pss->offset, - page); + pss->page =migration_bitmap_find_dirty (rs, pss->block, pss->page, page);if (pss->complete_round && pss->block == rs->last_seen_block && - pss->offset >= rs->last_page) { + pss->page >= rs->last_page) {/* * We've been once around the RAM and haven't found anything. * Give up.
@@ -1071,9 +1070,9 @@ static bool find_dirty_block(RAMState *rs, PageSearchStatus *pss, *again = false;return false; } -if (pss->offset >= pss->block->used_length) { +if ((pss->page <<TARGET_PAGE_BITS ) >= pss->block->used_length) {/* Didn't find anything in this RAM Block */ - pss->offset =0 ; + pss->page =0 ; pss->block =QLIST_NEXT_RCU (pss->block, next);if (!pss->block) {/* Hit the end of the list */
@@ -1196,7 +1195,7 @@ static bool get_queued_page(RAMState *rs, PageSearchStatus *pss,* it just requested. */ pss->block = block; - pss->offset = offset; + pss->page = offset >>TARGET_PAGE_BITS ; }return !!block;
@@ -1351,7 +1350,8 @@ static int ram_save_host_page(RAMState *rs, PageSearchStatus *pss, unsigned long page) {int tmppages, pages =0 ; -size_t pagesize =qemu_ram_pagesize (pss->block); +size_t pagesize_bits = +qemu_ram_pagesize (pss->block) >>TARGET_PAGE_BITS ; do { tmppages = ram_save_target_page(rs, pss, last_stage, page);
@@ -1360,12 +1360,12 @@ static int ram_save_host_page(RAMState *rs, PageSearchStatus *pss, } pages += tmppages; - pss->offset +=TARGET_PAGE_SIZE ; + pss->page++; page++; - }while (pss->offset & (pagesize -1 )); + }while (pss->page & (pagesize_bits -1 ));/* The offset we leave with is the last one we looked at */ - pss->offset -=TARGET_PAGE_SIZE ; + pss->page--;return pages; }
@@ -1396,7 +1396,7 @@ static int ram_find_and_save_block(RAMState *rs, bool last_stage) } pss.block = rs->last_seen_block; - pss.offset = rs->last_page <<TARGET_PAGE_BITS ; + pss.page = rs->last_page; pss.complete_round = false;if (!pss.block) {
@@ -1418,7 +1418,7 @@ static int ram_find_and_save_block(RAMState *rs, bool last_stage) }while (!pages && again); rs->last_seen_block = pss.block; - rs->last_page = pss.offset >>TARGET_PAGE_BITS ; + rs->last_page = pss.page;return pages; }
Signature · 1 line
2.9.3
Re: [Qemu-devel] [PATCH 47/51] ram: Change offset field in PageSearchStatus to page
Quoted 3 lines · * Juan Quintela ([email protected]) wrote:
We are moving everything to work on pages, not addresses.
Signed-off-by Juan Quintela <[email protected]>
Quoted 175 lines
--- migration/ram.c | 50 +++++++++++++++++++++++++------------------------- 1 file changed, 25 insertions(+), 25 deletions(-)migration/ram.c +25
-25@@ -298,8 +298,8 @@ uint64_t ram_postcopy_requests(void)struct PageSearchStatus {/* Current block being searched */ RAMBlock *block; -/* Current offset to search from */ -ram_addr_t offset; +/* Current page to search from */ +unsigned long page;/* Set once we wrap around */ bool complete_round; };@@ -610,16 +610,16 @@ static int save_xbzrle_page(RAMState *rs, uint8_t **current_data,* * @rs: current RAM state * @rb: RAMBlock where to search for dirty pages -* @start: starting address (typically so we can continue from previous page) +* @start: page where we start the search * @page: pointer into where to store the dirty page */ static inline -ram_addr_t migration_bitmap_find_dirty (RAMState *rs,RAMBlock *rb, -ram_addr_t start, -unsigned long *page) +unsigned long migration_bitmap_find_dirty (RAMState *rs,RAMBlock *rb, +unsigned long start, +unsigned long *page) {unsigned long base = rb->offset >>TARGET_PAGE_BITS ; -unsigned long nr = base + (start >>TARGET_PAGE_BITS ); +unsigned long nr = base + start;uint64_t rb_size = rb->used_length;unsigned long size = base + (rb_size >>TARGET_PAGE_BITS );unsigned long *bitmap;@@ -634,7 +634,7 @@ ram_addr_t migration_bitmap_find_dirty(RAMState *rs, RAMBlock *rb, } *page = next; -return (next - base) <<TARGET_PAGE_BITS ; +return next - base; } static inline bool migration_bitmap_clear_dirty(RAMState *rs,@@ -812,7 +812,7 @@ static int ram_save_page(RAMState *rs, PageSearchStatus *pss, bool last_stage)int ret;bool send_async = true;RAMBlock *block = pss->block; -ram_addr_t offset = pss->offset; +ram_addr_t offset = pss->page <<TARGET_PAGE_BITS ; p = block->host + offset;@@ -844,7 +844,7 @@ static int ram_save_page(RAMState *rs, PageSearchStatus *pss, bool last_stage)* page would be stale */ xbzrle_cache_zero_page (rs, current_addr); -ram_release_pages (block->idstr, pss->offset, pages); +ram_release_pages (block->idstr, offset, pages); }else if (!rs->ram_bulk_stage && !migration_in_postcopy () &&migrate_use_xbzrle ()) { pages = save_xbzrle_page(rs, &p, current_addr, block,@@ -987,7 +987,7 @@ static int ram_save_compressed_page(RAMState *rs, PageSearchStatus *pss,uint8_t *p;int ret, blen;RAMBlock *block = pss->block; -ram_addr_t offset = pss->offset; +ram_addr_t offset = pss->page <<TARGET_PAGE_BITS ; p = block->host + offset;@@ -1031,14 +1031,14 @@ static int ram_save_compressed_page(RAMState *rs, PageSearchStatus *pss, } }if (pages >0 ) { -ram_release_pages (block->idstr, pss->offset, pages); +ram_release_pages (block->idstr, offset, pages); } }else { pages =save_zero_page (rs, block, offset, p);if (pages ==-1 ) { pages =compress_page_with_multi_thread (rs, block, offset); }else { -ram_release_pages (block->idstr, pss->offset, pages); +ram_release_pages (block->idstr, offset, pages); } } }@@ -1060,10 +1060,9 @@ static int ram_save_compressed_page(RAMState *rs, PageSearchStatus *pss,static bool find_dirty_block (RAMState *rs,PageSearchStatus *pss,bool *again,unsigned long *page) { - pss->offset =migration_bitmap_find_dirty (rs, pss->block, pss->offset, - page); + pss->page =migration_bitmap_find_dirty (rs, pss->block, pss->page, page);if (pss->complete_round && pss->block == rs->last_seen_block && - pss->offset >= rs->last_page) { + pss->page >= rs->last_page) {/* * We've been once around the RAM and haven't found anything. * Give up. @@ -1071,9 +1070,9 @@ static bool find_dirty_block(RAMState *rs, PageSearchStatus *pss, *again = false;return false; } -if (pss->offset >= pss->block->used_length) { +if ((pss->page <<TARGET_PAGE_BITS ) >= pss->block->used_length) {/* Didn't find anything in this RAM Block */ - pss->offset =0 ; + pss->page =0 ; pss->block =QLIST_NEXT_RCU (pss->block, next);if (!pss->block) {/* Hit the end of the list */ @@ -1196,7 +1195,7 @@ static bool get_queued_page(RAMState *rs, PageSearchStatus *pss,* it just requested. */ pss->block = block; - pss->offset = offset; + pss->page = offset >>TARGET_PAGE_BITS ; }return !!block;@@ -1351,7 +1350,8 @@ static int ram_save_host_page(RAMState *rs, PageSearchStatus *pss, unsigned long page) {int tmppages, pages =0 ; -size_t pagesize =qemu_ram_pagesize (pss->block); +size_t pagesize_bits = +qemu_ram_pagesize (pss->block) >>TARGET_PAGE_BITS ; do { tmppages = ram_save_target_page(rs, pss, last_stage, page);@@ -1360,12 +1360,12 @@ static int ram_save_host_page(RAMState *rs, PageSearchStatus *pss, } pages += tmppages; - pss->offset +=TARGET_PAGE_SIZE ; + pss->page++; page++; - }while (pss->offset & (pagesize -1 )); + }while (pss->page & (pagesize_bits -1 ));/* The offset we leave with is the last one we looked at */ - pss->offset -=TARGET_PAGE_SIZE ; + pss->page--;return pages; }@@ -1396,7 +1396,7 @@ static int ram_find_and_save_block(RAMState *rs, bool last_stage) } pss.block = rs->last_seen_block; - pss.offset = rs->last_page <<TARGET_PAGE_BITS ; + pss.page = rs->last_page; pss.complete_round = false;if (!pss.block) {@@ -1418,7 +1418,7 @@ static int ram_find_and_save_block(RAMState *rs, bool last_stage) }while (!pages && again); rs->last_seen_block = pss.block; - rs->last_page = pss.offset >>TARGET_PAGE_BITS ; + rs->last_page = pss.page;return pages; }Signature · 1 line
2.9.3
--
Dr. David Alan Gilbert / [email protected] / Manchester, UK
PATCH v2 48/51 ram: Use ramblock and page offset instead of absolute offset
In reply to Juan QuintelaThis removes the needto pass also the absolute offset.
--- migration/ram.c | 56 ++++++++++++++++++++++---------------------------- migration/trace-events | 2 +- 2 files changed, 26 insertions(+), 32 deletions(-)
migration/ram.c +25 -31
@@ -611,12 +611,10 @@ static int save_xbzrle_page(RAMState *rs, uint8_t **current_data,* @rs: current RAM state * @rb: RAMBlock where to search for dirty pages * @start: page where we start the search -* @page: pointer into where to store the dirty page */ static inline unsigned long migration_bitmap_find_dirty (RAMState *rs,RAMBlock *rb, -unsigned long start, -unsigned long *page) +unsigned long start) {unsigned long base = rb->offset >>TARGET_PAGE_BITS ;unsigned long nr = base + start;
@@ -633,17 +631,18 @@ unsigned long migration_bitmap_find_dirty(RAMState *rs, RAMBlock *rb, next =find_next_bit (bitmap, size, nr); } - *page = next;return next - base; }static inline bool migration_bitmap_clear_dirty (RAMState *rs, +RAMBlock *rb,unsigned long page) {bool ret;unsigned long *bitmap =atomic_rcu_read (&rs->ram_bitmap)->bmap; +unsigned long nr = (rb->offset >>TARGET_PAGE_BITS ) + page; - ret =test_and_clear_bit (page, bitmap); + ret =test_and_clear_bit (nr, bitmap);if (ret) { rs->migration_dirty_pages--;
@@ -1057,10 +1056,9 @@ static int ram_save_compressed_page(RAMState *rs, PageSearchStatus *pss,* @again: set to false if the search has scanned the whole of RAM * @page: pointer into where to store the dirty page */ -static bool find_dirty_block (RAMState *rs,PageSearchStatus *pss, -bool *again,unsigned long *page) +static bool find_dirty_block (RAMState *rs,PageSearchStatus *pss,bool *again) { - pss->page =migration_bitmap_find_dirty (rs, pss->block, pss->page, page); + pss->page =migration_bitmap_find_dirty (rs, pss->block, pss->page);if (pss->complete_round && pss->block == rs->last_seen_block && pss->page >= rs->last_page) {/*
@@ -1110,8 +1108,7 @@ static bool find_dirty_block(RAMState *rs, PageSearchStatus *pss,* @offset: used to return the offset within the RAMBlock * @page: pointer into where to store the dirty page */ -static RAMBlock *unqueue_page (RAMState *rs,ram_addr_t *offset, -unsigned long *page) +static RAMBlock *unqueue_page (RAMState *rs,ram_addr_t *offset) {RAMBlock *block =NULL ;
@@ -1121,7 +1118,6 @@ static RAMBlock *unqueue_page(RAMState *rs, ram_addr_t *offset,QSIMPLEQ_FIRST (&rs->src_page_requests); block = entry->rb; *offset = entry->offset; - *page = (entry->offset + entry->rb->offset) >>TARGET_PAGE_BITS ;if (entry->len >TARGET_PAGE_SIZE ) { entry->len -=TARGET_PAGE_SIZE ;
@@ -1148,15 +1144,14 @@ static RAMBlock *unqueue_page(RAMState *rs, ram_addr_t *offset,* @pss: data about the state of the current dirty page scan * @page: pointer into where to store the dirty page */ -static bool get_queued_page (RAMState *rs,PageSearchStatus *pss, -unsigned long *page) +static bool get_queued_page (RAMState *rs,PageSearchStatus *pss) {RAMBlock *block;ram_addr_t offset;bool dirty; do { - block = unqueue_page(rs, &offset, page); + block = unqueue_page(rs, &offset); /* * We're sending this page, and since it's postcopy nothing else * will dirty it, and we must make sure it doesn't get sent again
@@ -1165,16 +1160,18 @@ static bool get_queued_page(RAMState *rs, PageSearchStatus *pss,*/ if (block) {unsigned long *bitmap; +unsigned long page; + bitmap =atomic_rcu_read (&rs->ram_bitmap)->bmap; - dirty =test_bit (*page, bitmap); + page = (block->offset + offset) >>TARGET_PAGE_BITS ; + dirty =test_bit (page, bitmap);if (!dirty) {trace_get_queued_page_not_dirty (block->idstr, (uint64_t )offset, - *page, -test_bit (*page, + page, +test_bit (page,atomic_rcu_read (&rs->ram_bitmap)->unsentmap)); }else { -trace_get_queued_page (block->idstr, (uint64_t )offset, - *page); +trace_get_queued_page (block->idstr, (uint64_t )offset, page); } }
@@ -1300,16 +1297,17 @@ err:* @ms: current migration state * @pss: data about the page we want to send * @last_stage: if we are at the completion stage -* @page: page number of the dirty page */ static int ram_save_target_page (RAMState *rs,PageSearchStatus *pss, -bool last_stage,unsigned long page) +bool last_stage) {int res =0 ;/* Check the pages is dirty and if it is send it */ -if (migration_bitmap_clear_dirty (rs, page)) { +if (migration_bitmap_clear_dirty (rs, pss->block, pss->page)) {unsigned long *unsentmap; +unsigned long page = + (pss->block->offset >>TARGET_PAGE_BITS ) + pss->page;if (!rs->preffer_xbzrle &&migrate_use_compression ()) { res =ram_save_compressed_page (rs, pss, last_stage); }else {
@@ -1343,25 +1341,22 @@ static int ram_save_target_page(RAMState *rs, PageSearchStatus *pss,* @ms: current migration state * @pss: data about the page we want to send * @last_stage: if we are at the completion stage -* @page: Page number of the dirty page */ static int ram_save_host_page (RAMState *rs,PageSearchStatus *pss, -bool last_stage, -unsigned long page) +bool last_stage) {int tmppages, pages =0 ;size_t pagesize_bits =qemu_ram_pagesize (pss->block) >>TARGET_PAGE_BITS ;do { - tmppages =ram_save_target_page (rs, pss, last_stage, page); + tmppages =ram_save_target_page (rs, pss, last_stage);if (tmppages <0 ) {return tmppages; } pages += tmppages; pss->page++; - page++; }while (pss->page & (pagesize_bits -1 ));/* The offset we leave with is the last one we looked at */
@@ -1388,7 +1383,6 @@ static int ram_find_and_save_block(RAMState *rs, bool last_stage)PageSearchStatus pss;int pages =0 ;bool again, found; -unsigned long page;/* Page number of the dirty page */ /* No dirty page as there is zero RAM */ if (!ram_bytes_total ()) {
@@ -1405,15 +1399,15 @@ static int ram_find_and_save_block(RAMState *rs, bool last_stage)do { again = true; - found =get_queued_page (rs, &pss, &page); + found =get_queued_page (rs, &pss);if (!found) {/* priority queue empty, so just search for something dirty */ - found =find_dirty_block (rs, &pss, &again, &page); + found =find_dirty_block (rs, &pss, &again); }if (found) { - pages =ram_save_host_page (rs, &pss, last_stage, page); + pages =ram_save_host_page (rs, &pss, last_stage); } }while (!pages && again);
migration/trace-events +1 -1
@@ -63,7 +63,7 @@ put_qtailq_end(const char *name, const char *reason) "%s %s" qemu_file_fclose(void) "" # migration/ram.c -get_queued_page(const char *block_name, uint64_t tmp_offset, uint64_t ram_addr) "%s/%" PRIx64 " ram_addr=%" PRIx64 +get_queued_page(const char *block_name, uint64_t tmp_offset, unsigned long page) "%s/%" PRIx64 " page=%lu" get_queued_page_not_dirty(const char *block_name, uint64_t tmp_offset, uint64_t ram_addr, int sent) "%s/%" PRIx64 " ram_addr=%" PRIx64 " (sent=%d)" migration_bitmap_sync_start(void) "" migration_bitmap_sync_end(uint64_t dirty_pages) "dirty_pages %" PRIu64
Signature · 1 line
2.9.3
Re: [Qemu-devel] [PATCH 48/51] ram: Use ramblock and page offset instead of absolute offset
Quoted 1 line · * Juan Quintela ([email protected]) wrote:
This removes the needto pass also the absolute offset.
Quoted 210 lines
Signed-off-by Juan Quintela <[email protected]>--- migration/ram.c | 56 ++++++++++++++++++++++---------------------------- migration/trace-events | 2 +- 2 files changed, 26 insertions(+), 32 deletions(-)migration/ram.c +25
-31@@ -611,12 +611,10 @@ static int save_xbzrle_page(RAMState *rs, uint8_t **current_data,* @rs: current RAM state * @rb: RAMBlock where to search for dirty pages * @start: page where we start the search -* @page: pointer into where to store the dirty page */ static inline unsigned long migration_bitmap_find_dirty (RAMState *rs,RAMBlock *rb, -unsigned long start, -unsigned long *page) +unsigned long start) {unsigned long base = rb->offset >>TARGET_PAGE_BITS ;unsigned long nr = base + start;@@ -633,17 +631,18 @@ unsigned long migration_bitmap_find_dirty(RAMState *rs, RAMBlock *rb, next =find_next_bit (bitmap, size, nr); } - *page = next;return next - base; }static inline bool migration_bitmap_clear_dirty (RAMState *rs, +RAMBlock *rb,unsigned long page) {bool ret;unsigned long *bitmap =atomic_rcu_read (&rs->ram_bitmap)->bmap; +unsigned long nr = (rb->offset >>TARGET_PAGE_BITS ) + page; - ret =test_and_clear_bit (page, bitmap); + ret =test_and_clear_bit (nr, bitmap);if (ret) { rs->migration_dirty_pages--;@@ -1057,10 +1056,9 @@ static int ram_save_compressed_page(RAMState *rs, PageSearchStatus *pss,* @again: set to false if the search has scanned the whole of RAM * @page: pointer into where to store the dirty page */ -static bool find_dirty_block (RAMState *rs,PageSearchStatus *pss, -bool *again,unsigned long *page) +static bool find_dirty_block (RAMState *rs,PageSearchStatus *pss,bool *again) { - pss->page =migration_bitmap_find_dirty (rs, pss->block, pss->page, page); + pss->page =migration_bitmap_find_dirty (rs, pss->block, pss->page);if (pss->complete_round && pss->block == rs->last_seen_block && pss->page >= rs->last_page) {/* @@ -1110,8 +1108,7 @@ static bool find_dirty_block(RAMState *rs, PageSearchStatus *pss,* @offset: used to return the offset within the RAMBlock * @page: pointer into where to store the dirty page */ -static RAMBlock *unqueue_page (RAMState *rs,ram_addr_t *offset, -unsigned long *page) +static RAMBlock *unqueue_page (RAMState *rs,ram_addr_t *offset) {RAMBlock *block =NULL ;@@ -1121,7 +1118,6 @@ static RAMBlock *unqueue_page(RAMState *rs, ram_addr_t *offset,QSIMPLEQ_FIRST (&rs->src_page_requests); block = entry->rb; *offset = entry->offset; - *page = (entry->offset + entry->rb->offset) >>TARGET_PAGE_BITS ;if (entry->len >TARGET_PAGE_SIZE ) { entry->len -=TARGET_PAGE_SIZE ;@@ -1148,15 +1144,14 @@ static RAMBlock *unqueue_page(RAMState *rs, ram_addr_t *offset,* @pss: data about the state of the current dirty page scan * @page: pointer into where to store the dirty page */ -static bool get_queued_page (RAMState *rs,PageSearchStatus *pss, -unsigned long *page) +static bool get_queued_page (RAMState *rs,PageSearchStatus *pss) {RAMBlock *block;ram_addr_t offset;bool dirty; do { - block = unqueue_page(rs, &offset, page); + block = unqueue_page(rs, &offset); /* * We're sending this page, and since it's postcopy nothing else * will dirty it, and we must make sure it doesn't get sent again@@ -1165,16 +1160,18 @@ static bool get_queued_page(RAMState *rs, PageSearchStatus *pss,*/ if (block) {unsigned long *bitmap; +unsigned long page; + bitmap =atomic_rcu_read (&rs->ram_bitmap)->bmap; - dirty =test_bit (*page, bitmap); + page = (block->offset + offset) >>TARGET_PAGE_BITS ; + dirty =test_bit (page, bitmap);if (!dirty) {trace_get_queued_page_not_dirty (block->idstr, (uint64_t )offset, - *page, -test_bit (*page, + page, +test_bit (page,atomic_rcu_read (&rs->ram_bitmap)->unsentmap)); }else { -trace_get_queued_page (block->idstr, (uint64_t )offset, - *page); +trace_get_queued_page (block->idstr, (uint64_t )offset, page); } }@@ -1300,16 +1297,17 @@ err:* @ms: current migration state * @pss: data about the page we want to send * @last_stage: if we are at the completion stage -* @page: page number of the dirty page */ static int ram_save_target_page (RAMState *rs,PageSearchStatus *pss, -bool last_stage,unsigned long page) +bool last_stage) {int res =0 ;/* Check the pages is dirty and if it is send it */ -if (migration_bitmap_clear_dirty (rs, page)) { +if (migration_bitmap_clear_dirty (rs, pss->block, pss->page)) {unsigned long *unsentmap; +unsigned long page = + (pss->block->offset >>TARGET_PAGE_BITS ) + pss->page;if (!rs->preffer_xbzrle &&migrate_use_compression ()) { res =ram_save_compressed_page (rs, pss, last_stage); }else {@@ -1343,25 +1341,22 @@ static int ram_save_target_page(RAMState *rs, PageSearchStatus *pss,* @ms: current migration state * @pss: data about the page we want to send * @last_stage: if we are at the completion stage -* @page: Page number of the dirty page */ static int ram_save_host_page (RAMState *rs,PageSearchStatus *pss, -bool last_stage, -unsigned long page) +bool last_stage) {int tmppages, pages =0 ;size_t pagesize_bits =qemu_ram_pagesize (pss->block) >>TARGET_PAGE_BITS ;do { - tmppages =ram_save_target_page (rs, pss, last_stage, page); + tmppages =ram_save_target_page (rs, pss, last_stage);if (tmppages <0 ) {return tmppages; } pages += tmppages; pss->page++; - page++; }while (pss->page & (pagesize_bits -1 ));/* The offset we leave with is the last one we looked at */ @@ -1388,7 +1383,6 @@ static int ram_find_and_save_block(RAMState *rs, bool last_stage)PageSearchStatus pss;int pages =0 ;bool again, found; -unsigned long page;/* Page number of the dirty page */ /* No dirty page as there is zero RAM */ if (!ram_bytes_total ()) {@@ -1405,15 +1399,15 @@ static int ram_find_and_save_block(RAMState *rs, bool last_stage)do { again = true; - found =get_queued_page (rs, &pss, &page); + found =get_queued_page (rs, &pss);if (!found) {/* priority queue empty, so just search for something dirty */ - found =find_dirty_block (rs, &pss, &again, &page); + found =find_dirty_block (rs, &pss, &again); }if (found) { - pages =ram_save_host_page (rs, &pss, last_stage, page); + pages =ram_save_host_page (rs, &pss, last_stage); } }while (!pages && again);migration/trace-events +1
-1@@ -63,7 +63,7 @@ put_qtailq_end(const char *name, const char *reason) "%s %s" qemu_file_fclose(void) "" # migration/ram.c -get_queued_page(const char *block_name, uint64_t tmp_offset, uint64_t ram_addr) "%s/%" PRIx64 " ram_addr=%" PRIx64 +get_queued_page(const char *block_name, uint64_t tmp_offset, unsigned long page) "%s/%" PRIx64 " page=%lu" get_queued_page_not_dirty(const char *block_name, uint64_t tmp_offset, uint64_t ram_addr, int sent) "%s/%" PRIx64 " ram_addr=%" PRIx64 " (sent=%d)" migration_bitmap_sync_start(void) "" migration_bitmap_sync_end(uint64_t dirty_pages) "dirty_pages %" PRIu64Signature · 1 line
2.9.3
--
Dr. David Alan Gilbert / [email protected] / Manchester, UK
PATCH v2 49/51 ram: rename last_ram_offset() last_ram_pages()
In reply to Juan QuintelaWe always use it as pages anyways.
--- exec.c | 6 +++--- include/exec/ram_addr.h | 2 +- migration/ram.c | 11 +++++------ 3 files changed, 9 insertions(+), 10 deletions(-)
exec.c +3 -3
@@ -1528,7 +1528,7 @@ static ram_addr_t find_ram_offset(ram_addr_t size)return offset; } -ram_addr_t last_ram_offset (void ) +unsigned long last_ram_page (void ) {RAMBlock *block;ram_addr_t last =0 ;
@@ -1538,7 +1538,7 @@ ram_addr_t last_ram_offset(void) last =MAX (last, block->offset + block->max_length); }rcu_read_unlock (); -return last; +return last >>TARGET_PAGE_BITS ; }static void qemu_ram_setup_dump (void *addr,ram_addr_t size)
@@ -1727,7 +1727,7 @@ static void ram_block_add(RAMBlock *new_block, Error **errp)ram_addr_t old_ram_size, new_ram_size;Error *err =NULL ; - old_ram_size =last_ram_offset () >>TARGET_PAGE_BITS ; + old_ram_size =last_ram_page ();qemu_mutex_lock_ramlist (); new_block->offset =find_ram_offset (new_block->max_length);
include/exec/ram_addr.h +1 -1
@@ -53,7 +53,7 @@ static inline void *ramblock_ptr(RAMBlock *block, ram_addr_t offset) }long qemu_getrampagesize (void ); -ram_addr_t last_ram_offset (void ); +unsigned long last_ram_page (void );RAMBlock *qemu_ram_alloc_from_file (ram_addr_t size,MemoryRegion *mr,bool share,const char *mem_path,Error **errp);
migration/ram.c +5 -6
@@ -1535,7 +1535,7 @@ void migration_bitmap_extend(ram_addr_t old, ram_addr_t new)*/ void ram_debug_dump_bitmap (unsigned long *todump,bool expected) { -int64_t ram_pages =last_ram_offset () >>TARGET_PAGE_BITS ; +unsigned long ram_pages =last_ram_page ();RAMState *rs = &ram_state;int64_t cur;int64_t linelen =128 ;
@@ -1902,8 +1902,7 @@ int ram_postcopy_send_discard_bitmap(MigrationState *ms)* Update the unsentmap to be unsentmap = unsentmap | dirty */ bitmap =atomic_rcu_read (&rs->ram_bitmap)->bmap; -bitmap_or (unsentmap, unsentmap, bitmap, -last_ram_offset () >>TARGET_PAGE_BITS ); +bitmap_or (unsentmap, unsentmap, bitmap,last_ram_page ());trace_ram_postcopy_send_discard_bitmap ();
@@ -1951,7 +1950,7 @@ err:static int ram_state_init (RAMState *rs) { -int64_t ram_bitmap_pages;/* Size of bitmap in pages, including gaps */ +unsigned long ram_bitmap_pages;memset (rs,0 ,sizeof (*rs));qemu_mutex_init (&rs->bitmap_mutex);
@@ -1997,7 +1996,7 @@ static int ram_state_init(RAMState *rs) rs->ram_bitmap = g_new0(struct RAMBitmap, 1);/* Skip setting bitmap if there is no RAM */ if (ram_bytes_total ()) { - ram_bitmap_pages =last_ram_offset () >>TARGET_PAGE_BITS ; + ram_bitmap_pages =last_ram_page (); rs->ram_bitmap->bmap =bitmap_new (ram_bitmap_pages);bitmap_set (rs->ram_bitmap->bmap,0 , ram_bitmap_pages);
@@ -2458,7 +2457,7 @@ static void decompress_data_with_multi_threads(QEMUFile *f,*/ int ram_postcopy_incoming_init (MigrationIncomingState *mis) { -size_t ram_pages =last_ram_offset () >>TARGET_PAGE_BITS ; +unsigned long ram_pages =last_ram_page ();return postcopy_ram_incoming_init (mis, ram_pages); }
Signature · 1 line
2.9.3
Re: [Qemu-devel] [PATCH 49/51] ram: rename last_ram_offset() last_ram_pages()
Quoted 3 lines · * Juan Quintela ([email protected]) wrote:
We always use it as pages anyways.
Signed-off-by Juan Quintela <[email protected]>
Quoted 103 lines
--- exec.c | 6 +++--- include/exec/ram_addr.h | 2 +- migration/ram.c | 11 +++++------ 3 files changed, 9 insertions(+), 10 deletions(-)exec.c +3
-3@@ -1528,7 +1528,7 @@ static ram_addr_t find_ram_offset(ram_addr_t size)return offset; } -ram_addr_t last_ram_offset (void ) +unsigned long last_ram_page (void ) {RAMBlock *block;ram_addr_t last =0 ;@@ -1538,7 +1538,7 @@ ram_addr_t last_ram_offset(void) last =MAX (last, block->offset + block->max_length); }rcu_read_unlock (); -return last; +return last >>TARGET_PAGE_BITS ; }static void qemu_ram_setup_dump (void *addr,ram_addr_t size)@@ -1727,7 +1727,7 @@ static void ram_block_add(RAMBlock *new_block, Error **errp)ram_addr_t old_ram_size, new_ram_size;Error *err =NULL ; - old_ram_size =last_ram_offset () >>TARGET_PAGE_BITS ; + old_ram_size =last_ram_page ();qemu_mutex_lock_ramlist (); new_block->offset =find_ram_offset (new_block->max_length);include/exec/ram_addr.h +1
-1@@ -53,7 +53,7 @@ static inline void *ramblock_ptr(RAMBlock *block, ram_addr_t offset) }long qemu_getrampagesize (void ); -ram_addr_t last_ram_offset (void ); +unsigned long last_ram_page (void );RAMBlock *qemu_ram_alloc_from_file (ram_addr_t size,MemoryRegion *mr,bool share,const char *mem_path,Error **errp);migration/ram.c +5
-6@@ -1535,7 +1535,7 @@ void migration_bitmap_extend(ram_addr_t old, ram_addr_t new)*/ void ram_debug_dump_bitmap (unsigned long *todump,bool expected) { -int64_t ram_pages =last_ram_offset () >>TARGET_PAGE_BITS ; +unsigned long ram_pages =last_ram_page ();RAMState *rs = &ram_state;int64_t cur;int64_t linelen =128 ;@@ -1902,8 +1902,7 @@ int ram_postcopy_send_discard_bitmap(MigrationState *ms)* Update the unsentmap to be unsentmap = unsentmap | dirty */ bitmap =atomic_rcu_read (&rs->ram_bitmap)->bmap; -bitmap_or (unsentmap, unsentmap, bitmap, -last_ram_offset () >>TARGET_PAGE_BITS ); +bitmap_or (unsentmap, unsentmap, bitmap,last_ram_page ());trace_ram_postcopy_send_discard_bitmap ();@@ -1951,7 +1950,7 @@ err:static int ram_state_init (RAMState *rs) { -int64_t ram_bitmap_pages;/* Size of bitmap in pages, including gaps */ +unsigned long ram_bitmap_pages;memset (rs,0 ,sizeof (*rs));qemu_mutex_init (&rs->bitmap_mutex);@@ -1997,7 +1996,7 @@ static int ram_state_init(RAMState *rs) rs->ram_bitmap = g_new0(struct RAMBitmap, 1);/* Skip setting bitmap if there is no RAM */ if (ram_bytes_total ()) { - ram_bitmap_pages =last_ram_offset () >>TARGET_PAGE_BITS ; + ram_bitmap_pages =last_ram_page (); rs->ram_bitmap->bmap =bitmap_new (ram_bitmap_pages);bitmap_set (rs->ram_bitmap->bmap,0 , ram_bitmap_pages);@@ -2458,7 +2457,7 @@ static void decompress_data_with_multi_threads(QEMUFile *f,*/ int ram_postcopy_incoming_init (MigrationIncomingState *mis) { -size_t ram_pages =last_ram_offset () >>TARGET_PAGE_BITS ; +unsigned long ram_pages =last_ram_page ();return postcopy_ram_incoming_init (mis, ram_pages); }Signature · 1 line
2.9.3
--
Dr. David Alan Gilbert / [email protected] / Manchester, UK
PATCH v2 50/51 ram: Use RAMBitmap type for coherence
In reply to Juan Quintela--- migration/ram.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-)
migration/ram.c +5 -5
@@ -1449,7 +1449,7 @@ void free_xbzrle_decoded_buf(void) xbzrle_decoded_buf =NULL ; } -static void migration_bitmap_free (struct RAMBitmap *bmap) +static void migration_bitmap_free (RAMBitmap *bmap) {g_free (bmap->bmap);g_free (bmap->unsentmap);
@@ -1463,7 +1463,7 @@ static void ram_migration_cleanup(void *opaque)/* caller have hold iothread lock or is in a bh, so there is * no writing race against this migration_bitmap */ -struct RAMBitmap *bitmap = rs->ram_bitmap; +RAMBitmap *bitmap = rs->ram_bitmap;atomic_rcu_set (&rs->ram_bitmap,NULL );if (bitmap) {memory_global_dirty_log_stop ();
@@ -1502,8 +1502,8 @@ void migration_bitmap_extend(ram_addr_t old, ram_addr_t new)* no writing race against this migration_bitmap */ if (rs->ram_bitmap) { -struct RAMBitmap *old_bitmap = rs->ram_bitmap, *bitmap; - bitmap = g_new(struct RAMBitmap, 1); +RAMBitmap *old_bitmap = rs->ram_bitmap, *bitmap; + bitmap =g_new (RAMBitmap,1 ); bitmap->bmap =bitmap_new (new);/* prevent migration_bitmap content from being set bit
@@ -1993,7 +1993,7 @@ static int ram_state_init(RAMState *rs)rcu_read_lock ();ram_state_reset (rs); - rs->ram_bitmap = g_new0(struct RAMBitmap, 1); + rs->ram_bitmap =g_new0 (RAMBitmap,1 );/* Skip setting bitmap if there is no RAM */ if (ram_bytes_total ()) { ram_bitmap_pages =last_ram_page ();
Signature · 1 line
2.9.3
Re: [Qemu-devel] [PATCH 50/51] ram: Use RAMBitmap type for coherence
Quoted 1 line · * Juan Quintela ([email protected]) wrote:
Signed-off-by Juan Quintela <[email protected]>
Quoted 49 lines
--- migration/ram.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-)migration/ram.c +5
-5@@ -1449,7 +1449,7 @@ void free_xbzrle_decoded_buf(void) xbzrle_decoded_buf =NULL ; } -static void migration_bitmap_free (struct RAMBitmap *bmap) +static void migration_bitmap_free (RAMBitmap *bmap) {g_free (bmap->bmap);g_free (bmap->unsentmap);@@ -1463,7 +1463,7 @@ static void ram_migration_cleanup(void *opaque)/* caller have hold iothread lock or is in a bh, so there is * no writing race against this migration_bitmap */ -struct RAMBitmap *bitmap = rs->ram_bitmap; +RAMBitmap *bitmap = rs->ram_bitmap;atomic_rcu_set (&rs->ram_bitmap,NULL );if (bitmap) {memory_global_dirty_log_stop ();@@ -1502,8 +1502,8 @@ void migration_bitmap_extend(ram_addr_t old, ram_addr_t new)* no writing race against this migration_bitmap */ if (rs->ram_bitmap) { -struct RAMBitmap *old_bitmap = rs->ram_bitmap, *bitmap; - bitmap = g_new(struct RAMBitmap, 1); +RAMBitmap *old_bitmap = rs->ram_bitmap, *bitmap; + bitmap =g_new (RAMBitmap,1 ); bitmap->bmap =bitmap_new (new);/* prevent migration_bitmap content from being set bit @@ -1993,7 +1993,7 @@ static int ram_state_init(RAMState *rs)rcu_read_lock ();ram_state_reset (rs); - rs->ram_bitmap = g_new0(struct RAMBitmap, 1); + rs->ram_bitmap =g_new0 (RAMBitmap,1 );/* Skip setting bitmap if there is no RAM */ if (ram_bytes_total ()) { ram_bitmap_pages =last_ram_page ();Signature · 1 line
2.9.3
--
Dr. David Alan Gilbert / [email protected] / Manchester, UK
PATCH v2 51/51 migration: Remove MigrationState parameter from migration_is_idle()
In reply to Juan QuintelaOnly user don't have a MigrationState handly.
--- include/migration/migration.h | 2 +- migration/migration.c | 8 +++----- 2 files changed, 4 insertions(+), 6 deletions(-)
include/migration/migration.h +1 -1
@@ -234,7 +234,7 @@ void remove_migration_state_change_notifier(Notifier *notify);MigrationState *migrate_init (const MigrationParams *params);bool migration_is_blocked (Error **errp);bool migration_in_setup (MigrationState *); -bool migration_is_idle (MigrationState *s); +bool migration_is_idle (void );bool migration_has_finished (MigrationState *);bool migration_has_failed (MigrationState *);/* True if outgoing migration has entered postcopy phase */
migration/migration.c +3 -5
@@ -1067,11 +1067,9 @@ bool migration_in_postcopy_after_devices(MigrationState *s)return migration_in_postcopy () && s->postcopy_after_devices; } -bool migration_is_idle (MigrationState *s) +bool migration_is_idle (void ) { -if (!s) { - s =migrate_get_current (); - } +MigrationState *s =migrate_get_current ();switch (s->state) {case MIGRATION_STATUS_NONE :
@@ -1136,7 +1134,7 @@ int migrate_add_blocker(Error *reason, Error **errp)return -EACCES ; } -if (migration_is_idle (NULL )) { +if (migration_is_idle ()) { migration_blockers =g_slist_prepend (migration_blockers, reason);return 0 ; }
Signature · 1 line
2.9.3
Re: [Qemu-devel] [PATCH 51/51] migration: Remove MigrationState parameter from migration_is_idle()
Quoted 3 lines · * Juan Quintela ([email protected]) wrote:
Only user don't have a MigrationState handly.
Signed-off-by Juan Quintela <[email protected]>
Quoted 48 lines
--- include/migration/migration.h | 2 +- migration/migration.c | 8 +++----- 2 files changed, 4 insertions(+), 6 deletions(-)include/migration/migration.h +1
-1@@ -234,7 +234,7 @@ void remove_migration_state_change_notifier(Notifier *notify);MigrationState *migrate_init (const MigrationParams *params);bool migration_is_blocked (Error **errp);bool migration_in_setup (MigrationState *); -bool migration_is_idle (MigrationState *s); +bool migration_is_idle (void );bool migration_has_finished (MigrationState *);bool migration_has_failed (MigrationState *);/* True if outgoing migration has entered postcopy phase */ migration/migration.c +3
-5@@ -1067,11 +1067,9 @@ bool migration_in_postcopy_after_devices(MigrationState *s)return migration_in_postcopy () && s->postcopy_after_devices; } -bool migration_is_idle (MigrationState *s) +bool migration_is_idle (void ) { -if (!s) { - s =migrate_get_current (); - } +MigrationState *s =migrate_get_current ();switch (s->state) {case MIGRATION_STATUS_NONE :@@ -1136,7 +1134,7 @@ int migrate_add_blocker(Error *reason, Error **errp)return -EACCES ; } -if (migration_is_idle (NULL )) { +if (migration_is_idle ()) { migration_blockers =g_slist_prepend (migration_blockers, reason);return 0 ; }Signature · 1 line
2.9.3
--
Dr. David Alan Gilbert / [email protected] / Manchester, UK
Quoted 1 line · * Juan Quintela ([email protected]) wrote:
Hi
Some high level points:
Quoted 11 lines
Continuation of previous series, all review comments addressed. New things:
- Consolidate all function comments in the same style (yes, docs)
- Be much more careful with maintaining comments correct
- Move all postcopy fields to RAMState- Move QEMUFile to RAMState
- renameqemu_target_page_bits()toqemu_target_page_size()to reflect use
- Remove MigrationState from functions that don't need it
- reorganizelast_sent_blockto the place where it is used/needed
- Move several places from offsets to pages
- Renamelast_ram_offset()tolast_ram_page()to refect use
An interesting question is what happens if we ever have multiple threads working on RAM at once, I assume you're thinking there will be multiple RAMStates? It'll be interesting to see whether everything we have now got in RAMState is stuff that wants to be replicated that way.
Dave
Quoted 99 lines
Please comment.
[v1]
Currently, we have several places where we store informaticon about ram for migration pruposes:
- global variables onmigration/ram.c
- inside theaccounting_infostruct inmigration/ram.cnotice that not all the accounting vars are inside there
- some stuff is in MigrationState, althought it belongs tomigrate/ram.cSo, this series does:
- move everything related toram.cto RAMState struct
- make all the statistics consistent, exporting them with an accessor functionWhy now?
Because I am trying to do some more optimizations about how we send data around and it is basically impossible to do with current code, we still need to add more variables. Notice that there are things like that:
- accounting info was only reset if we had xbzrle enabled
- How/where to initialize variables are completely inconsistent.To Do:
- There are still places that access directly the global struct. Mainly postcopy. We could finfd a way to make a pointer to the current migration. If people like the approach, I will search where to put it.
- I haven't posted any real change here, this is just the move of variables to the struct and pass the struct around. Optimizations will came after.- Consolidate XBZRLE, Compression params, etc in its own structs (inside or not RAMState, to be able to allocate ones, others, or ...)
Comments, please.
Chao Fan (1):
Add page-size to output in 'info migrate'Juan Quintela (50):
ram: Update all functions comments
ram: renameblock_nameto rbname
ram: Create RAMState
ram: Adddirty_rate_high_cntto RAMState
ram: Movebitmap_sync_countinto RAMState
ram: Move start time into RAMState
ram: Movebytes_xfer_previnto RAMState
ram: Movenum_dirty_pages_periodinto RAMState
ram: Movexbzrle_cache_miss_previnto RAMState
ram: Moveiterations_previnto RAMState
ram: Movedup_pagesinto RAMState
ram: Remove unuseddup_mig_bytes_transferred()
ram: Remove unusedpages_skippedvariable
ram: Movenorm_pagesto RAMState
ram: Removenorm_mig_bytes_transferred
ram: Move iterations into RAMState
ram: Movexbzrle_bytesinto RAMState
ram: Movexbzrle_pagesinto RAMState
ram: Movexbzrle_cache_missinto RAMState
ram: Movexbzrle_cache_miss_rateinto RAMState
ram: Movexbzrle_overflowsinto RAMState
ram: Movemigration_dirty_pagesto RAMState
ram: Everything was init to zero, so use memset
ram: Movemigration_bitmap_mutexinto RAMState
ram: Movemigration_bitmap_rcuinto RAMState
ram: Movebytes_transferredinto RAMState
ram: Use the RAMStatebytes_transferredparameter
ram: Removeram_save_remaining
ram: Movelast_req_rbto RAMState
ram: Move src_page_req* to RAMState
ram: Createram_dirty_sync_count()
ram: Removedirty_bytes_rate
ram: Movedirty_pages_rateto RAMState
ram: Movepostcopy_requestsinto RAMState
ram: Add QEMUFile to RAMState
ram: Move QEMUFile into RAMState
ram: Movecompression_switchto RAMState
migration: Remove MigrationState frommigration_in_postcopy
ram: We don't need MigrationState parameter anymore
ram: Renameqemu_target_page_bits()toqemu_target_page_size()
ram: Pass RAMBlock tobitmap_sync
ram:ram_discard_range()don't use the mis parameter
ram: reorganizelast_sent_block
ram: Use page number instead of an address for the bitmap operations
ram: Rememberlast_pageinstead oflast_offset
ram: Change offset field in PageSearchStatus to page
ram: Use ramblock and page offset instead of absolute offset
ram: renamelast_ram_offset()last_ram_pages()
ram: Use RAMBitmap type for coherence
migration: Remove MigrationState parameter frommigration_is_idle()
Quoted 16 lines
exec.c | 10 +- hmp.c | 3 + include/exec/ram_addr.h | 4 +- include/migration/migration.h | 41 +- include/sysemu/sysemu.h | 2 +- migration/migration.c | 44 +- migration/postcopy-ram.c | 14 +- migration/ram.c | 1190 ++++++++++++++++++++++------------------- migration/savevm.c | 15 +- migration/trace-events | 2 +- qapi-schema.json | 5 +- 11 files changed, 695 insertions(+), 635 deletions(-)Signature · 1 line
2.9.3
--
Dr. David Alan Gilbert / [email protected] / Manchester, UK
Quoted 17 lines · Dr. David Alan Gilbert
Quoted 1 line · * Juan Quintela ([email protected]) wrote:
Hi
Some high level points:
Quoted 11 lines
Continuation of previous series, all review comments addressed. New things:
- Consolidate all function comments in the same style (yes, docs)
- Be much more careful with maintaining comments correct
- Move all postcopy fields to RAMState- Move QEMUFile to RAMState
- renameqemu_target_page_bits()toqemu_target_page_size()to reflect use
- Remove MigrationState from functions that don't need it
- reorganizelast_sent_blockto the place where it is used/needed
- Move several places from offsets to pages
- Renamelast_ram_offset()tolast_ram_page()to refect use
Quoted 4 lines
An interesting question is what happens if we ever have multiple threads working on RAM at once, I assume you're thinking there will be multiple RAMStates? It'll be interesting to see whether everything we have now got in RAMState is stuff that wants to be replicated that way.
Working on paolo suggestion on sending everyhting through multiplefd's. That requires multiple FD's.
Thanks, Juan.
Quoted 18 lines · * Juan Quintela ([email protected]) wrote:
Quoted 17 lines · Dr. David Alan Gilbert
Quoted 1 line · * Juan Quintela ([email protected]) wrote:
Hi
Some high level points:
Quoted 11 lines
Continuation of previous series, all review comments addressed. New things:
- Consolidate all function comments in the same style (yes, docs)
- Be much more careful with maintaining comments correct
- Move all postcopy fields to RAMState- Move QEMUFile to RAMState
- renameqemu_target_page_bits()toqemu_target_page_size()to reflect use
- Remove MigrationState from functions that don't need it
- reorganizelast_sent_blockto the place where it is used/needed
- Move several places from offsets to pages
- Renamelast_ram_offset()tolast_ram_page()to refect use
Quoted 7 lines
Quoted 4 lines
An interesting question is what happens if we ever have multiple threads working on RAM at once, I assume you're thinking there will be multiple RAMStates? It'll be interesting to see whether everything we have now got in RAMState is stuff that wants to be replicated that way.
Working on paolo suggestion on sending everyhting through multiplefd's. That requires multiple FD's.
Yes, but for example do we want multiple postcopy request queues? Do we have one reverse stream for requests or multiple?
Dave
Quoted 1 line
Thanks, Juan.
--
Dr. David Alan Gilbert / [email protected] / Manchester, UK