public inbox for kvm@vger.kernel.org
 help / color / mirror / Atom feed
From: Paolo Bonzini <pbonzini@redhat.com>
To: qna <infinite.questions@gmail.com>
Cc: "kvm@vger.kernel.org" <kvm@vger.kernel.org>
Subject: Re: When is the page table built for migration destination ?
Date: Mon, 09 Sep 2013 10:14:02 +0200	[thread overview]
Message-ID: <522D834A.2050309@redhat.com> (raw)
In-Reply-To: <CALSEb2fia0tjLRRozL9L27B_sQM8hFPn07oOrJJqAOchLYx5-g@mail.gmail.com>

Il 09/09/2013 07:27, qna ha scritto:
> Hello List,
> 
> I am trying to understand kvm memory management code related to VM
> migration. From the code, it looks like during guest VM migration, all the
> memory of the guest is transferred from source to destination, but does it
> copy the source page tables to destination ?
> 
> A certain GFN(guest frame/physical number) X can be mapped to to PFN Y in
> source but it is not necessary to map that GFN to PFN Y at destination.
> Thus it should not make sense to copy page tables. But then, KVM should
> build page tables when entire memory is copied(because current
> implementation is precopy).
> 
> I added prinks in code and looks like at destination it fault, there are no
> page tables created. But the memory is. Is this understanding correct ? Can
> anyone explain which part of code is doing this page table building ?

The guest's page tables that do the gva->gfn (guest virtual
address->guest frame number) translation are in guest memory, so they
are obviously migrated together with the memory.

As the guest runs, KVM builds page tables that do either gfn->pfn
translation (if nested page tables are in use) or a combined gva->pfn
translation (these are called "shadow page tables").  These page tables
are internal to KVM and they are built lazily as the guest runs.  To do
this, KVM intercepts page faults, then:

* if the entry for the GFN doesn't exist in the KVM page tables, it
builds the entry and retries

* if the entry for the GFN exists, it passes the page fault to the guest.

Paolo

  reply	other threads:[~2013-09-09  8:13 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-09-09  5:27 When is the page table built for migration destination ? qna
2013-09-09  8:14 ` Paolo Bonzini [this message]
2013-09-09  9:38   ` Sunil
2013-09-09  9:58     ` Paolo Bonzini

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=522D834A.2050309@redhat.com \
    --to=pbonzini@redhat.com \
    --cc=infinite.questions@gmail.com \
    --cc=kvm@vger.kernel.org \
    /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