LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (http://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   linux print virtual pages associated with processes (http://www.linuxquestions.org/questions/linux-newbie-8/linux-print-virtual-pages-associated-with-processes-4175436101/)

yash0307 11-07-2012 10:48 AM

linux print virtual pages associated with processes
 
how can I print the virtual pages allocated to the currently running processes on my system and also the page faults associated with them?

shivaa 11-07-2012 11:01 AM

Please elaborate little more, what exactly your requirement is & what you've tried so far...

johnsfine 11-07-2012 11:06 AM

Quote:

Originally Posted by yash0307 (Post 4824282)
how can I print the virtual pages allocated to the currently running processes on my system and also the page faults associated with them?

I don't know about associating page faults to pages or to processes. But the virtual pages of each process are available from
/proc/pid/smaps
where you replace pid with the pid of each task you want info on.

yash0307 11-07-2012 11:14 AM

Quote:

Originally Posted by shivaa (Post 4824292)
Please elaborate little more, what exactly your requirement is & what you've tried so far...

I want to list out all the processes that are currently running on my system, and print the virtual pages allocated to it and number of page faults associated with each process.

I have tried it out with many commands to get the solution like vmmstat,top and ps (ps aux)..but didn't succeed.
please help me out.

johnsfine 11-07-2012 11:45 AM

Quote:

Originally Posted by yash0307 (Post 4824300)
the virtual pages allocated to it

I'm still not sure whether you mean the total number of virtual pages or something much more detailed, all the way up to some kind of identification of each virtual page.

Either way, there are some complicated questions about what "allocated" means.

The smaps info gives you quite a lot of detail (but not all the way down to individual pages) about what is mapped in the virtual address space of a process. One conceivable meaning of "allocated" in your question might be everything that is mapped. The total size of all the mappings is the VIRT column in top and similar tools.

But that is a larger value than what you are likely to think "allocated" means. Mappings may be "demand zero" so the pages don't take up space anywhere (neither on disk nor in ram). Mappings may be "copy on write" so the same physical pages (on disk or in ram) are counted by more than one process even though not shareable. Of course, pages may be shareable and those might or might not actually be shared, so pages may be counted by more than one process without being "copy on write".

yash0307 11-07-2012 11:52 AM

Quote:

Originally Posted by johnsfine (Post 4824317)
I'm still not sure whether you mean the total number of virtual pages or something much more detailed, all the way up to some kind of identification of each virtual page.

Either way, there are some complicated questions about what "allocated" means.

The smaps info gives you quite a lot of detail (but not all the way down to individual pages) about what is mapped in the virtual address space of a process. One conceivable meaning of "allocated" in your question might be everything that is mapped. The total size of all the mappings is the VIRT column in top and similar tools.

But that is a larger value than what you are likely to think "allocated" means. Mappings may be "demand zero" so the pages don't take up space anywhere (neither on disk nor in ram). Mappings may be "copy on write" so the same physical pages (on disk or in ram) are counted by more than one process even though not shareable. Of course, pages may be shareable and those might or might not actually be shared, so pages may be counted by more than one process without being "copy on write".

I think you previous answer is what I want for this question-->"all the virtual pages of each process" and the number of page faults I can find out through the ps command using the pid of the process.I think my problem is solved.

thanks a lot :)

shivaa 11-07-2012 11:54 AM

Inside the /proc directory, you'll find associated directories for every process, named same as pid. So you can try searching required info. in "status" file inside every pid dir. i.e. in /proc/<pid>/status file.


All times are GMT -5. The time now is 02:41 PM.