Skip to content

Commit bca1554

Browse files
koct9itorvalds
authored andcommitted
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>
1 parent b1d4d9e commit bca1554

1 file changed

Lines changed: 12 additions & 0 deletions

File tree

‎fs/proc/task_mmu.c‎

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -393,6 +393,7 @@ struct mem_size_stats {
393393
unsigned long anonymous;
394394
unsigned long anonymous_thp;
395395
unsigned long swap;
396+
unsigned long nonlinear;
396397
u64 pss;
397398
};
398399

@@ -402,6 +403,7 @@ static void smaps_pte_entry(pte_t ptent, unsigned long addr,
402403
{
403404
struct mem_size_stats *mss = walk->private;
404405
struct vm_area_struct *vma = mss->vma;
406+
pgoff_t pgoff = linear_page_index(vma, addr);
405407
struct page *page = NULL;
406408
int mapcount;
407409

@@ -414,6 +416,9 @@ static void smaps_pte_entry(pte_t ptent, unsigned long addr,
414416
mss->swap += ptent_size;
415417
else if (is_migration_entry(swpent))
416418
page = migration_entry_to_page(swpent);
419+
} else if (pte_file(ptent)) {
420+
if (pte_to_pgoff(ptent) != pgoff)
421+
mss->nonlinear += ptent_size;
417422
}
418423

419424
if (!page)
@@ -422,6 +427,9 @@ static void smaps_pte_entry(pte_t ptent, unsigned long addr,
422427
if (PageAnon(page))
423428
mss->anonymous += ptent_size;
424429

430+
if (page->index != pgoff)
431+
mss->nonlinear += ptent_size;
432+
425433
mss->resident += ptent_size;
426434
/* Accumulate the size in pages that have been accessed. */
427435
if (pte_young(ptent) || PageReferenced(page))
@@ -523,6 +531,10 @@ static int show_smap(struct seq_file *m, void *v, int is_pid)
523531
(vma->vm_flags & VM_LOCKED) ?
524532
(unsigned long)(mss.pss >> (10 + PSS_SHIFT)) : 0);
525533

534+
if (vma->vm_flags & VM_NONLINEAR)
535+
seq_printf(m, "Nonlinear: %8lu kB\n",
536+
mss.nonlinear >> 10);
537+
526538
if (m->count < m->size) /* vma is copied successfully */
527539
m->version = (vma != get_gate_vma(task->mm))
528540
? vma->vm_start : 0;

0 commit comments

Comments
 (0)