proc:pagemap_file
Differences
This shows you the differences between two versions of the page.
Next revision | Previous revision | ||
proc:pagemap_file [2017/04/05 10:18] – created peter | proc:pagemap_file [2020/07/15 09:30] (current) – external edit 127.0.0.1 | ||
---|---|---|---|
Line 1: | Line 1: | ||
====== Proc - pagemap file ====== | ====== Proc - pagemap file ====== | ||
- | The **/ | + | The **/ |
- | + | ||
- | For detailed explanation, | + | |
Line 10: | Line 8: | ||
There are three components to pagemap: | There are three components to pagemap: | ||
- | * / | ||
- | * Bits 0-54 page frame number (PFN) if present | + | ===== / |
- | * Bits 0-4 swap type if swapped | + | |
- | * Bits 5-54 swap offset if swapped | + | |
- | * Bits 55-60 page shift (page size = 1<< | + | |
- | * Bit 61 reserved for future use | + | |
- | * Bit 62 page swapped | + | |
- | * Bit 63 page present | + | |
- | If the page is not present but in swap, then the PFN contains | + | This file lets a userspace process find out which physical frame each virtual |
- | | + | ^Bits^Description^ |
+ | |0-54|Page frame number (PFN) if present.| | ||
+ | |0-4|Swap type if swapped.| | ||
+ | |5-54|Swap offset if swapped.| | ||
+ | |55-60|Page shift (page size = 1<< | ||
+ | |61|Reserved for future | ||
+ | |62|Page swapped.| | ||
+ | |63|Page present.| | ||
- | * / | + | If the page is not present but in swap, then the PFN contains |
- | | + | Efficient users of this interface will use [[Proc:maps file|/proc/pid/maps]] to determine which areas of memory are actually mapped and llseek to skip over unmapped regions. |
- | The flags are (from fs/ | ||
- | 0. LOCKED | + | ===== / |
- | 1. ERROR | + | |
- | 2. REFERENCED | + | |
- | 3. UPTODATE | + | |
- | 4. DIRTY | + | |
- | 5. LRU | + | |
- | 6. ACTIVE | + | |
- | 7. SLAB | + | |
- | 8. WRITEBACK | + | |
- | 9. RECLAIM | + | |
- | 10. BUDDY | + | |
- | 11. MMAP | + | |
- | 12. ANON | + | |
- | 13. SWAPCACHE | + | |
- | 14. SWAPBACKED | + | |
- | 15. COMPOUND_HEAD | + | |
- | 16. COMPOUND_TAIL | + | |
- | 16. HUGE | + | |
- | 18. UNEVICTABLE | + | |
- | 19. HWPOISON | + | |
- | 20. NOPAGE | + | |
- | 21. KSM | + | |
- | Short descriptions to the page flags: | + | This file contains a 64-bit count of the number of times each page is mapped, indexed by PFN. |
- | 0. LOCKED | ||
- | page is being locked for exclusive access, eg. by undergoing read/write IO | ||
- | 7. SLAB | + | ===== /proc/kpageflags ===== |
- | page is managed by the SLAB/SLOB/SLUB/SLQB kernel memory allocator | + | |
- | When compound page is used, SLUB/SLQB will only set this flag on the head | + | |
- | page; SLOB will not flag it at all. | + | |
- | 10. BUDDY | + | This file contains |
- | | + | |
- | The buddy system organizes free memory in blocks of various orders. | + | |
- | An order N block has 2^N physically contiguous pages, with the BUDDY flag | + | |
- | | + | |
- | 15. COMPOUND_HEAD | + | ^ No. ^ Name ^ Description |
- | 16. COMPOUND_TAIL | + | | 0 | LOCKED |
- | A compound page with order N consists of 2^N physically contiguous pages. | + | | 1 | ERROR | IO error occurred. |
- | | + | | 2 | REFERENCED |
- | | + | | 3 | UPTODATE |
- | | + | | 4 | DIRTY | Page has been written to, hence contains new data. i.e. for file backed page: (in-memory data revision > on-disk one). | |
- | memory | + | | 5 | LRU | Page is in one of the LRU lists. |
- | | + | | 6 | ACTIVE |
- | 17. HUGE | + | | 7 | SLAB | Page is managed by the SLAB/ |
- | this is an integral part of a HugeTLB | + | | 8 | WRITEBACK |
+ | | 9 | RECLAIM | ||
+ | | 10 | BUDDY | A free memory block managed by the buddy system allocator. The buddy system organizes free memory in blocks of various orders. | ||
+ | | 11 | MMAP | A memory mapped page. | | ||
+ | | 12 | ANON | A memory mapped page that is not part of a file. | | ||
+ | | 13 | SWAPCACHE | ||
+ | | 14 | SWAPBACKED | ||
+ | | 15 | COMPOUND_HEAD | ||
+ | | 16 | COMPOUND_TAIL | ||
+ | | 17 | HUGE | This is an integral part of a [[Kernel: | ||
+ | | 18 | UNEVICTABLE | ||
+ | | 19 | HWPOISON | ||
+ | | 20 | NOPAGE | ||
+ | | 21 | KSM | Identical memory pages dynamically shared between one or more processes. | ||
- | 19. HWPOISON | ||
- | hardware detected memory corruption on this page: don't touch the data! | ||
- | 20. NOPAGE | + | The **page-types** tool in this directory can be used to query the above flags. |
- | no page frame exists at the requested address | + | |
- | + | ||
- | 21. KSM | + | |
- | identical memory pages dynamically shared between one or more processes | + | |
- | + | ||
- | [IO related page flags] | + | |
- | 1. ERROR IO error occurred | + | |
- | 3. UPTODATE | + | |
- | ie. for file backed page: (in-memory data revision >= on-disk one) | + | |
- | 4. DIRTY page has been written to, hence contains new data | + | |
- | ie. for file backed page: (in-memory data revision > on-disk one) | + | |
- | 8. WRITEBACK page is being synced to disk | + | |
- | + | ||
- | [LRU related page flags] | + | |
- | 5. LRU page is in one of the LRU lists | + | |
- | 6. ACTIVE | + | |
- | 18. UNEVICTABLE page is in the unevictable (non-)LRU list | + | |
- | It is somehow pinned and not a candidate for LRU page reclaims, | + | |
- | eg. ramfs pages, shmctl(SHM_LOCK) and mlock() memory segments | + | |
- | 2. REFERENCED | + | |
- | 9. RECLAIM | + | |
- | 11. MMAP a memory mapped page | + | |
- | 12. ANON a memory mapped page that is not part of a file | + | |
- | 13. SWAPCACHE | + | |
- | 14. SWAPBACKED | + | |
- | + | ||
- | The page-types tool in this directory can be used to query the above flags. | + | |
Using pagemap to do something useful: | Using pagemap to do something useful: | ||
- | The general procedure for using pagemap to find out about a process' | + | The general procedure for using pagemap to find out about a process' |
- | usage goes like this: | + | |
- | + | ||
- | 1. Read / | + | |
- | mapped to what. | + | |
- | 2. Select the maps you are interested in -- all of them, or a particular | + | |
- | library, or the stack or the heap, etc. | + | |
- | 3. Open / | + | |
- | 4. Read a u64 for each page from pagemap. | + | |
- | 5. Open / | + | |
- | read, seek to that entry in the file, and read the data you want. | + | |
- | For example, | + | - Read / |
- | memory | + | - Select the maps you are interested |
- | you can go through every map in the process, find the PFNs, look those up | + | - Open / |
- | in kpagecount, | + | - Read a u64 for each page from pagemap. |
- | once. | + | - Open / |
- | Other notes: | + | For example, to find the " |
- | Reading from any of the files will return -EINVAL if you are not starting | + | <WRAP info> |
- | the read on an 8-byte boundary (e.g., if you seeked an odd number of bytes | + | **NOTE: |
- | into the file), or if the size of the read is not a multiple of 8 bytes. | + | </ |
proc/pagemap_file.1491387526.txt.gz · Last modified: 2020/07/15 09:30 (external edit)