How to get list of all pages that belong to a proc

2019-08-06 08:44发布

问题:

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!!

回答1:

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!