I'm working on a project about Linux kernel mm(memory management) and with a page, I need to find the process which the page belongs to.
However, I could not find any way without modifying the kernel. So, I'm really wondering whether it is possible to do that without modifying kernel.
In detail, when I have a VMA then, it is also possible to convert the VMA into the corresponding page, I want to know what process the VMA or page belongs to.
for example, in mm/page_io.c (of linux kernel source tree):
int __swap_writepage(struct page *page, struct writeback_control *wbc,
void (*end_write_func)(struct bio *, int))
{
struct bio *bio;
int ret, rw = WRITE;
struct swap_info_struct *sis = page_swap_info(page);
...
ret = bdev_write_page(sis->bdev, swap_page_sector(page), page, wbc);
if (!ret) {
count_vm_event(PSWPOUT);
/* I should figure out what process is having the page above.
* But it is hard to know, because page is managed in LRU and
* it is not directly related to its process. What hints I have
* are page struct and some data structures which I could
* infer from the page only.
*/
// here!
In where I mark "here!", I should do that work what I said above. I'm waiting for your great answer. Thank you!