summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
author TreeHugger Robot <treehugger-gerrit@google.com> 2021-02-16 14:50:24 +0000
committer Android (Google) Code Review <android-gerrit@google.com> 2021-02-16 14:50:24 +0000
commit15c4d3210ad1374bc0feacecc74608eaae60b76a (patch)
tree44855c7540de25614d804982559bb64479dbee3d
parentb1c53539379c57c060002d93447b0a5ac472269a (diff)
parentd805e562aa014811fdc5f381abcfd5f82d0377ff (diff)
Merge "dumpsys: Print total DMA-BUFs exported from the DMA-BUF heaps framework" into sc-dev
-rw-r--r--core/java/android/os/Debug.java8
-rw-r--r--core/jni/android_os_Debug.cpp12
-rw-r--r--services/core/java/com/android/server/am/ActivityManagerService.java9
-rw-r--r--services/core/java/com/android/server/am/AppProfiler.java8
4 files changed, 37 insertions, 0 deletions
diff --git a/core/java/android/os/Debug.java b/core/java/android/os/Debug.java
index eac03dc5d07e..e3b13f4f9f17 100644
--- a/core/java/android/os/Debug.java
+++ b/core/java/android/os/Debug.java
@@ -2566,6 +2566,14 @@ public final class Debug
public static native long getDmabufTotalExportedKb();
/**
+ * Return total memory size in kilobytes for DMA-BUFs exported from the DMA-BUF
+ * heaps frameworks or -1 in the case of an error.
+ *
+ * @hide
+ */
+ public static native long getDmabufHeapTotalExportedKb();
+
+ /**
* Return memory size in kilobytes allocated for ION heaps or -1 if
* /sys/kernel/ion/total_heaps_kb could not be read.
*
diff --git a/core/jni/android_os_Debug.cpp b/core/jni/android_os_Debug.cpp
index a7950f217243..8dcb2100b5fb 100644
--- a/core/jni/android_os_Debug.cpp
+++ b/core/jni/android_os_Debug.cpp
@@ -829,6 +829,16 @@ static jlong android_os_Debug_getDmabufTotalExportedKb(JNIEnv* env, jobject claz
return dmabufTotalSizeKb;
}
+static jlong android_os_Debug_getDmabufHeapTotalExportedKb(JNIEnv* env, jobject clazz) {
+ jlong dmabufHeapTotalSizeKb = -1;
+ uint64_t size;
+
+ if (meminfo::ReadDmabufHeapTotalExportedKb(&size)) {
+ dmabufHeapTotalSizeKb = size;
+ }
+ return dmabufHeapTotalSizeKb;
+}
+
static jlong android_os_Debug_getIonPoolsSizeKb(JNIEnv* env, jobject clazz) {
jlong poolsSizeKb = -1;
uint64_t size;
@@ -986,6 +996,8 @@ static const JNINativeMethod gMethods[] = {
(void*)android_os_Debug_getDmabufTotalExportedKb },
{ "getGpuDmaBufUsageKb", "()J",
(void*)android_os_Debug_getGpuDmaBufUsageKb },
+ { "getDmabufHeapTotalExportedKb", "()J",
+ (void*)android_os_Debug_getDmabufHeapTotalExportedKb },
{ "getIonPoolsSizeKb", "()J",
(void*)android_os_Debug_getIonPoolsSizeKb },
{ "getDmabufMappedSizeKb", "()J",
diff --git a/services/core/java/com/android/server/am/ActivityManagerService.java b/services/core/java/com/android/server/am/ActivityManagerService.java
index bedd19b6864a..26fede1eb950 100644
--- a/services/core/java/com/android/server/am/ActivityManagerService.java
+++ b/services/core/java/com/android/server/am/ActivityManagerService.java
@@ -10747,6 +10747,15 @@ public class ActivityManagerService extends IActivityManager.Stub
ss[INDEX_TOTAL_PSS] -= ss[INDEX_TOTAL_MEMTRACK_GRAPHICS];
ss[INDEX_TOTAL_PSS] += dmabufMapped;
}
+
+ // totalDmabufHeapExported is included in totalExportedDmabuf above and hence do not
+ // need to be added to kernelUsed.
+ final long totalDmabufHeapExported = Debug.getDmabufHeapTotalExportedKb();
+ if (totalDmabufHeapExported >= 0) {
+ pw.print("DMA-BUF Heaps: ");
+ pw.println(stringifyKBSize(totalDmabufHeapExported));
+ }
+
final long totalDmabufHeapPool = Debug.getDmabufHeapPoolsSizeKb();
if (totalDmabufHeapPool >= 0) {
pw.print("DMA-BUF Heaps pool: ");
diff --git a/services/core/java/com/android/server/am/AppProfiler.java b/services/core/java/com/android/server/am/AppProfiler.java
index fc7a476c6108..c8630fa52973 100644
--- a/services/core/java/com/android/server/am/AppProfiler.java
+++ b/services/core/java/com/android/server/am/AppProfiler.java
@@ -1536,6 +1536,14 @@ public class AppProfiler {
totalPss -= totalMemtrackGraphics;
totalPss += dmabufMapped;
}
+ // These are included in the totalExportedDmabuf above and hence do not need to be added
+ // to kernelUsed.
+ final long totalExportedDmabufHeap = Debug.getDmabufHeapTotalExportedKb();
+ if (totalExportedDmabufHeap >= 0) {
+ memInfoBuilder.append("DMA-BUF Heap: ");
+ memInfoBuilder.append(stringifyKBSize(totalExportedDmabufHeap));
+ memInfoBuilder.append("\n");
+ }
final long totalDmabufHeapPool = Debug.getDmabufHeapPoolsSizeKb();
if (totalDmabufHeapPool >= 0) {