Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Origin/max iter #45

Closed
wants to merge 4 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions hmp.c
Original file line number Diff line number Diff line change
Expand Up @@ -195,6 +195,8 @@ void hmp_info_migrate(Monitor *mon, const QDict *qdict)
}

if (info->has_ram) {
monitor_printf(mon, "iterations: %" PRIu64 "\n", info->ram->iters);

monitor_printf(mon, "transferred ram: %" PRIu64 " kbytes\n",
info->ram->transferred >> 10);
monitor_printf(mon, "throughput: %0.2f mbps\n",
Expand Down
1 change: 1 addition & 0 deletions include/migration/migration.h
Original file line number Diff line number Diff line change
Expand Up @@ -253,6 +253,7 @@ void free_xbzrle_decoded_buf(void);

void acct_update_position(QEMUFile *f, size_t size, bool zero);

uint64_t get_ram_iters(void) ;
uint64_t dup_mig_bytes_transferred(void);
uint64_t dup_mig_pages_transferred(void);
uint64_t skipped_mig_bytes_transferred(void);
Expand Down
26 changes: 22 additions & 4 deletions migration/migration.c
Original file line number Diff line number Diff line change
Expand Up @@ -602,10 +602,14 @@ static void get_xbzrle_cache_stats(MigrationInfo *info)
}
}

/* XXX QEMU monitor info */
static void populate_ram_info(MigrationInfo *info, MigrationState *s)
{
info->has_ram = true;
info->ram = g_malloc0(sizeof(*info->ram));

info->ram->iters = get_ram_iters() ; //XXX get number of iterations somehow

info->ram->transferred = ram_bytes_transferred();
info->ram->total = ram_bytes_total();
info->ram->duplicate = dup_mig_pages_transferred();
Expand All @@ -615,7 +619,8 @@ static void populate_ram_info(MigrationInfo *info, MigrationState *s)
info->ram->mbps = s->mbps;
info->ram->dirty_sync_count = s->dirty_sync_count;
info->ram->postcopy_requests = s->postcopy_requests;



if (s->state != MIGRATION_STATUS_COMPLETED) {
info->ram->remaining = ram_bytes_remaining();
info->ram->dirty_pages_rate = s->dirty_pages_rate;
Expand Down Expand Up @@ -1756,14 +1761,26 @@ static void *migration_thread(void *opaque)
pending_size = pend_nonpost + pend_post;
trace_migrate_pending(pending_size, max_size,
pend_post, pend_nonpost);
if (pending_size && pending_size >= max_size) {
/** Ideally, iteration check here
* But the ram_find_and_save_block is called through
* 3 levels of functions . */
/* Can either make the iterations a global variable
Or.... */
//XXX
/* if (get_ram_iters() > 30) { */
/* break ; */
/* } */
if ((pending_size && pending_size >= max_size) && get_ram_iters()<30) {
/* Still a significant amount to transfer */

if (migrate_postcopy_ram() &&
s->state != MIGRATION_STATUS_POSTCOPY_ACTIVE &&
pend_nonpost <= max_size &&
atomic_read(&s->start_postcopy)) {

//Postcopy start is stop-and-copy
//Who sets the start_postcopy flag? Only through user-action

if (!postcopy_start(s, &old_vm_running)) {
current_active_state = MIGRATION_STATUS_POSTCOPY_ACTIVE;
entered_postcopy = true;
Expand All @@ -1773,13 +1790,14 @@ static void *migration_thread(void *opaque)
}
/* Just another iteration step */
qemu_savevm_state_iterate(s->to_dst_file, entered_postcopy);
/* XXX */
} else {
trace_migration_thread_low_pending(pending_size);
migration_completion(s, current_active_state,
&old_vm_running, &start_time);
break;
}
}
} //endif file rate limit

if (qemu_file_get_error(s->to_dst_file)) {
migrate_set_state(&s->state, current_active_state,
Expand Down Expand Up @@ -1814,7 +1832,7 @@ static void *migration_thread(void *opaque)
/* usleep expects microseconds */
g_usleep((initial_time + BUFFER_DELAY - current_time)*1000);
}
}
} //end while loop

trace_migration_thread_after_loop();
/* If we enabled cpu throttling for auto-converge, turn it off. */
Expand Down
28 changes: 28 additions & 0 deletions migration/notes.org
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@

savevm.c:
int =qemu_savevm_state_iterate(QEMUFile *f)=

for each qemu state handler. ca;; =save_live_iterate=

ram.c

=ram_save_iterate= , =ram_save_complete=

=ram_find_and_save_block= (do save_host_page while pages)
-> =ram_save_host_page= saves one host_page , same block
-> =ram_save_target_page=
-> =ram_save_page(File/stream, pagesearchstautus, last_stage)=
-> Saves actual page to file

last_sent_block is global


=ram_save_iterate= callback registered as savevm =save_live_iterate=

iterations incre



hmp_info_migrate , add monitor_printf(migration)

migration.c =populate_ram_info=
32 changes: 26 additions & 6 deletions migration/ram.c
Original file line number Diff line number Diff line change
Expand Up @@ -218,6 +218,13 @@ uint64_t xbzrle_mig_pages_overflow(void)
return acct_info.xbzrle_overflows;
}


uint64_t get_ram_iters(void)
{
return acct_info.iterations ;
}


/* This is the last block that we have visited serching for dirty pages
*/
static RAMBlock *last_seen_block;
Expand Down Expand Up @@ -742,29 +749,34 @@ static int ram_save_page(QEMUFile *f, PageSearchStatus *pss,

/* In doubt sent page as normal */
bytes_xmit = 0;
/* This just copies the page to f? */
ret = ram_control_save_page(f, block->offset,
offset, TARGET_PAGE_SIZE, &bytes_xmit);
if (bytes_xmit) {
*bytes_transferred += bytes_xmit;
pages = 1;
pages = 1; //1 == success
}

XBZRLE_cache_lock();

current_addr = block->offset + offset;

if (block == last_sent_block) {
offset |= RAM_SAVE_FLAG_CONTINUE;
/* XXX Continue sending in same block */
offset |= RAM_SAVE_FLAG_CONTINUE; /* 0x20 */
/* WHy do this? Are blocks of size 0x20? */
}
if (ret != RAM_SAVE_CONTROL_NOT_SUPP) {
if (ret != RAM_SAVE_CONTROL_DELAYED) {
/* 1 success page copied , non-delayed */
if (bytes_xmit > 0) {
acct_info.norm_pages++;
} else if (bytes_xmit == 0) {
acct_info.dup_pages++;
}
}
} else {
/* Just save page header, no content? */
pages = save_zero_page(f, block, offset, p, bytes_transferred);
if (pages > 0) {
/* Must let xbzrle know, otherwise a previous (now 0'd) cached
Expand All @@ -781,14 +793,20 @@ static int ram_save_page(QEMUFile *f, PageSearchStatus *pss,
send_async = false;
}
}
}
} /* End else block */

/* XBZRLE overflow or normal page */
if (pages == -1) {
if (pages == -1) { /*pages =1 if bytes xmitted */
/* Write page offset */
/* offset may've been 0x20'ed */
*bytes_transferred += save_page_header(f, block,
offset | RAM_SAVE_FLAG_PAGE);
if (send_async) {
/* p = block->host+offset---the physical address offset,
we write offset first above, and then the actual phy addr? */
qemu_put_buffer_async(f, p, TARGET_PAGE_SIZE);
/* f, buf, size. Size is ? */
/* Maybe this just writes 0s? */
} else {
qemu_put_buffer(f, p, TARGET_PAGE_SIZE);
}
Expand Down Expand Up @@ -1332,7 +1350,7 @@ static int ram_find_and_save_block(QEMUFile *f, bool last_stage,

pss.block = last_seen_block;
pss.offset = last_offset;
pss.complete_round = false;
pss.complete_round = false; //XXX flagged true by found_dirty_block to signify looped

if (!pss.block) {
pss.block = QLIST_FIRST_RCU(&ram_list.blocks);
Expand Down Expand Up @@ -1991,7 +2009,9 @@ static int ram_save_iterate(QEMUFile *f, void *opaque)
}
pages_sent += pages;
acct_info.iterations++;

/* XXX This IS number of RAM iterations
Insert limiter here! */

/* we want to check in the 1st loop, just in case it was the 1st time
and we had to sync the dirty bitmap.
qemu_get_clock_ns() is a bit expensive, so we only check each some
Expand Down
2 changes: 1 addition & 1 deletion qapi-schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -409,7 +409,7 @@
# Since: 0.14.0
##
{ 'struct': 'MigrationStats',
'data': {'transferred': 'int', 'remaining': 'int', 'total': 'int' ,
'data': {'iters': 'int' , 'transferred': 'int', 'remaining': 'int', 'total': 'int' ,
'duplicate': 'int', 'skipped': 'int', 'normal': 'int',
'normal-bytes': 'int', 'dirty-pages-rate' : 'int',
'mbps' : 'number', 'dirty-sync-count' : 'int',
Expand Down