Re: Swap usage with KVM

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hi, David.

On Tuesday, 20 July 2010 21:18:09 +0200,
David Weber wrote:

> > Yes, we are using Virtio drivers for networking and storage in both VMs
> > with cache=none. Both VMs are running Linux 2.6.32-bpo.5-amd64 from
> > Lenny Backports repositories. For VMHost, we are using a stable version
> > of KVM with Linux 2.6.32.12 compiled from source code of kernel.org and
> > qemu-kvm 0.12.3 compiled with the source code obtained from the official
> > site of KVM.

> Afaik this should be this bug
> http://sourceforge.net/tracker/?func=detail&atid=893831&aid=2989366&group_id=180599
> 
> try upgrading to 0.12.4 or backport this commit
> http://git.kernel.org/?p=virt/kvm/qemu-
> kvm.git;a=commit;h=012d4869c1eb195e83f159ed7b2bced33f37f960

Interesting... I'll try upgrading to qemu-kvm 0.12.4.

Marcelo Tosatti also recommended me to apply this patch I'm attaching.
Someone could confirm whether this is already included in Linux stable?

Thanks for your reply.

Regards,
Daniel
-- 
Fingerprint: BFB3 08D6 B4D1 31B2 72B9  29CE 6696 BF1B 14E6 1D37
Powered by Debian GNU/Linux Lenny - Linux user #188.598
commit 6316e1c8c6af6ccb55ff8564231710660608f46c
Author: Rik van Riel <riel@xxxxxxxxxx>
Date:   Wed Feb 3 16:11:03 2010 -0500

    KVM: VMX: emulate accessed bit for EPT
    
    Currently KVM pretends that pages with EPT mappings never got
    accessed.  This has some side effects in the VM, like swapping
    out actively used guest pages and needlessly breaking up actively
    used hugepages.
    
    We can avoid those very costly side effects by emulating the
    accessed bit for EPT PTEs, which should only be slightly costly
    because pages pass through page_referenced infrequently.
    
    TLB flushing is taken care of by kvm_mmu_notifier_clear_flush_young().
    
    This seems to help prevent KVM guests from being swapped out when
    they should not on my system.
    
    Signed-off-by: Rik van Riel <riel@xxxxxxxxxx>
    Signed-off-by: Avi Kivity <avi@xxxxxxxxxx>

diff --git a/arch/x86/kvm/mmu.c b/arch/x86/kvm/mmu.c
index 913ef4b..b8da671 100644
--- a/arch/x86/kvm/mmu.c
+++ b/arch/x86/kvm/mmu.c
@@ -838,9 +838,15 @@ static int kvm_age_rmapp(struct kvm *kvm, unsigned long *rmapp,
 	u64 *spte;
 	int young = 0;
 
-	/* always return old for EPT */
+	/*
+	 * Emulate the accessed bit for EPT, by checking if this page has
+	 * an EPT mapping, and clearing it if it does. On the next access,
+	 * a new EPT mapping will be established.
+	 * This has some overhead, but not as much as the cost of swapping
+	 * out actively used pages or breaking up actively used hugepages.
+	 */
 	if (!shadow_accessed_mask)
-		return 0;
+		return kvm_unmap_rmapp(kvm, rmapp, data);
 
 	spte = rmap_next(kvm, rmapp, NULL);
 	while (spte) {

Attachment: signature.asc
Description: Digital signature


[Index of Archives]     [KVM ARM]     [KVM ia64]     [KVM ppc]     [Virtualization Tools]     [Spice Development]     [Libvirt]     [Libvirt Users]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite Questions]     [Linux Kernel]     [Linux SCSI]     [XFree86]
  Powered by Linux