public inbox for kvm@vger.kernel.org
 help / color / mirror / Atom feed
From: Daniel Bareiro <daniel-listas@gmx.net>
To: KVM General <kvm@vger.kernel.org>
Subject: Re: Swap usage with KVM
Date: Thu, 22 Jul 2010 07:09:10 -0300	[thread overview]
Message-ID: <20100722100910.GA23163@defiant.freesoftware> (raw)
In-Reply-To: <201007202118.09842.davidwerbung@gmx.de>


[-- Attachment #1.1: Type: text/plain, Size: 1138 bytes --]

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

[-- Attachment #1.2: kvm-vmx-accessed-bit.patch --]
[-- Type: text/x-diff, Size: 1691 bytes --]

commit 6316e1c8c6af6ccb55ff8564231710660608f46c
Author: Rik van Riel <riel@redhat.com>
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@redhat.com>
    Signed-off-by: Avi Kivity <avi@redhat.com>

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 #2: Digital signature --]
[-- Type: application/pgp-signature, Size: 197 bytes --]

      reply	other threads:[~2010-07-22 10:09 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-07-11 15:12 Swap usage with KVM Daniel Bareiro
2010-07-11 19:12 ` Daniel Bareiro
2010-07-11 21:49   ` Rik van Riel
2010-08-02 18:57     ` Daniel Bareiro
2010-08-02 19:31       ` Rik van Riel
2010-08-02 19:52         ` Daniel Bareiro
2010-08-02 20:22           ` Rik van Riel
2010-08-02 21:43             ` Daniel Bareiro
2010-08-27 10:04             ` Swap usage with KVM (and KSM) Daniel Bareiro
2010-08-27 13:42               ` Rik van Riel
2010-07-11 21:05 ` Swap usage with KVM Freddie Cash
2010-07-11 22:08   ` Daniel Bareiro
2010-07-20 15:04     ` Daniel Bareiro
2010-07-20 19:18     ` David Weber
2010-07-22 10:09       ` Daniel Bareiro [this message]

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=20100722100910.GA23163@defiant.freesoftware \
    --to=daniel-listas@gmx.net \
    --cc=dbareiro@gmx.net \
    --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