Skip to content
Snippets Groups Projects
Commit 40899ad1 authored by Suren Baghdasaryan's avatar Suren Baghdasaryan
Browse files

Improve cached kernel memory accounting using meminfo KReclaimable field


KReclaimable field from /proc/meminfo is designed to represent total amount
of memory that kernel can reclaim when needed. This includes reclaimable
memory consumed by slab and reported in SReclaimable field as well as ION
pools. By using KReclaimable instead of SReclaimable we will account for
ION pools currently reported under "Lost RAM" category in dumpsys meminfo
report.

Bug: 138148041
Test: dumpsys meminfo
Change-Id: Ifdea234d05639db93074ab598b81db5ff5b43612
Signed-off-by: default avatarSuren Baghdasaryan <surenb@google.com>
parent 5911b9ef
No related branches found
No related tags found
No related merge requests found
......@@ -91,7 +91,15 @@ public final class MemInfoReader {
* that are mapped in to processes.
*/
public long getCachedSizeKb() {
return mInfos[Debug.MEMINFO_BUFFERS] + mInfos[Debug.MEMINFO_SLAB_RECLAIMABLE]
long kReclaimable = mInfos[Debug.MEMINFO_KRECLAIMABLE];
// Note: MEMINFO_KRECLAIMABLE includes MEMINFO_SLAB_RECLAIMABLE and ION pools.
// Fall back to using MEMINFO_SLAB_RECLAIMABLE in case of older kernels that do
// not include KReclaimable meminfo field.
if (kReclaimable == 0) {
kReclaimable = mInfos[Debug.MEMINFO_SLAB_RECLAIMABLE];
}
return mInfos[Debug.MEMINFO_BUFFERS] + kReclaimable
+ mInfos[Debug.MEMINFO_CACHED] - mInfos[Debug.MEMINFO_MAPPED];
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment