KSM: Difference between revisions
No edit summary |
Speculatrix (talk | contribs) m (→Kernel Samepage Merging: reworded original cumbersome wording) |
||
(One intermediate revision by one other user not shown) | |||
Line 1: | Line 1: | ||
= Kernel Samepage Merging = | = Kernel Samepage Merging = | ||
KSM is a memory-saving de-duplication feature, that merges anonymous (private) pages (not pagecache ones). Although it started this way, KSM is currently | KSM is a memory-saving de-duplication feature, that merges anonymous (private) pages (not pagecache ones). Although it started this way, KSM is currently suitable for more than Virtual Machine use, as it can be useful to any application which generates many instances of the same data | ||
application which generates many instances of the same data | |||
== Enabling KSM == | == Enabling KSM == | ||
Line 48: | Line 47: | ||
|- | |- | ||
|} | |} | ||
[[Category:Architecture]][[Category:Docs]][[Category:HowTo]] |
Latest revision as of 04:53, 9 July 2015
Kernel Samepage Merging
KSM is a memory-saving de-duplication feature, that merges anonymous (private) pages (not pagecache ones). Although it started this way, KSM is currently suitable for more than Virtual Machine use, as it can be useful to any application which generates many instances of the same data
Enabling KSM
KSM only operates on those areas of address space which an application has advised to be likely candidates for merging, by using the madvise(2) system call: int madvise(addr, length, MADV_MERGEABLE).
The app may call int madvise(addr, length, MADV_UNMERGEABLE) to cancel that advice and restore unshared pages: whereupon KSM unmerges whatever it merged in that range. Note: this unmerging call may suddenly require more memory than is available - possibly failing with EAGAIN, but more probably arousing the Out-Of-Memory killer.
Status
Merged in linux 2.6.32. One needs to enable it via CONFIG_KSM=y
Results
TBD
Testing
You can verify KSM is in action, by checking for the existence of some of its /sys files, under /sys/kernel/mm/ksm/
They are:
pages_shared | how many shared pages are being used |
pages_sharing | how many more sites are sharing them i.e. how much saved |
pages_unshared | how many pages unique but repeatedly checked for merging |
pages_volatile | how many pages changing too fast to be placed in a tree |
full_scans | how many times all mergeable areas have been scanned |