Bug 635418

Summary: Allow enable/disable ksm per VM
Product: Red Hat Enterprise Linux 6 Reporter: Itamar Heim <iheim>
Component: qemu-kvmAssignee: Andrea Arcangeli <aarcange>
Status: CLOSED ERRATA QA Contact: Virtualization Bugs <virt-bugs>
Severity: medium Docs Contact:
Priority: low    
Version: 6.1CC: amit.shah, dallan, ehabkost, gcosta, jyang, lcapitulino, mhusnain, mjenner, mkenneth, tburke, virt-maint, ypu
Target Milestone: betaKeywords: FutureFeature
Target Release: 6.1   
Hardware: All   
OS: Linux   
Whiteboard:
Fixed In Version: qemu-kvm-0.12.1.2-2.135.el6 Doc Type: Enhancement
Doc Text:
Previously, KSM supported global settings and no enable or disable options for each individual virtual machine. Qemu-kvn now allows selective decisions about whether or not KVM should register in KSM at the time of a virtual machine start up. This selection decision feature allows higher performance virtual machines to be selected from the manager, which eliminates the risk of the virtual machine slowing down due to memory duplication.
Story Points: ---
Clone Of:
: 769021 (view as bug list) Environment:
Last Closed: 2011-05-19 11:30:34 UTC Type: ---
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:
Bug Depends On:    
Bug Blocks: 580954, 635417, 635419, 655920, 1008500    

Description Itamar Heim 2010-09-19 16:12:06 UTC
- at create
- via monitor command

Comment 1 Andrea Arcangeli 2010-10-08 15:08:33 UTC
This is an useful feature and it shall be implemented in qemu userland. It doesn't require kernel support (madvise can be called also on a running qemu dynamically to remove it from KSM scan, via qemu monitor command).

The plan is to have KSM scanning subpages inside transparent hugepages, and to split the hugepage and merge the subpages in case we can merge equal subpages. So disabling KSM will prevent hugepages to be splitted so allowing for higher performance.

Comment 4 Andrea Arcangeli 2010-12-21 15:18:09 UTC
This adds -redhat-disable-THP and -redhat-disable-KSM parameters to qemu-kvm.

https://brewweb.devel.redhat.com/taskinfo?taskID=2991515

This qemu-kvm package should be used in combination with this kernel that implements MADV_NOHUGEPAGE:

https://brewweb.devel.redhat.com/taskinfo?taskID=2979741

Comment 13 Joy Pu 2011-02-18 09:24:04 UTC
Verify this bug in 
rpm -qa |grep qemu-kvm-0.12.1.2-2.136 and 2.6.32-94 kernel
gpxe-roms-qemu-0.9.7-6.3.el6.noarch
qemu-img-0.12.1.2-2.136.el6.x86_64
qemu-kvm-tools-0.12.1.2-2.136.el6.x86_64
qemu-kvm-debuginfo-0.12.1.2-2.136.el6.x86_64
qemu-kvm-0.12.1.2-2.136.el6.x86_64

with the -redhat-disable-KSM option, when dd in guest  /sys/kernel/mm/ksm/pages_sharing will be 0. And this value will change without this option.

Steps:
1. enable KSM
echo 1 > /sys/kernel/mm/ksm/
2. start two guest with -redhat-disable-KSM
3. swap off  in both guest
   swapoff -a
4. mount tmpfs and dd 2G zero file in guest
  mount -t tmpfs none /mnt
  dd if=/dev/zero of=/mnt/zero
5. cat /sys/kernel/mm/ksm/pages_sharing to check the status

Comment 14 Andrea Arcangeli 2011-05-06 18:40:16 UTC
    Technical note added. If any revisions are required, please edit the "Technical Notes" field
    accordingly. All revisions will be proofread by the Engineering Content Services team.
    
    New Contents:
A new feature has been introduced to qemu-kvm to selectively decide if KVM should register in KSM or not at virtual machine startup time. Previously it would register unconditionally so KSM could only enabled/disabled globally and not selectively for each virtual machine. This allows to select higher performance virtual machines from the manager, that will not risk to be slowed down in memory de-duplication (either because of transparent hugepage splits during memory-merging, or because of copy-on-writes when de-duplicated memory is modified by the guest).

Comment 15 Misha H. Ali 2011-05-12 06:48:01 UTC
    Technical note updated. If any revisions are required, please edit the "Technical Notes" field
    accordingly. All revisions will be proofread by the Engineering Content Services team.
    
    Diffed Contents:
@@ -1 +1 @@
-A new feature has been introduced to qemu-kvm to selectively decide if KVM should register in KSM or not at virtual machine startup time. Previously it would register unconditionally so KSM could only enabled/disabled globally and not selectively for each virtual machine. This allows to select higher performance virtual machines from the manager, that will not risk to be slowed down in memory de-duplication (either because of transparent hugepage splits during memory-merging, or because of copy-on-writes when de-duplicated memory is modified by the guest).+Previously, KSM supported global settings and no enable or disable options for each individual virtual machine. Qemu-kvn now allows selective decisions about whether or not KVM should register in KSM at the time of a virtual machine start up. This selection decision feature allows higher performance virtual machines to be selected from the manager, which eliminates the risk of the virtual machine slowing down due to memory duplication.

Comment 16 errata-xmlrpc 2011-05-19 11:30:34 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-0534.html

Comment 17 errata-xmlrpc 2011-05-19 12:49:01 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-0534.html