LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Programming (https://www.linuxquestions.org/questions/programming-9/)
-   -   Monitor memory saved from KSM (https://www.linuxquestions.org/questions/programming-9/monitor-memory-saved-from-ksm-929671/)

demon007 02-16-2012 05:11 AM

Monitor memory saved from KSM
 
I am marking the allocated memory for my program as mergeable. While checking the pages shared in KSM I can see that pages are getting merged in that program.

To check how much memory is saved by page merging, I run the program with mergeable and without mergeable.

But when I check with top command it shows that same amount of memory is used.

I am not able to figure that if the pages are getting merged then how it is showing same amount of memory used.

Please help me.

Thanks in advance.

mulyadi.santosa 03-08-2012 12:15 PM

Hi :)

I am just guessing that top "thinks" the KSM merged pages are like shared library.

from process address space's point of view, those pages are still mapped on each processes, thus are counted in their RSS (resident set size). The same like your shared libraries. It might be single .so file, but mapped into say 3 programs. Well then, each of them will count this .so into their RSS, while in fact only lesser amount of file backed pages are used.

Hope I explained it clearly :)

demon007 03-08-2012 12:40 PM

I think its correct but that is my problem. I mean I want to monitor those savings. So if top cannot show it, then how to monitor how much memory is being saved.

Quote:

Originally Posted by mulyadi.santosa (Post 4622058)
Hi :)

I am just guessing that top "thinks" the KSM merged pages are like shared library.

from process address space's point of view, those pages are still mapped on each processes, thus are counted in their RSS (resident set size). The same like your shared libraries. It might be single .so file, but mapped into say 3 programs. Well then, each of them will count this .so into their RSS, while in fact only lesser amount of file backed pages are used.

Hope I explained it clearly :)


mulyadi.santosa 03-08-2012 05:20 PM

Hi :)

I think you need to rely on /proc/meminfo directly. IIRC, "anonpages" is what you need:

Code:

grep -i anonpage /proc/meminfo
See if that helps you :)


All times are GMT -5. The time now is 12:52 AM.