diff options
| author | Konstantin Khlebnikov <khlebnikov@openvz.org> | 2012-05-31 19:26:20 -0400 |
|---|---|---|
| committer | Linus Torvalds <torvalds@linux-foundation.org> | 2012-05-31 20:49:29 -0400 |
| commit | bca15543736f9be6d84e0bbc262ea7069076b9e6 (patch) | |
| tree | dbca9451c0478011b51a623b32f3b04305e75212 | |
| parent | b1d4d9e0cbd0aecf40c3572e0c8f98de31b3b328 (diff) | |
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>
| -rw-r--r-- | fs/proc/task_mmu.c | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/fs/proc/task_mmu.c b/fs/proc/task_mmu.c index e2c1155ac09a..4540b8f76f16 100644 --- a/fs/proc/task_mmu.c +++ b/fs/proc/task_mmu.c | |||
| @@ -393,6 +393,7 @@ struct mem_size_stats { | |||
| 393 | unsigned long anonymous; | 393 | unsigned long anonymous; |
| 394 | unsigned long anonymous_thp; | 394 | unsigned long anonymous_thp; |
| 395 | unsigned long swap; | 395 | unsigned long swap; |
| 396 | unsigned long nonlinear; | ||
| 396 | u64 pss; | 397 | u64 pss; |
| 397 | }; | 398 | }; |
| 398 | 399 | ||
| @@ -402,6 +403,7 @@ static void smaps_pte_entry(pte_t ptent, unsigned long addr, | |||
| 402 | { | 403 | { |
| 403 | struct mem_size_stats *mss = walk->private; | 404 | struct mem_size_stats *mss = walk->private; |
| 404 | struct vm_area_struct *vma = mss->vma; | 405 | struct vm_area_struct *vma = mss->vma; |
| 406 | pgoff_t pgoff = linear_page_index(vma, addr); | ||
| 405 | struct page *page = NULL; | 407 | struct page *page = NULL; |
| 406 | int mapcount; | 408 | int mapcount; |
| 407 | 409 | ||
| @@ -414,6 +416,9 @@ static void smaps_pte_entry(pte_t ptent, unsigned long addr, | |||
| 414 | mss->swap += ptent_size; | 416 | mss->swap += ptent_size; |
| 415 | else if (is_migration_entry(swpent)) | 417 | else if (is_migration_entry(swpent)) |
| 416 | page = migration_entry_to_page(swpent); | 418 | page = migration_entry_to_page(swpent); |
| 419 | } else if (pte_file(ptent)) { | ||
| 420 | if (pte_to_pgoff(ptent) != pgoff) | ||
| 421 | mss->nonlinear += ptent_size; | ||
| 417 | } | 422 | } |
| 418 | 423 | ||
| 419 | if (!page) | 424 | if (!page) |
| @@ -422,6 +427,9 @@ static void smaps_pte_entry(pte_t ptent, unsigned long addr, | |||
| 422 | if (PageAnon(page)) | 427 | if (PageAnon(page)) |
| 423 | mss->anonymous += ptent_size; | 428 | mss->anonymous += ptent_size; |
| 424 | 429 | ||
| 430 | if (page->index != pgoff) | ||
| 431 | mss->nonlinear += ptent_size; | ||
| 432 | |||
| 425 | mss->resident += ptent_size; | 433 | mss->resident += ptent_size; |
| 426 | /* Accumulate the size in pages that have been accessed. */ | 434 | /* Accumulate the size in pages that have been accessed. */ |
| 427 | if (pte_young(ptent) || PageReferenced(page)) | 435 | if (pte_young(ptent) || PageReferenced(page)) |
| @@ -523,6 +531,10 @@ static int show_smap(struct seq_file *m, void *v, int is_pid) | |||
| 523 | (vma->vm_flags & VM_LOCKED) ? | 531 | (vma->vm_flags & VM_LOCKED) ? |
| 524 | (unsigned long)(mss.pss >> (10 + PSS_SHIFT)) : 0); | 532 | (unsigned long)(mss.pss >> (10 + PSS_SHIFT)) : 0); |
| 525 | 533 | ||
| 534 | if (vma->vm_flags & VM_NONLINEAR) | ||
| 535 | seq_printf(m, "Nonlinear: %8lu kB\n", | ||
| 536 | mss.nonlinear >> 10); | ||
| 537 | |||
| 526 | if (m->count < m->size) /* vma is copied successfully */ | 538 | if (m->count < m->size) /* vma is copied successfully */ |
| 527 | m->version = (vma != get_gate_vma(task->mm)) | 539 | m->version = (vma != get_gate_vma(task->mm)) |
| 528 | ? vma->vm_start : 0; | 540 | ? vma->vm_start : 0; |
