diff options
Diffstat (limited to 'fs/proc/task_mmu.c')
-rw-r--r-- | fs/proc/task_mmu.c | 50 |
1 files changed, 34 insertions, 16 deletions
diff --git a/fs/proc/task_mmu.c b/fs/proc/task_mmu.c index 4206454734e0..9dfb5ff24209 100644 --- a/fs/proc/task_mmu.c +++ b/fs/proc/task_mmu.c | |||
@@ -527,13 +527,21 @@ struct pagemapread { | |||
527 | char __user *out, *end; | 527 | char __user *out, *end; |
528 | }; | 528 | }; |
529 | 529 | ||
530 | #define PM_ENTRY_BYTES sizeof(u64) | 530 | #define PM_ENTRY_BYTES sizeof(u64) |
531 | #define PM_RESERVED_BITS 3 | 531 | #define PM_STATUS_BITS 3 |
532 | #define PM_RESERVED_OFFSET (64 - PM_RESERVED_BITS) | 532 | #define PM_STATUS_OFFSET (64 - PM_STATUS_BITS) |
533 | #define PM_RESERVED_MASK (((1LL<<PM_RESERVED_BITS)-1) << PM_RESERVED_OFFSET) | 533 | #define PM_STATUS_MASK (((1LL << PM_STATUS_BITS) - 1) << PM_STATUS_OFFSET) |
534 | #define PM_SPECIAL(nr) (((nr) << PM_RESERVED_OFFSET) & PM_RESERVED_MASK) | 534 | #define PM_STATUS(nr) (((nr) << PM_STATUS_OFFSET) & PM_STATUS_MASK) |
535 | #define PM_NOT_PRESENT PM_SPECIAL(1LL) | 535 | #define PM_PSHIFT_BITS 6 |
536 | #define PM_SWAP PM_SPECIAL(2LL) | 536 | #define PM_PSHIFT_OFFSET (PM_STATUS_OFFSET - PM_PSHIFT_BITS) |
537 | #define PM_PSHIFT_MASK (((1LL << PM_PSHIFT_BITS) - 1) << PM_PSHIFT_OFFSET) | ||
538 | #define PM_PSHIFT(x) (((u64) (x) << PM_PSHIFT_OFFSET) & PM_PSHIFT_MASK) | ||
539 | #define PM_PFRAME_MASK ((1LL << PM_PSHIFT_OFFSET) - 1) | ||
540 | #define PM_PFRAME(x) ((x) & PM_PFRAME_MASK) | ||
541 | |||
542 | #define PM_PRESENT PM_STATUS(4LL) | ||
543 | #define PM_SWAP PM_STATUS(2LL) | ||
544 | #define PM_NOT_PRESENT PM_PSHIFT(PAGE_SHIFT) | ||
537 | #define PM_END_OF_BUFFER 1 | 545 | #define PM_END_OF_BUFFER 1 |
538 | 546 | ||
539 | static int add_to_pagemap(unsigned long addr, u64 pfn, | 547 | static int add_to_pagemap(unsigned long addr, u64 pfn, |
@@ -574,7 +582,7 @@ static int pagemap_pte_hole(unsigned long start, unsigned long end, | |||
574 | u64 swap_pte_to_pagemap_entry(pte_t pte) | 582 | u64 swap_pte_to_pagemap_entry(pte_t pte) |
575 | { | 583 | { |
576 | swp_entry_t e = pte_to_swp_entry(pte); | 584 | swp_entry_t e = pte_to_swp_entry(pte); |
577 | return PM_SWAP | swp_type(e) | (swp_offset(e) << MAX_SWAPFILES_SHIFT); | 585 | return swp_type(e) | (swp_offset(e) << MAX_SWAPFILES_SHIFT); |
578 | } | 586 | } |
579 | 587 | ||
580 | static int pagemap_pte_range(pmd_t *pmd, unsigned long addr, unsigned long end, | 588 | static int pagemap_pte_range(pmd_t *pmd, unsigned long addr, unsigned long end, |
@@ -588,9 +596,11 @@ static int pagemap_pte_range(pmd_t *pmd, unsigned long addr, unsigned long end, | |||
588 | u64 pfn = PM_NOT_PRESENT; | 596 | u64 pfn = PM_NOT_PRESENT; |
589 | pte = pte_offset_map(pmd, addr); | 597 | pte = pte_offset_map(pmd, addr); |
590 | if (is_swap_pte(*pte)) | 598 | if (is_swap_pte(*pte)) |
591 | pfn = swap_pte_to_pagemap_entry(*pte); | 599 | pfn = PM_PFRAME(swap_pte_to_pagemap_entry(*pte)) |
600 | | PM_PSHIFT(PAGE_SHIFT) | PM_SWAP; | ||
592 | else if (pte_present(*pte)) | 601 | else if (pte_present(*pte)) |
593 | pfn = pte_pfn(*pte); | 602 | pfn = PM_PFRAME(pte_pfn(*pte)) |
603 | | PM_PSHIFT(PAGE_SHIFT) | PM_PRESENT; | ||
594 | /* unmap so we're not in atomic when we copy to userspace */ | 604 | /* unmap so we're not in atomic when we copy to userspace */ |
595 | pte_unmap(pte); | 605 | pte_unmap(pte); |
596 | err = add_to_pagemap(addr, pfn, pm); | 606 | err = add_to_pagemap(addr, pfn, pm); |
@@ -611,12 +621,20 @@ static struct mm_walk pagemap_walk = { | |||
611 | /* | 621 | /* |
612 | * /proc/pid/pagemap - an array mapping virtual pages to pfns | 622 | * /proc/pid/pagemap - an array mapping virtual pages to pfns |
613 | * | 623 | * |
614 | * For each page in the address space, this file contains one 64-bit | 624 | * For each page in the address space, this file contains one 64-bit entry |
615 | * entry representing the corresponding physical page frame number | 625 | * consisting of the following: |
616 | * (PFN) if the page is present. If there is a swap entry for the | 626 | * |
617 | * physical page, then an encoding of the swap file number and the | 627 | * Bits 0-55 page frame number (PFN) if present |
618 | * page's offset into the swap file are returned. If no page is | 628 | * Bits 0-4 swap type if swapped |
619 | * present at all, PM_NOT_PRESENT is returned. This allows determining | 629 | * Bits 5-55 swap offset if swapped |
630 | * Bits 55-60 page shift (page size = 1<<page shift) | ||
631 | * Bit 61 reserved for future use | ||
632 | * Bit 62 page swapped | ||
633 | * Bit 63 page present | ||
634 | * | ||
635 | * If the page is not present but in swap, then the PFN contains an | ||
636 | * encoding of the swap file number and the page's offset into the | ||
637 | * swap. Unmapped pages return a null PFN. This allows determining | ||
620 | * precisely which pages are mapped (or in swap) and comparing mapped | 638 | * precisely which pages are mapped (or in swap) and comparing mapped |
621 | * pages between processes. | 639 | * pages between processes. |
622 | * | 640 | * |