Add total DMA-BUF heap pool size information to dumpsys meminfo
Some DMA-BUF heaps maintain pools of pre-zeroed memory for faster allocations. Print the total size of all DMA-BUF heap pools as part of dumpsys meminfo and use the same in LostRam calculation. Test: dumpsys meminfo Bug: 167709539 Change-Id: Ifb61fe596c1a8fab1bd536ec904285e532629b71 Merged-In: Ifb61fe596c1a8fab1bd536ec904285e532629b71
This commit is contained in:
@@ -2566,6 +2566,14 @@ public final class Debug
|
||||
*/
|
||||
public static native long getIonHeapsSizeKb();
|
||||
|
||||
/**
|
||||
* Return memory size in kilobytes allocated for DMA-BUF heap pools or -1 if
|
||||
* /sys/kernel/dma_heap/total_pools_kb could not be read.
|
||||
*
|
||||
* @hide
|
||||
*/
|
||||
public static native long getDmabufHeapPoolsSizeKb();
|
||||
|
||||
/**
|
||||
* Return memory size in kilobytes allocated for ION pools or -1 if
|
||||
* /sys/kernel/ion/total_pools_kb could not be read.
|
||||
|
||||
@@ -824,6 +824,17 @@ static jlong android_os_Debug_getIonPoolsSizeKb(JNIEnv* env, jobject clazz) {
|
||||
return poolsSizeKb;
|
||||
}
|
||||
|
||||
static jlong android_os_Debug_getDmabufHeapPoolsSizeKb(JNIEnv* env, jobject clazz) {
|
||||
jlong poolsSizeKb = -1;
|
||||
uint64_t size;
|
||||
|
||||
if (meminfo::ReadDmabufHeapPoolsSizeKb(&size)) {
|
||||
poolsSizeKb = size;
|
||||
}
|
||||
|
||||
return poolsSizeKb;
|
||||
}
|
||||
|
||||
static jlong android_os_Debug_getDmabufMappedSizeKb(JNIEnv* env, jobject clazz) {
|
||||
jlong dmabufPss = 0;
|
||||
std::vector<dmabufinfo::DmaBuffer> dmabufs;
|
||||
@@ -936,6 +947,8 @@ static const JNINativeMethod gMethods[] = {
|
||||
(void*)android_os_Debug_getIonPoolsSizeKb },
|
||||
{ "getDmabufMappedSizeKb", "()J",
|
||||
(void*)android_os_Debug_getDmabufMappedSizeKb },
|
||||
{ "getDmabufHeapPoolsSizeKb", "()J",
|
||||
(void*)android_os_Debug_getDmabufHeapPoolsSizeKb },
|
||||
{ "getGpuTotalUsageKb", "()J",
|
||||
(void*)android_os_Debug_getGpuTotalUsageKb },
|
||||
{ "isVmapStack", "()Z",
|
||||
|
||||
@@ -13756,14 +13756,23 @@ public class ActivityManagerService extends IActivityManager.Stub
|
||||
pw.print(" mapped + ");
|
||||
pw.print(stringifyKBSize(dmabufUnmapped));
|
||||
pw.println(" unmapped)");
|
||||
// TODO(b/167709539): also add pooled memory from DMA-BUF heaps
|
||||
kernelUsed += totalExportedDmabuf;
|
||||
}
|
||||
final long totalDmabufHeapPool = Debug.getDmabufHeapPoolsSizeKb();
|
||||
if (totalDmabufHeapPool >= 0) {
|
||||
pw.print("DMA-BUF Heaps pool: ");
|
||||
pw.println(stringifyKBSize(totalDmabufHeapPool));
|
||||
}
|
||||
}
|
||||
final long gpuUsage = Debug.getGpuTotalUsageKb();
|
||||
if (gpuUsage >= 0) {
|
||||
pw.print(" GPU: "); pw.println(stringifyKBSize(gpuUsage));
|
||||
}
|
||||
|
||||
/*
|
||||
* Note: ION/DMA-BUF heap pools are reclaimable and hence, they are included as part of
|
||||
* memInfo.getCachedSizeKb().
|
||||
*/
|
||||
final long lostRAM = memInfo.getTotalSizeKb() - (totalPss - totalSwapPss)
|
||||
- memInfo.getFreeSizeKb() - memInfo.getCachedSizeKb()
|
||||
- kernelUsed - memInfo.getZramTotalSizeKb();
|
||||
@@ -14575,9 +14584,14 @@ public class ActivityManagerService extends IActivityManager.Stub
|
||||
memInfoBuilder.append("DMA-BUF: ");
|
||||
memInfoBuilder.append(stringifyKBSize(totalExportedDmabuf));
|
||||
memInfoBuilder.append("\n");
|
||||
// TODO(b/167709539): also add pooled memory from DMA-BUF heaps
|
||||
kernelUsed += totalExportedDmabuf;
|
||||
}
|
||||
final long totalDmabufHeapPool = Debug.getDmabufHeapPoolsSizeKb();
|
||||
if (totalDmabufHeapPool >= 0) {
|
||||
memInfoBuilder.append("DMA-BUF Heaps pool: ");
|
||||
memInfoBuilder.append(stringifyKBSize(totalDmabufHeapPool));
|
||||
memInfoBuilder.append("\n");
|
||||
}
|
||||
}
|
||||
|
||||
final long gpuUsage = Debug.getGpuTotalUsageKb();
|
||||
@@ -14590,6 +14604,11 @@ public class ActivityManagerService extends IActivityManager.Stub
|
||||
memInfoBuilder.append(stringifyKBSize(
|
||||
totalPss - cachedPss + kernelUsed));
|
||||
memInfoBuilder.append("\n");
|
||||
|
||||
/*
|
||||
* Note: ION/DMA-BUF heap pools are reclaimable and hence, they are included as part of
|
||||
* memInfo.getCachedSizeKb().
|
||||
*/
|
||||
memInfoBuilder.append(" Lost RAM: ");
|
||||
memInfoBuilder.append(stringifyKBSize(memInfo.getTotalSizeKb()
|
||||
- (totalPss - totalSwapPss) - memInfo.getFreeSizeKb() - memInfo.getCachedSizeKb()
|
||||
|
||||
Reference in New Issue
Block a user