问题描述
我试图解释如何使用/proc/pid/pagemap获取给定页面集的物理地址.假设从/proc/pid/maps获得与堆相对应的虚拟地址afa2d000-afa42000.我的问题是如何使用此信息遍历页面地图文件并找到对应于地址afa2d000-afa42000的物理页面框架.
I am trying to decipher how to use /proc/pid/pagemap to get the physical address of a given set of pages. Suppose from the /proc/pid/maps, I get the virtual address afa2d000-afa42000 which corresponds to the heap. My question is how do I use this info to traverse the pagemap file and find the physical page frames correspond to the address afa2d000-afa42000.
/proc/pid/pagemap条目为二进制格式.有什么工具可以帮助解析此文件?
The /proc/pid/pagemap entry is in binary format. Is there any tools to help parsing of this file?
推荐答案
尝试一下 http://www.eqware.net/Articles/CapturingProcessMemoryUsageUnderLinux/它可以为您解析页面地图,例如,如果虚拟地址您感兴趣的是堆,它是0x055468:= 0004c000-0005a000 rw-p 00000000 00:00 0 [heap]:86000000000FD6D6:0600000000000000
:0600000000000000
:86000000000FE921
:86000000000FE922
:0600000000000000
:86000000000FD5AD
:86000000000FD6D4
:86000000000FD5F8
:86000000000FD5FA =>第9
Try thishttp://www.eqware.net/Articles/CapturingProcessMemoryUsageUnderLinux/It can parse the pagemap for you, for example, if the virtual addressyou are interested is in the heap which is 0x055468 := 0004c000-0005a000 rw-p 00000000 00:00 0 [heap]: 86000000000FD6D6: 0600000000000000
: 0600000000000000
: 86000000000FE921
: 86000000000FE922
: 0600000000000000
: 86000000000FD5AD
: 86000000000FD6D4
: 86000000000FD5F8
: 86000000000FD5FA =>9th
假设页面大小为4KB,并且(0x055468-0x4c000)mod 4K = 9,因此,您页面的页面框架号是第9个页面框架 ==>:86000000000FD5FA因此物理pfn为0xFD5FA000(取最后55位乘以页面大小)加上偏移量:(0x055468-0x4c000-9 * 4K)= 0x468==>物理地址为0xFD5FA000 + 0x468 = 0xFD5FA468
Suppose the page size as 4KB, and(0x055468 - 0x4c000) mod 4K = 9,So the page frame number of your page is the 9th page frames ==> : 86000000000FD5FASo the physical pfn is 0xFD5FA000 (take the last 55 bits and times page size)plus the offset: ( 0x055468 - 0x4c000 - 9*4K) = 0x468==> the physical addr is 0xFD5FA000 + 0x468 = 0xFD5FA468
这篇关于如何在Linux中解码/proc/pid/pagemap条目?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!