Bug 582038 - backport EPT accessed bit emulation
Summary: backport EPT accessed bit emulation
Keywords:
Status: CLOSED ERRATA
Alias: None
Product: Red Hat Enterprise Linux 5
Classification: Red Hat
Component: kvm
Version: 5.5
Hardware: All
OS: Linux
low
medium
Target Milestone: rc
: ---
Assignee: Rik van Riel
QA Contact: Virtualization Bugs
URL:
Whiteboard:
Depends On:
Blocks:
TreeView+ depends on / blocked
 
Reported: 2010-04-13 22:33 UTC by Rik van Riel
Modified: 2013-01-09 22:27 UTC (History)
6 users (show)

Fixed In Version: kvm-83-175.el5
Doc Type: Bug Fix
Doc Text:
Clone Of:
Environment:
Last Closed: 2011-01-13 23:34:42 UTC
Target Upstream Version:
Embargoed:


Attachments (Terms of Use)
trivial backport of upstream changeset (1.73 KB, patch)
2010-04-13 22:33 UTC, Rik van Riel
no flags Details | Diff
ETPtest.sh will kvmcall_cnt.stp (43 bytes, application/x-sh)
2010-05-28 05:51 UTC, Keqin Hong
no flags Details
kvm module systemtap (953 bytes, application/octet-stream)
2010-05-28 05:52 UTC, Keqin Hong
no flags Details


Links
System ID Private Priority Status Summary Last Updated
Red Hat Product Errata RHSA-2011:0028 0 normal SHIPPED_LIVE Low: kvm security and bug fix update 2011-01-13 11:03:39 UTC

Description Rik van Riel 2010-04-13 22:33:01 UTC
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>

Comment 4 Keqin Hong 2010-05-17 09:00:38 UTC
Rik, could you tell us how to test this fix? An example with some steps would really help. Thanks.

Comment 5 Keqin Hong 2010-05-28 05:49:26 UTC
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

Comment 6 Keqin Hong 2010-05-28 05:51:52 UTC
Created attachment 417481 [details]
ETPtest.sh will kvmcall_cnt.stp

Comment 7 Keqin Hong 2010-05-28 05:52:40 UTC
Created attachment 417482 [details]
kvm module systemtap

Comment 9 Keqin Hong 2010-11-05 11:29:37 UTC
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
                            ^^^^^^^^^

Comment 12 errata-xmlrpc 2011-01-13 23:34:42 UTC
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


Note You need to log in before you can comment on or make changes to this bug.