如何在Linux内核中找到包含页面的进程?

时间:2017-01-29 16:34:20

标签: c linux linux-kernel

我正在开发一个关于Linux内核mm(内存管理)的项目 和页面,我需要找到页面所属的过程。

但是,如果不修改内核,我找不到任何方法。 所以,我真的很想知道在不修改内核的情况下是否可以这样做。

详细说明,当我有VMA时,也可以将VMA转换为相应的页面,我想知道VMA或页面属于哪个进程。

例如,在mm / page_io.c(Linux内核源代码树)中:

    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!

在我标记的地方!#34;我应该按照上面所说的那样做。 我等你的好回答。 谢谢!

0 个答案:

没有答案