Dieser Inhalt ist in der von Ihnen ausgewählten Sprache nicht verfügbar.
Chapter 7. KSM
qemu-kvm
process. Once the guest virtual machine is running, the contents of the guest virtual machine operating system image can be shared when guests are running the same operating system or applications.
Note
Note
/sys/kernel/mm/ksm/merge_across_nodes
tunable to 0
to avoid merging pages across NUMA nodes. Kernel memory accounting statistics can eventually contradict each other after large amounts of cross-node merging. As such, numad can become confused after the KSM daemon merges large amounts of memory. If your system has a large amount of free memory, you may achieve higher performance by turning off and disabling the KSM daemon. Refer to the Red Hat Enterprise Linux Performance Tuning Guide for more information on NUMA.
- The
ksm
service starts and stops the KSM kernel thread. - The
ksmtuned
service controls and tunes theksm
, dynamically managing same-page merging. Theksmtuned
service startsksm
and stops theksm
service if memory sharing is not necessary. Theksmtuned
service must be told with theretune
parameter to run when new guests are created or destroyed.
The ksm
service is included in the qemu-kvm package. KSM is off by default on Red Hat Enterprise Linux 6. When using Red Hat Enterprise Linux 6 as a KVM host physical machine, however, it is likely turned on by the ksm/ksmtuned
services.
ksm
service is not started, KSM shares only 2000 pages. This default is low and provides limited memory saving benefits.
ksm
service is started, KSM will share up to half of the host physical machine system's main memory. Start the ksm
service to enable KSM to share more memory.
# service ksm start Starting ksm: [ OK ]
ksm
service can be added to the default startup sequence. Make the ksm
service persistent with the chkconfig command.
# chkconfig ksm on
The ksmtuned
service does not have any options. The ksmtuned
service loops and adjusts ksm
. The ksmtuned
service is notified by libvirt when a guest virtual machine is created or destroyed.
# service ksmtuned start Starting ksmtuned: [ OK ]
ksmtuned
service can be tuned with the retune
parameter. The retune
parameter instructs ksmtuned
to run tuning functions manually.
thres
- Activation threshold, in kbytes. A KSM cycle is triggered when thethres
value added to the sum of allqemu-kvm
processes RSZ exceeds total system memory. This parameter is the equivalent in kbytes of the percentage defined inKSM_THRES_COEF
.
/etc/ksmtuned.conf
file is the configuration file for the ksmtuned
service. The file output below is the default ksmtuned.conf
file.
# Configuration file for ksmtuned. # How long ksmtuned should sleep between tuning adjustments # KSM_MONITOR_INTERVAL=60 # Millisecond sleep between ksm scans for 16Gb server. # Smaller servers sleep more, bigger sleep less. # KSM_SLEEP_MSEC=10 # KSM_NPAGES_BOOST is added to thenpages
value, whenfree memory
is less thanthres
. # KSM_NPAGES_BOOST=300 # KSM_NPAGES_DECAY Value given is subtracted to thenpages
value, whenfree memory
is greater thanthres
. # KSM_NPAGES_DECAY=-50 # KSM_NPAGES_MIN is the lower limit for thenpages
value. # KSM_NPAGES_MIN=64 # KSM_NAGES_MAX is the upper limit for thenpages
value. # KSM_NPAGES_MAX=1250 # KSM_TRES_COEF - is the RAM percentage to be calculated in parameterthres
. # KSM_THRES_COEF=20 # KSM_THRES_CONST - If this is a low memory system, and thethres
value is less thanKSM_THRES_CONST
, then resetthres
value toKSM_THRES_CONST
value. # KSM_THRES_CONST=2048 # uncomment the following to enable ksmtuned debug information # LOGFILE=/var/log/ksmtuned # DEBUG=1
KSM stores monitoring data in the /sys/kernel/mm/ksm/
directory. Files in this directory are updated by the kernel and are an accurate record of KSM usage and statistics.
/etc/ksmtuned.conf
file as noted below.
The /sys/kernel/mm/ksm/
files
- full_scans
- Full scans run.
- pages_shared
- Total pages shared.
- pages_sharing
- Pages presently shared.
- pages_to_scan
- Pages not scanned.
- pages_unshared
- Pages no longer shared.
- pages_volatile
- Number of volatile pages.
- run
- Whether the KSM process is running.
- sleep_millisecs
- Sleep milliseconds.
/var/log/ksmtuned
log file if the DEBUG=1
line is added to the /etc/ksmtuned.conf
file. The log file location can be changed with the LOGFILE
parameter. Changing the log file location is not advised and may require special configuration of SELinux settings.
KSM has a performance overhead which may be too large for certain environments or host physical machine systems.
ksmtuned
and the ksm
service. Stopping the services deactivates KSM but does not persist after restarting.
# service ksmtuned stop Stopping ksmtuned: [ OK ] # service ksm stop Stopping ksm: [ OK ]
chkconfig
command. To turn off the services, run the following commands:
# chkconfig ksm off # chkconfig ksmtuned off
Important