CHROMIUM: mm: fix divide error in smaps_account
For swapped out page, its mapcount is zero. Don't divide pss by it
in this case.
BUG=b:135658425
TEST=Built and booted
Change-Id: I9b7b6b9d22055151883d5b8e3c4c4509d0c00bfa
Signed-off-by: Yu Zhao <yuzhao@google.com>
Reviewed-on: https://chromium-review.googlesource.com/1676699
Tested-by: Yu Zhao <yuzhao@chromium.org>
Commit-Ready: Yu Zhao <yuzhao@chromium.org>
Legacy-Commit-Queue: Commit Bot <commit-bot@chromium.org>
Reviewed-by: Yu Zhao <yuzhao@chromium.org>
diff --git a/fs/proc/task_mmu.c b/fs/proc/task_mmu.c
index 9effad2..b0c7afc 100644
--- a/fs/proc/task_mmu.c
+++ b/fs/proc/task_mmu.c
@@ -583,8 +583,12 @@
}
for (i = 0; i < nr; i++, page++) {
int mapcount = page_mapcount(page);
- smaps_page_accumulate(mss, page, PAGE_SIZE, pss / mapcount,
- dirty, locked, mapcount < 2);
+ bool private = mapcount < 2;
+ unsigned long pss = private ? PAGE_SIZE << PSS_SHIFT :
+ (PAGE_SIZE << PSS_SHIFT) / mapcount;
+
+ smaps_page_accumulate(mss, page, PAGE_SIZE, pss,
+ dirty, locked, private);
}
}