Add swapPSS support to showmap
The swap column in showmap is sometimes misleading since it is total
swap and not proportional. Shared dirty RAM is often shared swap with
the zygote and other processes.
Added a swapPSS column to the showmap output that shows the swapPss
which is proportional swap usage (from smaps).
Test: looked at showmap for a device that is swapping
Bug: 36457259
(cherry picked from commit 737412d6d59bdf5caee3504426019b95b2cf1a83)
Change-Id: I8ffdbcea325016e0cbb967fc5c425ec0ac5dda59
diff --git a/showmap/showmap.cpp b/showmap/showmap.cpp
index 6efe260..6f16b49 100644
--- a/showmap/showmap.cpp
+++ b/showmap/showmap.cpp
@@ -20,6 +20,7 @@
unsigned private_clean;
unsigned private_dirty;
unsigned swap;
+ unsigned swap_pss;
int is_bss;
int count;
char name[1];
@@ -111,6 +112,8 @@
mi->private_dirty = size;
} else if (!strcmp(field, "Swap:")) {
mi->swap = size;
+ } else if (!strcmp(field, "SwapPss:")) {
+ mi->swap_pss = size;
}
}
return 0;
@@ -145,6 +148,7 @@
current->private_clean += map->private_clean;
current->private_dirty += map->private_dirty;
current->swap += map->swap;
+ current->swap_pss += map->swap_pss;
current->is_bss &= map->is_bss;
current->count++;
free(map);
@@ -220,7 +224,7 @@
const char *addr2 = addresses ? " addr addr " : "";
printf("%s virtual shared shared private private\n", addr1);
- printf("%s size RSS PSS clean dirty clean dirty swap ", addr2);
+ printf("%s size RSS PSS clean dirty clean dirty swap swapPSS", addr2);
if (!verbose && !addresses) {
printf(" # ");
}
@@ -232,7 +236,7 @@
if (addresses) {
printf("-------- -------- ");
}
- printf("-------- -------- -------- -------- -------- -------- -------- -------- ");
+ printf("-------- -------- -------- -------- -------- -------- -------- -------- -------- ");
if (!verbose && !addresses) {
printf("---- ");
}
@@ -248,11 +252,11 @@
printf("%08x %08x ", mi->start, mi->end);
}
}
- printf("%8d %8d %8d %8d %8d %8d %8d %8d ", mi->size,
+ printf("%8d %8d %8d %8d %8d %8d %8d %8d %8d ", mi->size,
mi->rss,
mi->pss,
mi->shared_clean, mi->shared_dirty,
- mi->private_clean, mi->private_dirty, mi->swap);
+ mi->private_clean, mi->private_dirty, mi->swap, mi->swap_pss);
if (!verbose && !addresses) {
printf("%4d ", mi->count);
}
@@ -279,6 +283,7 @@
total.private_clean += mi->private_clean;
total.private_dirty += mi->private_dirty;
total.swap += mi->swap;
+ total.swap_pss += mi->swap_pss;
total.rss += mi->rss;
total.pss += mi->pss;
total.size += mi->size;