Created attachment 406365 [details] trivial backport of upstream changeset Description of problem: The RHEL 5 KVM code does not emulate the accessed bit for EPT pages. This can cause the host to swap out frequently used guest pages, which can be a performance issue. I propose merging a backport of this changeset into RHEL 5 KVM: commit 6316e1c8c6af6ccb55ff8564231710660608f46c Author: Rik van Riel <riel> 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> Signed-off-by: Avi Kivity <avi>
Rik, could you tell us how to test this fix? An example with some steps would really help. Thanks.
Using Systemtap to probe the fix, the results were 1. kvm-83-164.el5 stapio kvm_age_rmapp 15531164 kvm_age_rmapp returns 0 15531164 times 2. kvm-83-176.el5 stapio kvm_age_rmapp 11302136 kvm_age_rmapp returns 0 11299767 times kvm_age_rmapp returns 1 2369 times Host info: CPU model: Intel(R) Core(TM) i7 CPU 920 @ 2.67GHz Mem: 12G # dmesg | grep ept ata3.00: 976773168 sectors, multi 0: LBA48 NCQ (depth 31/32) ata4.00: 976773168 sectors, multi 0: LBA48 NCQ (depth 31/32) kvm: virtualization flags detected on this hardware: vmx tpr_shadow vnmi flexpriority ept vpid kvm: virtualization flags detected on this hardware: vmx tpr_shadow vnmi flexpriority ept vpid kvm: virtualization flags detected on this hardware: vmx tpr_shadow vnmi flexpriority ept vpid Steps: 1. Start ./EPTtest.sh which in turn calls kvmcall_cnt.stp (see attachment) 2. Boot a Win2008rc guest overcommitting host physical memory #/usr/libexec/qemu-kvm -m 12G -smp 4 -drive file=test2k8.raw,if=virtio,cache=none,boot=on -net nic,model=virtio,vlan=1,macaddr=76:00:40:3F:20:20 -net tap,vlan=1,script=/etc/qemu-ifup -boot c -uuid 17644ecc-d3a1-4d3c-a386-12daf50015f2 -usbdevice tablet -no-hpet -rtc-td-hack -no-kvm-pit-reinjection -monitor stdio -notify all -cpu qemu64,+sse2 -balloon none -startdate now -vnc :1 -name EPT-test 3. Wait till guest finishes booting, and shut down guest 4. Press "^C" to end ./EPTtest.sh
Created attachment 417481 [details] ETPtest.sh will kvmcall_cnt.stp
Created attachment 417482 [details] kvm module systemtap
Verified on kvm-83-206.el5, PASS. Steps are the same as in Comment 5. stapio kvm_age_rmapp 10454128 kvm_age_rmapp returns 0 9333769 times kvm_age_rmapp returns 1 1120359 times ^^^^^^^^^
An advisory has been issued which should help the problem described in this bug report. This report is therefore being closed with a resolution of ERRATA. For more information on therefore solution and/or where to find the updated files, please follow the link below. You may reopen this bug report if the solution does not work for you. http://rhn.redhat.com/errata/RHSA-2011-0028.html