diff options
| author | Huang Ying <ying.huang@intel.com> | 2018-04-20 17:55:38 -0400 |
|---|---|---|
| committer | Linus Torvalds <torvalds@linux-foundation.org> | 2018-04-20 20:18:35 -0400 |
| commit | 88c28f2469151b031f8cea9b28ed5be1b74a4172 (patch) | |
| tree | 267a1a70a86b441e1a7131996c0447acb5b8198e /fs | |
| parent | 8f175cf5c99dc0e3add2aac0ea1cd54e0f9ca87d (diff) | |
mm, pagemap: fix swap offset value for PMD migration entry
The swap offset reported by /proc/<pid>/pagemap may be not correct for
PMD migration entries. If addr passed into pagemap_pmd_range() isn't
aligned with PMD start address, the swap offset reported doesn't
reflect this. And in the loop to report information of each sub-page,
the swap offset isn't increased accordingly as that for PFN.
This may happen after opening /proc/<pid>/pagemap and seeking to a page
whose address doesn't align with a PMD start address. I have verified
this with a simple test program.
BTW: migration swap entries have PFN information, do we need to restrict
whether to show them?
[akpm@linux-foundation.org: fix typo, per Huang, Ying]
Link: http://lkml.kernel.org/r/20180408033737.10897-1-ying.huang@intel.com
Signed-off-by: "Huang, Ying" <ying.huang@intel.com>
Cc: Michal Hocko <mhocko@suse.com>
Cc: "Kirill A. Shutemov" <kirill.shutemov@linux.intel.com>
Cc: Andrei Vagin <avagin@openvz.org>
Cc: Dan Williams <dan.j.williams@intel.com>
Cc: "Jerome Glisse" <jglisse@redhat.com>
Cc: Daniel Colascione <dancol@google.com>
Cc: Zi Yan <zi.yan@cs.rutgers.edu>
Cc: Naoya Horiguchi <n-horiguchi@ah.jp.nec.com>
Cc: Alexey Dobriyan <adobriyan@gmail.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to 'fs')
| -rw-r--r-- | fs/proc/task_mmu.c | 6 |
1 files changed, 5 insertions, 1 deletions
diff --git a/fs/proc/task_mmu.c b/fs/proc/task_mmu.c index 65ae54659833..c486ad4b43f0 100644 --- a/fs/proc/task_mmu.c +++ b/fs/proc/task_mmu.c | |||
| @@ -1310,9 +1310,11 @@ static int pagemap_pmd_range(pmd_t *pmdp, unsigned long addr, unsigned long end, | |||
| 1310 | #ifdef CONFIG_ARCH_ENABLE_THP_MIGRATION | 1310 | #ifdef CONFIG_ARCH_ENABLE_THP_MIGRATION |
| 1311 | else if (is_swap_pmd(pmd)) { | 1311 | else if (is_swap_pmd(pmd)) { |
| 1312 | swp_entry_t entry = pmd_to_swp_entry(pmd); | 1312 | swp_entry_t entry = pmd_to_swp_entry(pmd); |
| 1313 | unsigned long offset = swp_offset(entry); | ||
| 1313 | 1314 | ||
| 1315 | offset += (addr & ~PMD_MASK) >> PAGE_SHIFT; | ||
| 1314 | frame = swp_type(entry) | | 1316 | frame = swp_type(entry) | |
| 1315 | (swp_offset(entry) << MAX_SWAPFILES_SHIFT); | 1317 | (offset << MAX_SWAPFILES_SHIFT); |
| 1316 | flags |= PM_SWAP; | 1318 | flags |= PM_SWAP; |
| 1317 | if (pmd_swp_soft_dirty(pmd)) | 1319 | if (pmd_swp_soft_dirty(pmd)) |
| 1318 | flags |= PM_SOFT_DIRTY; | 1320 | flags |= PM_SOFT_DIRTY; |
| @@ -1332,6 +1334,8 @@ static int pagemap_pmd_range(pmd_t *pmdp, unsigned long addr, unsigned long end, | |||
| 1332 | break; | 1334 | break; |
| 1333 | if (pm->show_pfn && (flags & PM_PRESENT)) | 1335 | if (pm->show_pfn && (flags & PM_PRESENT)) |
| 1334 | frame++; | 1336 | frame++; |
| 1337 | else if (flags & PM_SWAP) | ||
| 1338 | frame += (1 << MAX_SWAPFILES_SHIFT); | ||
| 1335 | } | 1339 | } |
| 1336 | spin_unlock(ptl); | 1340 | spin_unlock(ptl); |
| 1337 | return err; | 1341 | return err; |
