Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

proc/smaps: show amount of nonlinear ptes in vma

Currently, nonlinear mappings can not be distinguished from ordinary
mappings. This patch adds into /proc/pid/smaps line "Nonlinear: <size>
kB", where size is amount of nonlinear ptes in vma, this line appears only
if VM_NONLINEAR is set. This information may be useful not only for
checkpoint/restore project.

Requested by Pavel Emelyanov.

Signed-off-by: Konstantin Khlebnikov <khlebnikov@openvz.org>
Cc: Andi Kleen <andi@firstfloor.org>
Cc: Pavel Emelyanov <xemul@parallels.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>

authored by

Konstantin Khlebnikov and committed by
Linus Torvalds
bca15543 b1d4d9e0

+12
+12
fs/proc/task_mmu.c
··· 393 393 unsigned long anonymous; 394 394 unsigned long anonymous_thp; 395 395 unsigned long swap; 396 + unsigned long nonlinear; 396 397 u64 pss; 397 398 }; 398 399 ··· 403 402 { 404 403 struct mem_size_stats *mss = walk->private; 405 404 struct vm_area_struct *vma = mss->vma; 405 + pgoff_t pgoff = linear_page_index(vma, addr); 406 406 struct page *page = NULL; 407 407 int mapcount; 408 408 ··· 416 414 mss->swap += ptent_size; 417 415 else if (is_migration_entry(swpent)) 418 416 page = migration_entry_to_page(swpent); 417 + } else if (pte_file(ptent)) { 418 + if (pte_to_pgoff(ptent) != pgoff) 419 + mss->nonlinear += ptent_size; 419 420 } 420 421 421 422 if (!page) ··· 426 421 427 422 if (PageAnon(page)) 428 423 mss->anonymous += ptent_size; 424 + 425 + if (page->index != pgoff) 426 + mss->nonlinear += ptent_size; 429 427 430 428 mss->resident += ptent_size; 431 429 /* Accumulate the size in pages that have been accessed. */ ··· 530 522 vma_mmu_pagesize(vma) >> 10, 531 523 (vma->vm_flags & VM_LOCKED) ? 532 524 (unsigned long)(mss.pss >> (10 + PSS_SHIFT)) : 0); 525 + 526 + if (vma->vm_flags & VM_NONLINEAR) 527 + seq_printf(m, "Nonlinear: %8lu kB\n", 528 + mss.nonlinear >> 10); 533 529 534 530 if (m->count < m->size) /* vma is copied successfully */ 535 531 m->version = (vma != get_gate_vma(task->mm))