Merge changes from topic "ion memory accounting" am: 5ded8c130c am: 3c4624dcc2

Change-Id: I6620e200357ddcc46557f149e17fcad25e7c57c4
This commit is contained in:
Automerger Merge Worker
2019-12-19 21:51:13 +00:00
5 changed files with 127 additions and 7 deletions

View File

@@ -2503,4 +2503,27 @@ public final class Debug
* @hide
*/
public static native long getZramFreeKb();
/**
* Return memory size in kilobytes allocated for ION heaps.
*
* @hide
*/
public static native long getIonHeapsSizeKb();
/**
* Return memory size in kilobytes allocated for ION pools.
*
* @hide
*/
public static native long getIonPoolsSizeKb();
/**
* Return ION memory mapped by processes in kB.
* Notes:
* * Warning: Might impact performance as it reads /proc/<pid>/maps files for each process.
*
* @hide
*/
public static native long getIonMappedSizeKb();
}

View File

@@ -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];
}