Skip to content

Commit 6d065f5

Browse files
Yuanyuan Zhongakpm00
Yuanyuan Zhong
authored andcommitted
mm: /proc/pid/smaps_rollup: avoid skipping vma after getting mmap_lock 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]>
1 parent eb85dac commit 6d065f5

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

fs/proc/task_mmu.c

+7-2
Original file line numberDiff line numberDiff line change
@@ -970,12 +970,17 @@ static int show_smaps_rollup(struct seq_file *m, void *v)
970970
break;
971971

972972
/* Case 1 and 2 above */
973-
if (vma->vm_start >= last_vma_end)
973+
if (vma->vm_start >= last_vma_end) {
974+
smap_gather_stats(vma, &mss, 0);
975+
last_vma_end = vma->vm_end;
974976
continue;
977+
}
975978

976979
/* Case 4 above */
977-
if (vma->vm_end > last_vma_end)
980+
if (vma->vm_end > last_vma_end) {
978981
smap_gather_stats(vma, &mss, last_vma_end);
982+
last_vma_end = vma->vm_end;
983+
}
979984
}
980985
} for_each_vma(vmi, vma);
981986

0 commit comments

Comments
 (0)