Add total size of DMA-BUFs exported to 'dumpsys meminfo' am: 363d44d7a0
Original change: https://android-review.googlesource.com/c/platform/frameworks/base/+/1564878 MUST ONLY BE SUBMITTED BY AUTOMERGER Change-Id: I17fd9f11e20e1c1ac216cff4224298d7fd7c2a00
This commit is contained in:
@@ -2550,6 +2550,14 @@ public final class Debug
|
||||
*/
|
||||
public static native long getZramFreeKb();
|
||||
|
||||
/**
|
||||
* Return total memory size in kilobytes for exported DMA-BUFs or -1 if
|
||||
* the DMA-BUF sysfs stats at /sys/kernel/dmabuf/buffers could not be read.
|
||||
*
|
||||
* @hide
|
||||
*/
|
||||
public static native long getDmabufTotalExportedKb();
|
||||
|
||||
/**
|
||||
* Return memory size in kilobytes allocated for ION heaps or -1 if
|
||||
* /sys/kernel/ion/total_heaps_kb could not be read.
|
||||
|
||||
@@ -43,6 +43,7 @@
|
||||
#include <nativehelper/JNIPlatformHelp.h>
|
||||
#include <nativehelper/ScopedUtfChars.h>
|
||||
#include "jni.h"
|
||||
#include <dmabufinfo/dmabuf_sysfs_stats.h>
|
||||
#include <dmabufinfo/dmabufinfo.h>
|
||||
#include <meminfo/procmeminfo.h>
|
||||
#include <meminfo/sysmeminfo.h>
|
||||
@@ -802,6 +803,16 @@ static jlong android_os_Debug_getIonHeapsSizeKb(JNIEnv* env, jobject clazz) {
|
||||
return heapsSizeKb;
|
||||
}
|
||||
|
||||
static jlong android_os_Debug_getDmabufTotalExportedKb(JNIEnv* env, jobject clazz) {
|
||||
jlong dmabufTotalSizeKb = -1;
|
||||
uint64_t size;
|
||||
|
||||
if (dmabufinfo::GetDmabufTotalExportedKb(&size)) {
|
||||
dmabufTotalSizeKb = size;
|
||||
}
|
||||
return dmabufTotalSizeKb;
|
||||
}
|
||||
|
||||
static jlong android_os_Debug_getIonPoolsSizeKb(JNIEnv* env, jobject clazz) {
|
||||
jlong poolsSizeKb = -1;
|
||||
uint64_t size;
|
||||
@@ -919,6 +930,8 @@ static const JNINativeMethod gMethods[] = {
|
||||
(void*)android_os_Debug_getFreeZramKb },
|
||||
{ "getIonHeapsSizeKb", "()J",
|
||||
(void*)android_os_Debug_getIonHeapsSizeKb },
|
||||
{ "getDmabufTotalExportedKb", "()J",
|
||||
(void*)android_os_Debug_getDmabufTotalExportedKb },
|
||||
{ "getIonPoolsSizeKb", "()J",
|
||||
(void*)android_os_Debug_getIonPoolsSizeKb },
|
||||
{ "getDmabufMappedSizeKb", "()J",
|
||||
|
||||
@@ -13720,13 +13720,13 @@ public class ActivityManagerService extends IActivityManager.Stub
|
||||
long kernelUsed = memInfo.getKernelUsedSizeKb();
|
||||
final long ionHeap = Debug.getIonHeapsSizeKb();
|
||||
final long ionPool = Debug.getIonPoolsSizeKb();
|
||||
final long dmabufMapped = Debug.getDmabufMappedSizeKb();
|
||||
if (ionHeap >= 0 && ionPool >= 0) {
|
||||
final long ionMapped = Debug.getDmabufMappedSizeKb();
|
||||
final long ionUnmapped = ionHeap - ionMapped;
|
||||
final long ionUnmapped = ionHeap - dmabufMapped;
|
||||
pw.print(" ION: ");
|
||||
pw.print(stringifyKBSize(ionHeap + ionPool));
|
||||
pw.print(" (");
|
||||
pw.print(stringifyKBSize(ionMapped));
|
||||
pw.print(stringifyKBSize(dmabufMapped));
|
||||
pw.print(" mapped + ");
|
||||
pw.print(stringifyKBSize(ionUnmapped));
|
||||
pw.print(" unmapped + ");
|
||||
@@ -13735,6 +13735,20 @@ public class ActivityManagerService extends IActivityManager.Stub
|
||||
// Note: mapped ION memory is not accounted in PSS due to VM_PFNMAP flag being
|
||||
// set on ION VMAs, therefore consider the entire ION heap as used kernel memory
|
||||
kernelUsed += ionHeap;
|
||||
} else {
|
||||
final long totalExportedDmabuf = Debug.getDmabufTotalExportedKb();
|
||||
if (totalExportedDmabuf >= 0) {
|
||||
final long dmabufUnmapped = totalExportedDmabuf - dmabufMapped;
|
||||
pw.print("DMA-BUF: ");
|
||||
pw.print(stringifyKBSize(totalExportedDmabuf));
|
||||
pw.print(" (");
|
||||
pw.print(stringifyKBSize(dmabufMapped));
|
||||
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 gpuUsage = Debug.getGpuTotalUsageKb();
|
||||
if (gpuUsage >= 0) {
|
||||
@@ -14539,15 +14553,23 @@ public class ActivityManagerService extends IActivityManager.Stub
|
||||
final long ionHeap = Debug.getIonHeapsSizeKb();
|
||||
final long ionPool = Debug.getIonPoolsSizeKb();
|
||||
if (ionHeap >= 0 && ionPool >= 0) {
|
||||
final long ionMapped = Debug.getDmabufMappedSizeKb();
|
||||
final long ionUnmapped = ionHeap - ionMapped;
|
||||
memInfoBuilder.append(" ION: ");
|
||||
memInfoBuilder.append(stringifyKBSize(ionHeap + ionPool));
|
||||
memInfoBuilder.append("\n");
|
||||
// Note: mapped ION memory is not accounted in PSS due to VM_PFNMAP flag being
|
||||
// set on ION VMAs, therefore consider the entire ION heap as used kernel memory
|
||||
kernelUsed += ionHeap;
|
||||
} else {
|
||||
final long totalExportedDmabuf = Debug.getDmabufTotalExportedKb();
|
||||
if (totalExportedDmabuf >= 0) {
|
||||
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 gpuUsage = Debug.getGpuTotalUsageKb();
|
||||
if (gpuUsage >= 0) {
|
||||
memInfoBuilder.append(" GPU: ");
|
||||
|
||||
Reference in New Issue
Block a user