Skip to content

Commit b1d4d9e

Browse files
koct9itorvalds
authored andcommitted
proc/smaps: carefully handle migration entries
Currently smaps reports migration entries as "swap", as result "swap" can appears in shared mapping. This patch converts migration entries into pages and handles them as usual. Signed-off-by: Konstantin Khlebnikov <[email protected]> Cc: Andi Kleen <[email protected]> Cc: Pavel Emelyanov <[email protected]> Cc: Alexey Dobriyan <[email protected]> Signed-off-by: Andrew Morton <[email protected]> Signed-off-by: Linus Torvalds <[email protected]>
1 parent 052fb0d commit b1d4d9e

File tree

1 file changed

+10
-8
lines changed

1 file changed

+10
-8
lines changed

fs/proc/task_mmu.c

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -402,18 +402,20 @@ static void smaps_pte_entry(pte_t ptent, unsigned long addr,
402402
{
403403
struct mem_size_stats *mss = walk->private;
404404
struct vm_area_struct *vma = mss->vma;
405-
struct page *page;
405+
struct page *page = NULL;
406406
int mapcount;
407407

408-
if (is_swap_pte(ptent)) {
409-
mss->swap += ptent_size;
410-
return;
411-
}
408+
if (pte_present(ptent)) {
409+
page = vm_normal_page(vma, addr, ptent);
410+
} else if (is_swap_pte(ptent)) {
411+
swp_entry_t swpent = pte_to_swp_entry(ptent);
412412

413-
if (!pte_present(ptent))
414-
return;
413+
if (!non_swap_entry(swpent))
414+
mss->swap += ptent_size;
415+
else if (is_migration_entry(swpent))
416+
page = migration_entry_to_page(swpent);
417+
}
415418

416-
page = vm_normal_page(vma, addr, ptent);
417419
if (!page)
418420
return;
419421

0 commit comments

Comments
 (0)