From Fedora Project Wiki

< FWN‎ | Beats

Line 15: Line 15:


==== KSM Tuning ====
==== KSM Tuning ====
[[IzikEidus|Izik Eidus]]
[[MarkMcLoughlin|Mark McLoughlin]]
<ref>http://www.redhat.com/archives/fedora-virt/2009-October/msg00110.html</ref>
described<ref>http://www.redhat.com/archives/fedora-virt/2009-October/msg00119.html</ref>
the default state of KSM<ref>http://fedoraproject.org/wiki/Features/KSM</ref> on Fedora systems.
"For Fedora 13, it'll be off by default in the kernel and the recommended
way of switching it on is with 'chkconfig ksm on'"
"For Fedora [[Releases/12|12]], it's on by default in the kernel, 'chkconfig ksm on' just changes max pages and the only way of disabling it is by manually
writing zero to {{filename|/sys/kernel/mm/ksm/run}}."


" by default enabled and only with 2000 kernel pages... What I am worried about is that users wont use the ksm tunning script and would just run ksm with this 2000 kernel pages - the result would be that ksm will probably merge just the zero pages (that could be alot of memory) and the user might not know
At release of Fedora 12 the kernel will default to a maximum of 2000 merged memory pages. A future F12 kernel update to 2.6.32 will likely disable KSM by default.
 
To take advantage of KSM in Fedora 12, the <code>ksm</code> service must be enabled:
that much more memory can be saved...
<pre>
 
sudo chkconfig ksm on
 
</pre>
Is it possible to at least make ksm disabled by default? so the users will have to run the ksm tunning script when they want to start ksm?
 
And if we set it to disabled by default, cant we set the initialized values
into more realistic value? (like 1/4 of the memory in the mainline kernels? )
"
<ref>http://www.kernel.org/doc/Documentation/vm/ksm.txt</ref>


[[MarkMcLoughlin|Mark McLoughlin]]
[[MarkMcLoughlin|Mark McLoughlin]]
<ref>http://www.redhat.com/archives/fedora-virt/2009-October/msg00112.html</ref>
also noted<ref>http://www.redhat.com/archives/fedora-virt/2009-October/msg00112.html</ref>
 
The maximum number of pages which may be merged defaults to half of the system
"ksm is disabled by default currently"
memory, and may also be manually defined in {{filename|/etc/sysconfig/ksm}}.
 
"Here's the logic we have in the init script<ref>http://gitorious.org/ksm-control-scripts/ksm-control-scripts</ref>:"
"Here's the logic we have in the init script<ref>http://gitorious.org/ksm-control-scripts/ksm-control-scripts</ref>:
 
<pre>
<pre>
   # unless KSM_MAX_KERNEL_PAGES is set, let ksm munch up to half of total memory.
   # unless KSM_MAX_KERNEL_PAGES is set, let ksm munch up to half of total memory.
Line 48: Line 45:


[[JustinForbes|Justin Forbes]]
[[JustinForbes|Justin Forbes]]
<ref>http://www.redhat.com/archives/fedora-virt/2009-October/msg00115.html</ref>
points out<ref>http://www.redhat.com/archives/fedora-virt/2009-October/msg00115.html</ref>
 
"The limit to half of total memory is because ksm pages are unswappable at
"There are actually 2 init scripts.  One to turn on ksm, and one for tuning.
this time. To be fixed in a future kernel."
The actual ksm init script simply makes sure ksm is turned on in the kernel
and sets max_kernel_pages to half of system memory.  The ksmtuned script is
a bit more involved."
 
[[MarkMcLoughlin|Mark McLoughlin]]
<ref>http://www.redhat.com/archives/fedora-virt/2009-October/msg00119.html</ref>
"For Fedora 13, it'll be off by default in the kernel and the recommended
way of switching it on is with 'chkconfig ksm on'


For Fedora 12, it's on by default in the kernel, 'chkconfig ksm on' just
A second service, <code>ksmtuned</code>, may also be enabled.
changes max pages and the only way of disabling it is by manually
Ksmtuned regulates how aggressively the system will attempt to merge pages.
writing zero to {{filename|/sys/kernel/mm/ksm/run}}"
Parameters such as how many pages to scan before sleeping and how long to
sleep may be configured in {{filename|/etc/ksmtuned.conf}}.


"We'll probably end up with this behaviour in F12 updates at some point
Memory pages must be flagged as mergable before KSM will scan them looking for
anyway when 2.6.32 is pulled in"
duplicates. At present only KVM pages will be marked as such.
 
As described in the kernel docs<ref>http://www.kernel.org/doc/Documentation/vm/ksm.txt</ref>,
[[JustinForbes|Justin Forbes]]
the effect of KSM system memory may be examined in {{filename|/sys/kernel/mm/ksm}}.
"The limit to half of total memory is because ksm pages are unswappable at
"A high ratio of pages_sharing to pages_shared indicates good sharing, but
this time.  To be fixed in a future kernel."
a high ratio of pages_unshared to pages_sharing indicates wasted effort."


<references />
<references />

Revision as of 02:44, 2 November 2009


Virtualization

In this section, we cover discussion of Fedora virtualization technologies on the @fedora-virt and @virt-tools lists..

Contributing Writer: Dale Bewley

Fedora Virtualization List

This section contains the discussion happening on the fedora-virt list.

KSM Tuning

Mark McLoughlin described[1] the default state of KSM[2] on Fedora systems. "For Fedora 13, it'll be off by default in the kernel and the recommended way of switching it on is with 'chkconfig ksm on'" "For Fedora 12, it's on by default in the kernel, 'chkconfig ksm on' just changes max pages and the only way of disabling it is by manually writing zero to /sys/kernel/mm/ksm/run."

At release of Fedora 12 the kernel will default to a maximum of 2000 merged memory pages. A future F12 kernel update to 2.6.32 will likely disable KSM by default. To take advantage of KSM in Fedora 12, the ksm service must be enabled:

sudo chkconfig ksm on

Mark McLoughlin also noted[3] The maximum number of pages which may be merged defaults to half of the system memory, and may also be manually defined in /etc/sysconfig/ksm. "Here's the logic we have in the init script[4]:"

  # unless KSM_MAX_KERNEL_PAGES is set, let ksm munch up to half of total memory.
  default_max_kernel_pages () {
      local total pagesize
      total=`awk '/^MemTotal:/ {print $2}' /proc/meminfo`
      pagesize=`getconf PAGESIZE`
      echo $[total * 1024 / pagesize / 2]
  }

Justin Forbes points out[5] "The limit to half of total memory is because ksm pages are unswappable at this time. To be fixed in a future kernel."

A second service, ksmtuned, may also be enabled. Ksmtuned regulates how aggressively the system will attempt to merge pages. Parameters such as how many pages to scan before sleeping and how long to sleep may be configured in /etc/ksmtuned.conf.

Memory pages must be flagged as mergable before KSM will scan them looking for duplicates. At present only KVM pages will be marked as such. As described in the kernel docs[6], the effect of KSM system memory may be examined in /sys/kernel/mm/ksm. "A high ratio of pages_sharing to pages_shared indicates good sharing, but a high ratio of pages_unshared to pages_sharing indicates wasted effort."

Virtualization Tools List

This section contains the discussion happening on the virt-tools-list list.

libosinfo Revisited

Arjun Roy revived[1] discussion of a library to track details of OS distributions for use by tools such as Package-x-generic-16.pngpython-virtinst and virt-inspector. LibOSinfo was first proposed[2] by Cole Robinson.