* [PATCH] mm: /proc/pid/smaps_rollup: avoid skipping vma after getting mmap_lock again
@ 2024-05-23 18:35 Yuanyuan Zhong
2024-05-23 18:56 ` Andrew Morton
2024-05-27 7:33 ` David Hildenbrand
0 siblings, 2 replies; 5+ messages in thread
From: Yuanyuan Zhong @ 2024-05-23 18:35 UTC (permalink / raw)
To: Andrew Morton, David Hildenbrand, Matthew Wilcox
Cc: linux-kernel, linux-fsdevel, Yuanyuan Zhong, Mohamed Khalfella
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.
Fixes: c4c84f06285e ("fs/proc/task_mmu: stop using linked list and highest_vm_end")
Signed-off-by: Yuanyuan Zhong <yzhong@purestorage.com>
Reviewed-by: Mohamed Khalfella <mkhalfella@purestorage.com>
---
fs/proc/task_mmu.c | 9 +++++++--
1 file changed, 7 insertions(+), 2 deletions(-)
diff --git a/fs/proc/task_mmu.c b/fs/proc/task_mmu.c
index e5a5f015ff03..f8d35f993fe5 100644
--- a/fs/proc/task_mmu.c
+++ b/fs/proc/task_mmu.c
@@ -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);
--
2.34.1
^ permalink raw reply related [flat|nested] 5+ messages in thread* Re: [PATCH] mm: /proc/pid/smaps_rollup: avoid skipping vma after getting mmap_lock again
2024-05-23 18:35 [PATCH] mm: /proc/pid/smaps_rollup: avoid skipping vma after getting mmap_lock again Yuanyuan Zhong
@ 2024-05-23 18:56 ` Andrew Morton
2024-05-23 19:16 ` Yuanyuan Zhong
2024-05-27 7:33 ` David Hildenbrand
1 sibling, 1 reply; 5+ messages in thread
From: Andrew Morton @ 2024-05-23 18:56 UTC (permalink / raw)
To: Yuanyuan Zhong
Cc: David Hildenbrand, Matthew Wilcox, linux-kernel, linux-fsdevel,
Mohamed Khalfella
On Thu, 23 May 2024 12:35:31 -0600 Yuanyuan Zhong <yzhong@purestorage.com> wrote:
> 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.
Please describe the userspace-visible runtime effects of this bug.
This aids others in deciding which kernel version(s) need the patch.
Thanks.
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH] mm: /proc/pid/smaps_rollup: avoid skipping vma after getting mmap_lock again
2024-05-23 18:56 ` Andrew Morton
@ 2024-05-23 19:16 ` Yuanyuan Zhong
2024-05-24 3:02 ` Andrew Morton
0 siblings, 1 reply; 5+ messages in thread
From: Yuanyuan Zhong @ 2024-05-23 19:16 UTC (permalink / raw)
To: Andrew Morton
Cc: David Hildenbrand, Matthew Wilcox, linux-kernel, linux-fsdevel,
Mohamed Khalfella
On Thu, May 23, 2024 at 11:56 AM Andrew Morton
<akpm@linux-foundation.org> wrote:
>
> Please describe the userspace-visible runtime effects of this bug.
> This aids others in deciding which kernel version(s) need the patch.
>
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.
Please let me know if separate v2 is needed. Thanks
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH] mm: /proc/pid/smaps_rollup: avoid skipping vma after getting mmap_lock again
2024-05-23 19:16 ` Yuanyuan Zhong
@ 2024-05-24 3:02 ` Andrew Morton
0 siblings, 0 replies; 5+ messages in thread
From: Andrew Morton @ 2024-05-24 3:02 UTC (permalink / raw)
To: Yuanyuan Zhong
Cc: David Hildenbrand, Matthew Wilcox, linux-kernel, linux-fsdevel,
Mohamed Khalfella
On Thu, 23 May 2024 12:16:57 -0700 Yuanyuan Zhong <yzhong@purestorage.com> wrote:
> On Thu, May 23, 2024 at 11:56 AM Andrew Morton
> <akpm@linux-foundation.org> wrote:
> >
> > Please describe the userspace-visible runtime effects of this bug.
> > This aids others in deciding which kernel version(s) need the patch.
> >
> 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.
>
> Please let me know if separate v2 is needed. Thanks
All is good, thanks. I added the above text and the cc:stable tag.
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH] mm: /proc/pid/smaps_rollup: avoid skipping vma after getting mmap_lock again
2024-05-23 18:35 [PATCH] mm: /proc/pid/smaps_rollup: avoid skipping vma after getting mmap_lock again Yuanyuan Zhong
2024-05-23 18:56 ` Andrew Morton
@ 2024-05-27 7:33 ` David Hildenbrand
1 sibling, 0 replies; 5+ messages in thread
From: David Hildenbrand @ 2024-05-27 7:33 UTC (permalink / raw)
To: Yuanyuan Zhong, Andrew Morton, Matthew Wilcox
Cc: linux-kernel, linux-fsdevel, Mohamed Khalfella
Am 23.05.24 um 20:35 schrieb Yuanyuan Zhong:
> 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.
>
> Fixes: c4c84f06285e ("fs/proc/task_mmu: stop using linked list and highest_vm_end")
> Signed-off-by: Yuanyuan Zhong <yzhong@purestorage.com>
> Reviewed-by: Mohamed Khalfella <mkhalfella@purestorage.com>
> ---
> fs/proc/task_mmu.c | 9 +++++++--
> 1 file changed, 7 insertions(+), 2 deletions(-)
>
> diff --git a/fs/proc/task_mmu.c b/fs/proc/task_mmu.c
> index e5a5f015ff03..f8d35f993fe5 100644
> --- a/fs/proc/task_mmu.c
> +++ b/fs/proc/task_mmu.c
> @@ -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);
>
Looks correct to me. I guess getting a reproducer is rather tricky.
Acked-by: David Hildenbrand <david@redhat.com>
--
Thanks,
David / dhildenb
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2024-05-27 7:33 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-05-23 18:35 [PATCH] mm: /proc/pid/smaps_rollup: avoid skipping vma after getting mmap_lock again Yuanyuan Zhong
2024-05-23 18:56 ` Andrew Morton
2024-05-23 19:16 ` Yuanyuan Zhong
2024-05-24 3:02 ` Andrew Morton
2024-05-27 7:33 ` David Hildenbrand
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox