首先摘录如下URL对pagemap的描述。
https://www.kernel.org/doc/Documentation/vm/pagemap.txt
* /proc/pid/pagemap. This file lets a userspace process find out which
physical frame each virtual page is mapped to. It contains one 64-bit
value for each virtual page, containing the following data (from
fs/proc/task_mmu.c, above pagemap_read):
* Bits 0-54 page frame number (PFN) if present
* Bits 0-4 swap type if swapped
* Bits 5-54 swap offset if swapped
* Bit 55 pte is soft-dirty (see Documentation/vm/soft-dirty.txt)
* Bits 56-60 zero
* Bit 61 page is file-page or shared-anon
* Bit 62

这篇博客介绍了如何在Linux系统下通过/proc/pid/pagemap文件获取虚拟内存地址对应的物理地址。文章详细解释了pagemap文件的内容结构,并提供了一段C语言代码示例,展示了如何读取并解析pagemap来转换虚拟地址到物理地址。同时提到了在进行转换前检查页面是否在内存中以及防止交换到磁盘的mlock和mlockall函数。
最低0.47元/天 解锁文章
4597

被折叠的 条评论
为什么被折叠?



