开发者

Linux page-cache list

I want to get a list of all PFNs which belong to the pagecache. One way is to go over each open file/inode and get the address_space pages. Is there a simpler way? Cannot seem to find a big list of cache-pages . I开发者_如何学编程s there any such list/API i can use ?


yes, something like what u said - the address_space pointer is called i_mapping for a inode.

So for example, inside fs/drop_cache.c is a function that enumerate all the pagecache for a superblock:

static void drop_pagecache_sb(struct super_block *sb, void *unused)
{
        struct inode *inode, *toput_inode = NULL;

        spin_lock(&inode_sb_list_lock);
        list_for_each_entry(inode, &sb->s_inodes, i_sb_list) {
                spin_lock(&inode->i_lock);
                if ((inode->i_state & (I_FREEING|I_WILL_FREE|I_NEW)) ||
                    (inode->i_mapping->nrpages == 0)) {
                        spin_unlock(&inode->i_lock);
                        continue;
                }
                __iget(inode);
                spin_unlock(&inode->i_lock);
                spin_unlock(&inode_sb_list_lock);
                invalidate_mapping_pages(inode->i_mapping, 0, -1);
                iput(toput_inode);
                toput_inode = inode;
                spin_lock(&inode_sb_list_lock);
        }
        spin_unlock(&inode_sb_list_lock);
        iput(toput_inode);
}

So instead of calling "invalidate_mapping_pages()" will use the i_mapping pointer to enumerate all the pagecache component.

As for enumerate the blocks, and thus identifying the page's PFN, u can follow this here:

http://www.makelinux.net/books/ulk3/understandlk-CHP-15-SECT-2#understandlk-CHP-15-SECT-2.6

(15.2.6. Searching Blocks in the Page Cache).

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜