diff options
| author | Suren Baghdasaryan <surenb@google.com> | 2020-10-23 09:31:54 -0700 |
|---|---|---|
| committer | Suren Baghdasaryan <surenb@google.com> | 2020-12-30 17:32:10 +0000 |
| commit | aee45ee0bc05abd181ff16af92c599d31f9fbc7f (patch) | |
| tree | 81fe070c0c3703e11766d16dd5751b4c9e10770e /core | |
| parent | 4c7a71448dd46d171444d18b87e0344b9c912fe8 (diff) | |
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>
Merged-In: I949a13836d5b5bc87fc43f60871b4fbf2add6480
Change-Id: I949a13836d5b5bc87fc43f60871b4fbf2add6480
Diffstat (limited to 'core')
| -rw-r--r-- | core/java/android/os/Debug.java | 7 | ||||
| -rw-r--r-- | core/jni/android_os_Debug.cpp | 13 |
2 files changed, 20 insertions, 0 deletions
diff --git a/core/java/android/os/Debug.java b/core/java/android/os/Debug.java index 8ab734d2325e..27dc6e0ada43 100644 --- a/core/java/android/os/Debug.java +++ b/core/java/android/os/Debug.java @@ -2576,6 +2576,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 * diff --git a/core/jni/android_os_Debug.cpp b/core/jni/android_os_Debug.cpp index 5a859aabce7b..28fc8ede1653 100644 --- a/core/jni/android_os_Debug.cpp +++ b/core/jni/android_os_Debug.cpp @@ -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 }, }; |
