aboutsummaryrefslogtreecommitdiffstats
path: root/arch
diff options
context:
space:
mode:
authorRik van Riel <riel@redhat.com>2010-02-03 16:11:03 -0500
committerMarcelo Tosatti <mtosatti@redhat.com>2010-03-01 10:36:08 -0500
commit6316e1c8c6af6ccb55ff8564231710660608f46c (patch)
treeeda5c9c5be2f2f11d820899515a4923d22467e8c /arch
parent8f0b1ab6fb045a1324d9435ba00c2940783b0041 (diff)
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>
Diffstat (limited to 'arch')
-rw-r--r--arch/x86/kvm/mmu.c10
1 files changed, 8 insertions, 2 deletions
diff --git a/arch/x86/kvm/mmu.c b/arch/x86/kvm/mmu.c
index 913ef4b7939a..b8da6715d08b 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,
838 u64 *spte; 838 u64 *spte;
839 int young = 0; 839 int young = 0;
840 840
841 /* always return old for EPT */ 841 /*
842 * Emulate the accessed bit for EPT, by checking if this page has
843 * an EPT mapping, and clearing it if it does. On the next access,
844 * a new EPT mapping will be established.
845 * This has some overhead, but not as much as the cost of swapping
846 * out actively used pages or breaking up actively used hugepages.
847 */
842 if (!shadow_accessed_mask) 848 if (!shadow_accessed_mask)
843 return 0; 849 return kvm_unmap_rmapp(kvm, rmapp, data);
844 850
845 spte = rmap_next(kvm, rmapp, NULL); 851 spte = rmap_next(kvm, rmapp, NULL);
846 while (spte) { 852 while (spte) {