Skip to content

Commit

Permalink
mm: /proc/pid/smaps_rollup: avoid skipping vma after getting mmap_loc…
Browse files Browse the repository at this point in the history
…k again

After switching smaps_rollup to use VMA iterator, searching for next entry
is part of the condition expression of the do-while loop.  So the current
VMA needs to be addressed before the continue statement.

Otherwise, with some VMAs skipped, userspace observed memory
consumption from /proc/pid/smaps_rollup will be smaller than the sum of
the corresponding fields from /proc/pid/smaps.

Link: https://lkml.kernel.org/r/[email protected]
Fixes: c4c84f0 ("fs/proc/task_mmu: stop using linked list and highest_vm_end")
Signed-off-by: Yuanyuan Zhong <[email protected]>
Reviewed-by: Mohamed Khalfella <[email protected]>
Cc: David Hildenbrand <[email protected]>
Cc: Matthew Wilcox (Oracle) <[email protected]>
Cc: <[email protected]>
Signed-off-by: Andrew Morton <[email protected]>
  • Loading branch information
Yuanyuan Zhong authored and akpm00 committed May 24, 2024
1 parent eb85dac commit 6d065f5
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions fs/proc/task_mmu.c
Original file line number Diff line number Diff line change
Expand Up @@ -970,12 +970,17 @@ static int show_smaps_rollup(struct seq_file *m, void *v)
break;

/* Case 1 and 2 above */
if (vma->vm_start >= last_vma_end)
if (vma->vm_start >= last_vma_end) {
smap_gather_stats(vma, &mss, 0);
last_vma_end = vma->vm_end;
continue;
}

/* Case 4 above */
if (vma->vm_end > last_vma_end)
if (vma->vm_end > last_vma_end) {
smap_gather_stats(vma, &mss, last_vma_end);
last_vma_end = vma->vm_end;
}
}
} for_each_vma(vmi, vma);

Expand Down

0 comments on commit 6d065f5

Please sign in to comment.