linux-fsdevel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] mm: proc: smaps_rollup: Fix pss_locked calculation
@ 2019-01-21  1:10 Sandeep Patil
       [not found] ` <20190123225746.5B3DF218A4@mail.kernel.org>
  2019-01-29  0:15 ` Andrew Morton
  0 siblings, 2 replies; 6+ messages in thread
From: Sandeep Patil @ 2019-01-21  1:10 UTC (permalink / raw)
  To: vbabka, adobriyan, akpm, avagin
  Cc: linux-fsdevel, linux-mm, linux-kernel, stable, kernel-team, dancol

The 'pss_locked' field of smaps_rollup was being calculated incorrectly
as it accumulated the current pss everytime a locked VMA was found.

Fix that by making sure we record the current pss value before each VMA
is walked. So, we can only add the delta if the VMA was found to be
VM_LOCKED.

Fixes: 493b0e9d945f ("mm: add /proc/pid/smaps_rollup")
Cc: stable@vger.kernel.org # 4.14.y 4.19.y
Signed-off-by: Sandeep Patil <sspatil@android.com>
---
 fs/proc/task_mmu.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/fs/proc/task_mmu.c b/fs/proc/task_mmu.c
index f0ec9edab2f3..51a00a2b4733 100644
--- a/fs/proc/task_mmu.c
+++ b/fs/proc/task_mmu.c
@@ -709,6 +709,7 @@ static void smap_gather_stats(struct vm_area_struct *vma,
 #endif
 		.mm = vma->vm_mm,
 	};
+	unsigned long pss;
 
 	smaps_walk.private = mss;
 
@@ -737,11 +738,12 @@ static void smap_gather_stats(struct vm_area_struct *vma,
 		}
 	}
 #endif
-
+	/* record current pss so we can calculate the delta after page walk */
+	pss = mss->pss;
 	/* mmap_sem is held in m_start */
 	walk_page_vma(vma, &smaps_walk);
 	if (vma->vm_flags & VM_LOCKED)
-		mss->pss_locked += mss->pss;
+		mss->pss_locked += mss->pss - pss;
 }
 
 #define SEQ_PUT_DEC(str, val) \
-- 
2.20.1.321.g9e740568ce-goog


^ permalink raw reply related	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2019-02-03  6:21 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-01-21  1:10 [PATCH] mm: proc: smaps_rollup: Fix pss_locked calculation Sandeep Patil
     [not found] ` <20190123225746.5B3DF218A4@mail.kernel.org>
2019-01-24 21:39   ` Sandeep Patil
2019-01-25  6:21     ` Greg KH
2019-01-29  0:15 ` Andrew Morton
2019-01-29 15:52   ` Vlastimil Babka
2019-02-03  6:21     ` Sandeep Patil

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).