如何在Linux中操纵页面缓存? [英] How to manipulate page cache in Linux?

查看:235
本文介绍了如何在Linux中操纵页面缓存?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想知道页面缓存中缓存了哪些文件,并希望实用地释放特定文件的缓存空间.如果需要,我可以编写内核模块,甚至修改内核代码.谁能给我一些线索?

I want to know what files are cached in Page Cache, and want to free the cache space of a specific file pragmatically. It is possible for me to write kernel module or even modify the kernel code if needed. Can anyone give me some clues?

推荐答案

首先,内核不维护页面缓存中所有文件的主列表,因为它不需要此类信息.相反,给定一个inode,您可以查找关联的页面缓存页面,反之亦然.

Firstly, the kernel does not maintain a master list of all files in the page cache, because it has no need for such information. Instead, given an inode you can look up the associated page cache pages, and vice-versa.

对于每个页面缓存struct pagepage_mapping()将返回其所属的struct address_space. struct address_spacehost成员标识拥有的struct inode,然后您可以从中获取inode编号和设备.

For each page cache struct page, page_mapping() will return the struct address_space that it belongs to. The host member of struct address_space identifies the owning struct inode, and from there you can get the inode number and device.

这篇关于如何在Linux中操纵页面缓存?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆