How to decode /proc/pid/pagemap entries in Linux?

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.

The /proc/pid/pagemap entry is in binary format. Is there any tools to help parsing of this file?


  • Try this It can parse the pagemap for you, for example, if the virtual address you 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

    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 ==> : 86000000000FD5FA So 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