Add total GPU usage report into dumpsys meminfo output
With latest kernel changes, total GPU memory usage is reported and can be obtained via a BPF program. Create JNI interface to query it and report inside dumpsys meminfo output. Bug: 171261987 Test: dumpsys meminfo Signed-off-by: Suren Baghdasaryan <surenb@google.com> Change-Id: I949a13836d5b5bc87fc43f60871b4fbf2add6480
This commit is contained in:
@@ -2581,6 +2581,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
|
||||
|
||||
@@ -847,6 +847,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 {
|
||||
@@ -915,6 +926,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 },
|
||||
};
|
||||
|
||||
@@ -11247,6 +11247,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()
|
||||
- (ss[INDEX_TOTAL_PSS] - ss[INDEX_TOTAL_SWAP_PSS])
|
||||
- memInfo.getFreeSizeKb() - memInfo.getCachedSizeKb()
|
||||
@@ -12041,6 +12045,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));
|
||||
|
||||
Reference in New Issue
Block a user