2

Can some one please help me understand this.

i am running kvm hosts with 5 vms on it.

These are ksm driver statistics

each page is 4KB

cat /sys/kernel/mm/ksm/pages_shared     162221
cat /sys/kernel/mm/ksm/pages_sharing    264281
cat /sys/kernel/mm/ksm/pages_unshared   241483

Is "pages_sharing" total no of pages created by vms. and "pages_shared" is the number of pages that is found similar and merged together.

if that is true then why is  pages_sharing-pages_shared != pages_unshared


 264281-162221 != 241483

3 Answers 3

5

pages_unshared means just what it says: the pages could not be shared because they're unique.

pages_shared indicates how many pages are actually in use and being shared.

pages_sharing indicates how many pages the VMs think there are. If you didn't have KSM running, this is how many pages would actually be in use.

So, in your example, 264281 pages have been found to be shareable, and so they were merged into 162221 pages, while 241483 pages were not shareable. KSM saved you about 398 MB of memory.

3
  • can u tell me how did u get 398mb? Feb 25, 2013 at 8:16
  • 2
    Sure: (264281 - 162221) * 4096 = 418037760. Divide by (1024 * 1024) and you get 398.67... Feb 25, 2013 at 8:23
  • Your explanation about pages_unshared is confusing.
    – shomeax
    Mar 22 at 22:12
2

See here https://www.kernel.org/doc/Documentation/vm/ksm.txt

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

So, you shouldn't substract pages_shared from pages_sharing. pages_sharing is saved memory!

0

pages_sharing is the memory really saved: 264281*4096/1024/1024=1032MB

(264281 - 162221) * 4096 = 418037760. Divide by (1024 * 1024)= 398.67MB is not memory saved

1
  • Welcome on the ServerFault! Please, elabore more your answer - it is important, if not only these people can understand it, who can make this calculation also for themselfes :-)
    – peterh
    Aug 10, 2017 at 15:33

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.