From 228fc0293b498cbb29f08d6eeec3dda2545dddbc Mon Sep 17 00:00:00 2001 From: Ioannis Ilkos Date: Thu, 25 Mar 2021 15:44:03 +0000 Subject: Per process DMA-BUF stats In order to detect memory regressions caused by improper handling of dma-buf buffers we need to measure how this memory is used. This change: - Introduces DmabufInfoReader which wraps libmeminfo and provides per-process DMA-BUF stats. - Specifically, measures buffers mapped to the process address space (from /proc/pid/maps). This is supported on all devices. - For devices running 5.4+ (where the system processes can query fdinfo) also measures the total retained memory (either by mmap or an open fd). - Introduces a statsd atom that collects this for all running managed processes. Non-managed processes will also hold dmabufs, but the likelihood of them causing issues (post-launch) is smaller so I am trading them off for cheaper collection (if indeed we encounter such problems, they will definitely be caught by the total dmabuf counters). Test: manual Bug: 183708249 Change-Id: I5e0ef58ac1a66ebe2d280c5733de46ba84f75a46 --- core/jni/AndroidRuntime.cpp | 2 ++ 1 file changed, 2 insertions(+) (limited to 'core/jni/AndroidRuntime.cpp') diff --git a/core/jni/AndroidRuntime.cpp b/core/jni/AndroidRuntime.cpp index 0c3f265b84cc..6636b1f6327b 100644 --- a/core/jni/AndroidRuntime.cpp +++ b/core/jni/AndroidRuntime.cpp @@ -191,6 +191,7 @@ extern int register_com_android_internal_content_NativeLibraryHelper(JNIEnv *env extern int register_com_android_internal_content_om_OverlayConfig(JNIEnv *env); extern int register_com_android_internal_net_NetworkUtilsInternal(JNIEnv* env); extern int register_com_android_internal_os_ClassLoaderFactory(JNIEnv* env); +extern int register_com_android_internal_os_DmabufInfoReader(JNIEnv* env); extern int register_com_android_internal_os_FuseAppLoop(JNIEnv* env); extern int register_com_android_internal_os_KernelCpuBpfTracking(JNIEnv* env); extern int register_com_android_internal_os_KernelCpuTotalBpfMapReader(JNIEnv* env); @@ -1616,6 +1617,7 @@ static const RegJNIRec gRegJNI[] = { REG_JNI(register_android_animation_PropertyValuesHolder), REG_JNI(register_android_security_Scrypt), REG_JNI(register_com_android_internal_content_NativeLibraryHelper), + REG_JNI(register_com_android_internal_os_DmabufInfoReader), REG_JNI(register_com_android_internal_os_FuseAppLoop), REG_JNI(register_com_android_internal_os_KernelCpuBpfTracking), REG_JNI(register_com_android_internal_os_KernelCpuTotalBpfMapReader), -- cgit v1.2.3