Hailiang Zhang <zhang.zhanghaili...@huawei.com> wrote: > On 2017/4/25 18:11, Juan Quintela wrote: >> Both the ram bitmap and the unsent bitmap are split by RAMBlock. >> >> Signed-off-by: Juan Quintela <quint...@redhat.com> >> --- >> include/exec/ram_addr.h | 13 +- >> include/migration/postcopy-ram.h | 3 - >> migration/postcopy-ram.c | 5 +- >> migration/ram.c | 257 >> +++++++++++++++------------------------ >> 4 files changed, 109 insertions(+), 169 deletions(-) >>
>> + >> + QLIST_FOREACH_RCU(block, &ram_list.blocks, next) { > ... ... >> + unsigned long pages = block->used_length >> TARGET_PAGE_BITS; >> + unsigned long *bitmap = block->bmap; >> + unsigned long *unsentmap = block->unsentmap; >> + >> + if (!unsentmap) { >> + /* We don't have a safe way to resize the sentmap, so >> + * if the bitmap was resized it will be NULL at this >> + * point. >> + */ >> + error_report("migration ram resized during precopy phase"); >> + rcu_read_unlock(); >> + return -EINVAL; >> + } >> + /* Deal with TPS != HPS and huge pages */ >> + ret = postcopy_chunk_hostpages(ms, block); >> + if (ret) { >> + rcu_read_unlock(); >> + return ret; >> + } >> + >> + /* >> + * Update the unsentmap to be unsentmap = unsentmap | dirty >> */ >> - error_report("migration ram resized during precopy phase"); >> - rcu_read_unlock(); >> - return -EINVAL; >> + bitmap_or(unsentmap, unsentmap, bitmap, pages); >> } >> - >> - /* Deal with TPS != HPS and huge pages */ >> - ret = postcopy_chunk_hostpages(ms); >> - if (ret) { >> - rcu_read_unlock(); >> - return ret; >> - } >> - >> - /* >> - * Update the unsentmap to be unsentmap = unsentmap | dirty >> - */ >> - bitmap = atomic_rcu_read(&rs->ram_bitmap)->bmap; >> - bitmap_or(unsentmap, unsentmap, bitmap, last_ram_page()); >> - >> - >> trace_ram_postcopy_send_discard_bitmap(); >> #ifdef DEBUG_POSTCOPY >> ram_debug_dump_bitmap(unsentmap, true); > ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ > It seems that, you forgot to put the above codes in the loop: > > QLIST_FOREACH_RCU(block, &ram_list.blocks, next) > > If DEBUG_POSTCOPY is defined, compiling will fail ... Fixed, thanks. Now I put that code inside the FOREACH with the "pages" parameter. Later, Juan.