Merge "Add total GPU usage report into dumpsys meminfo output" am: 50a824abf7 am: 0eed51c4fd

Original change: https://android-review.googlesource.com/c/platform/frameworks/base/+/1472569

MUST ONLY BE SUBMITTED BY AUTOMERGER

Change-Id: Ib3aa0cf7b052dad50273e1370218bbb4e4ecb375
This commit is contained in:
Suren Baghdasaryan
2020-12-30 18:26:52 +00:00
committed by Automerger Merge Worker
3 changed files with 30 additions and 0 deletions

View File

@@ -2575,6 +2575,13 @@ public final class Debug
*/
public static native long getIonMappedSizeKb();
/**
* Return memory size in kilobytes used by GPU.
*
* @hide
*/
public static native long getGpuTotalUsageKb();
/**
* Return whether virtually-mapped kernel stacks are enabled (CONFIG_VMAP_STACK).
* Note: caller needs config_gz read sepolicy permission

View File

@@ -844,6 +844,17 @@ static jlong android_os_Debug_getIonMappedSizeKb(JNIEnv* env, jobject clazz) {
return ionPss;
}
static jlong android_os_Debug_getGpuTotalUsageKb(JNIEnv* env, jobject clazz) {
jlong sizeKb = -1;
uint64_t size;
if (meminfo::ReadGpuTotalUsageKb(&size)) {
sizeKb = size;
}
return sizeKb;
}
static jboolean android_os_Debug_isVmapStack(JNIEnv *env, jobject clazz)
{
static enum {
@@ -912,6 +923,8 @@ static const JNINativeMethod gMethods[] = {
(void*)android_os_Debug_getIonPoolsSizeKb },
{ "getIonMappedSizeKb", "()J",
(void*)android_os_Debug_getIonMappedSizeKb },
{ "getGpuTotalUsageKb", "()J",
(void*)android_os_Debug_getGpuTotalUsageKb },
{ "isVmapStack", "()Z",
(void*)android_os_Debug_isVmapStack },
};

View File

@@ -13743,6 +13743,10 @@ public class ActivityManagerService extends IActivityManager.Stub
// set on ION VMAs, therefore consider the entire ION heap as used kernel memory
kernelUsed += ionHeap;
}
final long gpuUsage = Debug.getGpuTotalUsageKb();
if (gpuUsage >= 0) {
pw.print(" GPU: "); pw.println(stringifyKBSize(gpuUsage));
}
final long lostRAM = memInfo.getTotalSizeKb() - (totalPss - totalSwapPss)
- memInfo.getFreeSizeKb() - memInfo.getCachedSizeKb()
- kernelUsed - memInfo.getZramTotalSizeKb();
@@ -14551,6 +14555,12 @@ public class ActivityManagerService extends IActivityManager.Stub
// set on ION VMAs, therefore consider the entire ION heap as used kernel memory
kernelUsed += ionHeap;
}
final long gpuUsage = Debug.getGpuTotalUsageKb();
if (gpuUsage >= 0) {
memInfoBuilder.append(" GPU: ");
memInfoBuilder.append(stringifyKBSize(gpuUsage));
memInfoBuilder.append("\n");
}
memInfoBuilder.append(" Used RAM: ");
memInfoBuilder.append(stringifyKBSize(
totalPss - cachedPss + kernelUsed));