From mboxrd@z Thu Jan 1 00:00:00 1970 From: Daniel Bareiro Subject: Re: Swap usage with KVM Date: Thu, 22 Jul 2010 07:09:10 -0300 Message-ID: <20100722100910.GA23163@defiant.freesoftware> References: <20100711151257.GA13279@defiant.freesoftware> <20100711220858.GE9267@defiant.freesoftware> <201007202118.09842.davidwerbung@gmx.de> Reply-To: dbareiro@gmx.net Mime-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha1; protocol="application/pgp-signature"; boundary="/NkBOFFp2J2Af1nK" To: KVM General Return-path: Received: from mailout-de.gmx.net ([213.165.64.22]:46077 "HELO mail.gmx.net" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with SMTP id S1754476Ab0GVKJX (ORCPT ); Thu, 22 Jul 2010 06:09:23 -0400 Received: from defiant (defiant.freesoftware [10.1.0.65]) by hermes.freesoftware (Postfix) with ESMTP id 25C6B421 for ; Thu, 22 Jul 2010 07:06:57 -0300 (ART) Content-Disposition: inline In-Reply-To: <201007202118.09842.davidwerbung@gmx.de> Sender: kvm-owner@vger.kernel.org List-ID: --/NkBOFFp2J2Af1nK Content-Type: multipart/mixed; boundary="qMm9M+Fa2AknHoGS" Content-Disposition: inline --qMm9M+Fa2AknHoGS Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable 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=3Dnone. 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=3Ddetail&atid=3D893831&aid=3D2989366= &group_id=3D180599 >=20 > try upgrading to 0.12.4 or backport this commit > http://git.kernel.org/?p=3Dvirt/kvm/qemu- > kvm.git;a=3Dcommit;h=3D012d4869c1eb195e83f159ed7b2bced33f37f960 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 --=20 Fingerprint: BFB3 08D6 B4D1 31B2 72B9 29CE 6696 BF1B 14E6 1D37 Powered by Debian GNU/Linux Lenny - Linux user #188.598 --qMm9M+Fa2AknHoGS Content-Type: text/x-diff; charset=us-ascii Content-Disposition: attachment; filename="kvm-vmx-accessed-bit.patch" Content-Transfer-Encoding: quoted-printable commit 6316e1c8c6af6ccb55ff8564231710660608f46c Author: Rik van Riel Date: Wed Feb 3 16:11:03 2010 -0500 KVM: VMX: emulate accessed bit for EPT =20 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. =20 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. =20 TLB flushing is taken care of by kvm_mmu_notifier_clear_flush_young(). =20 This seems to help prevent KVM guests from being swapped out when they should not on my system. =20 Signed-off-by: Rik van Riel Signed-off-by: Avi Kivity 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 lon= g *rmapp, u64 *spte; int young =3D 0; =20 - /* 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); =20 spte =3D rmap_next(kvm, rmapp, NULL); while (spte) { --qMm9M+Fa2AknHoGS-- --/NkBOFFp2J2Af1nK Content-Type: application/pgp-signature; name="signature.asc" Content-Description: Digital signature Content-Disposition: inline -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.9 (GNU/Linux) iEYEARECAAYFAkxIGMYACgkQZpa/GxTmHTcLJwCeNyhdXNYytSo1Gww9G9pXG1oL hZwAn1g9WxUb4RaBQWBTK/znMaIb0HOD =a5hi -----END PGP SIGNATURE----- --/NkBOFFp2J2Af1nK--