Is there a way to get a list of all pages owned by a process in Linux kernel? I would need to call 'page_free()'on those pages. Please let me know!!
Asked
Active
Viewed 1,161 times
1
-
Are you asking for a Linux kernel command, or something more in relation to Android/C? I know that Linux has a `ps` command that shows processes, and if you add an 'x' after it (`ps x`), it will show you a more extensive list. Here is some documentation: http://unixhelp.ed.ac.uk/CGI/man-cgi?ps – Zhouster Jul 08 '14 at 18:39
-
I am asking if there is a "linux kernel API" that gives a list of pages associated with a process or if there is a way to get this list by having a process id. – user3788234 Jul 08 '14 at 18:57
-
You can try `ps pid`, where pid is your process id. This will give you all pages linked to the given process id. – Zhouster Jul 08 '14 at 19:05
-
looks like you have mistaken my question. I was asking if there is a way inside the kernel code to call some 'kernel api' that gives a list of all pages associated with a process. This is something to do with the task_struct of that process. – user3788234 Jul 08 '14 at 19:10
-
Ah, I understand. I apologize, but I do not have an answer for your question then. – Zhouster Jul 08 '14 at 19:54
1 Answers
2
If you want get a list of all the physical pages to collect state, you can write a small kernel module to achieve this, declare a struct page *p for (for physical page on the system), there is a exported symbol ./mm/memory.c:mem_map pointing to the page with PFN = 0. You can use get_num_physpage() to get total number of physical pages. Then you should be able to walk to the array to get physical page stats.
If its all pages of a process: it looks like you have to walk the page tables of a process
hope this helps!