From: "Dr. David Alan Gilbert" <dgilbert@redhat.com>
To: Denis Plotnikov <dplotnikov@virtuozzo.com>
Cc: quintela@redhat.com, qemu-devel@nongnu.org, peterx@redhat.com,
armbru@redhat.com, den@openvz.org, pbonzini@redhat.com
Subject: Re: [PATCH v0 3/4] migration: add background snapshot
Date: Wed, 29 Jul 2020 14:27:21 +0100 [thread overview]
Message-ID: <20200729132721.GF2795@work-vm> (raw)
In-Reply-To: <092ca853-d4ec-788d-6f26-7361714b8dea@virtuozzo.com>
* Denis Plotnikov (dplotnikov@virtuozzo.com) wrote:
>
>
> On 27.07.2020 19:48, Dr. David Alan Gilbert wrote:
> > * Denis Plotnikov (dplotnikov@virtuozzo.com) wrote:
> ...
> > > +static void page_fault_thread_stop(void)
> > > +{
> > > + if (page_fault_fd) {
> > > + close(page_fault_fd);
> > > + page_fault_fd = 0;
> > > + }
> > I think you need to do that after you've done the quit and join,
> > otherwise the fault thread might still be reading this.
>
> Seems to be so
> >
> > > + if (thread_quit_fd) {
> > > + uint64_t val = 1;
> > > + int ret;
> > > +
> > > + ret = write(thread_quit_fd, &val, sizeof(val));
> > > + assert(ret == sizeof(val));
> > > +
> > > + qemu_thread_join(&page_fault_thread);
> > > + close(thread_quit_fd);
> > > + thread_quit_fd = 0;
> > > + }
> > > +}
> ...
> > > /**
> > > * ram_find_and_save_block: finds a dirty page and sends it to f
> > > *
> > > @@ -1782,6 +2274,7 @@ static int ram_find_and_save_block(RAMState *rs, bool last_stage)
> > > pss.block = rs->last_seen_block;
> > > pss.page = rs->last_page;
> > > pss.complete_round = false;
> > > + pss.page_copy = NULL;
> > > if (!pss.block) {
> > > pss.block = QLIST_FIRST_RCU(&ram_list.blocks);
> > > @@ -1794,11 +2287,30 @@ static int ram_find_and_save_block(RAMState *rs, bool last_stage)
> > > if (!found) {
> > > /* priority queue empty, so just search for something dirty */
> > > found = find_dirty_block(rs, &pss, &again);
> > > +
> > > + if (found && migrate_background_snapshot()) {
> > > + /*
> > > + * make a copy of the page and
> > > + * pass it to the page search status
> > > + */
> > > + int ret;
> > > + ret = ram_copy_page(pss.block, pss.page, &pss.page_copy);
> > I'm a bit confused about why we hit this; the way I'd thought about your
> > code was we turn on the write faulting, do one big save and then fixup
> > the faults as the save is happening (doing the copies) as the writes
> > hit; so when does this case hit?
>
> To make it more clear, let me draw the whole picture:
>
> When we do background snapshot, the vm is paused untill all vmstate EXCEPT
> ram is saved.
> RAM isn't written at all. That vmstate part is saved in the temporary
> buffer.
>
> Then all the RAM is marked as read-only and the vm is un-paused. Note that
> at this moment all vm's vCPUs are
> running and can touch any part of memory.
> After that, the migration thread starts writing the ram content. Once a
> memory chunk is written, the write protection is removed for that chunk.
> If a vCPU wants to write to a memory page which is write protected (hasn't
> been written yet), this write is intercepted, the memory page is copied
> and queued for writing, the memory page write access is restored. The
> intention behind of that, is to allow vCPU to work with a memory page as
> soon as possible.
So I think I'm confusing this description with the code I'm seeing
above. The code above, being in ram_find_and_save_block makes me think
it's calling ram_copy_page for every page at the point just before it
writes it - I'm not seeing how that corresponds to what you're saying
about it being queued when the CPU tries to write it.
> Once all the RAM has been written, the rest of the vmstate is written from
> the buffer. This needs to be so because some of the emulated devices, saved
> in that
> buffered vmstate part, expects the RAM content to be available first on its
> loading.
Right, same type of problem as postcopy.
Dave
>
> I hope this description will make things more clear.
> If not, please let me know, so I could add more details.
>
> Denis
>
> > --
> > Dr. David Alan Gilbert / dgilbert@redhat.com / Manchester, UK
> >
>
--
Dr. David Alan Gilbert / dgilbert@redhat.com / Manchester, UK
next prev parent reply other threads:[~2020-07-29 13:28 UTC|newest]
Thread overview: 25+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-07-22 8:11 [PATCH v0 0/4] background snapshot Denis Plotnikov
2020-07-22 8:11 ` [PATCH v0 1/4] bitops: add some atomic versions of bitmap operations Denis Plotnikov
2020-07-22 8:11 ` [PATCH v0 2/4] migration: add background snapshot capability Denis Plotnikov
2020-07-23 22:21 ` Peter Xu
2020-07-22 8:11 ` [PATCH v0 3/4] migration: add background snapshot Denis Plotnikov
2020-07-23 22:15 ` Peter Xu
2020-07-29 12:27 ` Denis Plotnikov
2020-07-24 0:08 ` Peter Xu
2020-07-29 12:54 ` Denis Plotnikov
2020-07-29 16:58 ` Peter Xu
2020-07-27 16:48 ` Dr. David Alan Gilbert
2020-07-28 9:34 ` Denis Plotnikov
2020-07-29 13:27 ` Dr. David Alan Gilbert [this message]
2020-07-29 13:57 ` Denis Plotnikov
2020-07-22 8:11 ` [PATCH v0 4/4] background snapshot: add trace events for page fault processing Denis Plotnikov
2020-07-22 14:50 ` [PATCH v0 0/4] background snapshot Peter Xu
2020-07-22 15:42 ` Denis Plotnikov
2020-07-22 15:47 ` Denis Plotnikov
2020-07-22 16:30 ` Peter Xu
2020-07-23 8:03 ` Denis Plotnikov
2020-07-23 17:39 ` Peter Xu
2020-07-24 8:06 ` Denis Plotnikov
2020-07-24 16:31 ` Peter Xu
2020-07-27 16:59 ` Dr. David Alan Gilbert
2020-08-04 13:11 ` Zhanghailiang
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20200729132721.GF2795@work-vm \
--to=dgilbert@redhat.com \
--cc=armbru@redhat.com \
--cc=den@openvz.org \
--cc=dplotnikov@virtuozzo.com \
--cc=pbonzini@redhat.com \
--cc=peterx@redhat.com \
--cc=qemu-devel@nongnu.org \
--cc=quintela@redhat.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).