From: Rik van Riel on
On 07/06/2010 12:24 PM, Gleb Natapov wrote:
> When page is swapped in it is mapped into guest memory only after guest
> tries to access it again and generate another fault. To save this fault
> we can map it immediately since we know that guest is going to access
> the page.
>
> Signed-off-by: Gleb Natapov<gleb(a)redhat.com>

Acked-by: Rik van Riel <riel(a)redhat.com>

--
All rights reversed
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo(a)vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
From: Marcelo Tosatti on
On Tue, Jul 06, 2010 at 07:24:57PM +0300, Gleb Natapov wrote:
> When page is swapped in it is mapped into guest memory only after guest
> tries to access it again and generate another fault. To save this fault
> we can map it immediately since we know that guest is going to access
> the page.
>
> Signed-off-by: Gleb Natapov <gleb(a)redhat.com>
> ---
> arch/x86/include/asm/kvm_host.h | 7 ++++++-
> arch/x86/kvm/mmu.c | 27 ++++++++++++++++++++-------
> arch/x86/kvm/paging_tmpl.h | 37 +++++++++++++++++++++++++++++++++----
> arch/x86/kvm/x86.c | 9 +++++++++
> virt/kvm/kvm_main.c | 2 ++
> 5 files changed, 70 insertions(+), 12 deletions(-)
>

> +static int FNAME(page_fault_other_cr3)(struct kvm_vcpu *vcpu, gpa_t cr3,
> + gva_t addr, u32 error_code)
> +{
> + int r = 0;
> + gpa_t curr_cr3 = vcpu->arch.cr3;
> +
> + if (curr_cr3 != cr3) {
> + /*
> + * We do page fault on behalf of a process that is sleeping
> + * because of async PF. PV guest takes reference to mm that cr3
> + * belongs too, so it has to be valid here.
> + */
> + kvm_set_cr3(vcpu, cr3);
> + if (kvm_mmu_reload(vcpu))
> + goto switch_cr3;
> + }
> +
> + r = FNAME(page_fault)(vcpu, addr, error_code, true);

KVM_REQ_MMU_SYNC request generated here must be processed before
switching to a different cr3 (otherwise vcpu_enter_guest will process it
with the wrong cr3 in place).

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo(a)vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/