Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 7d360a08 authored by Treehugger Robot's avatar Treehugger Robot Committed by Automerger Merge Worker
Browse files

Merge changes from topic "b/167709539" am: ad688d3e

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

MUST ONLY BE SUBMITTED BY AUTOMERGER

Change-Id: I2b479ecc6524c0c1ba24bee365ccc07a7e88d1f7
parents 8bff83e9 ad688d3e
Loading
Loading
Loading
Loading
+8 −0
Original line number Original line Diff line number Diff line
@@ -2566,6 +2566,14 @@ public final class Debug
     */
     */
    public static native long getIonHeapsSizeKb();
    public static native long getIonHeapsSizeKb();


    /**
     * Return memory size in kilobytes allocated for DMA-BUF heap pools or -1 if
     * /sys/kernel/dma_heap/total_pools_kb could not be read.
     *
     * @hide
     */
    public static native long getDmabufHeapPoolsSizeKb();

    /**
    /**
     * Return memory size in kilobytes allocated for ION pools or -1 if
     * Return memory size in kilobytes allocated for ION pools or -1 if
     * /sys/kernel/ion/total_pools_kb could not be read.
     * /sys/kernel/ion/total_pools_kb could not be read.
+13 −0
Original line number Original line Diff line number Diff line
@@ -824,6 +824,17 @@ static jlong android_os_Debug_getIonPoolsSizeKb(JNIEnv* env, jobject clazz) {
    return poolsSizeKb;
    return poolsSizeKb;
}
}


static jlong android_os_Debug_getDmabufHeapPoolsSizeKb(JNIEnv* env, jobject clazz) {
    jlong poolsSizeKb = -1;
    uint64_t size;

    if (meminfo::ReadDmabufHeapPoolsSizeKb(&size)) {
        poolsSizeKb = size;
    }

    return poolsSizeKb;
}

static jlong android_os_Debug_getDmabufMappedSizeKb(JNIEnv* env, jobject clazz) {
static jlong android_os_Debug_getDmabufMappedSizeKb(JNIEnv* env, jobject clazz) {
    jlong dmabufPss = 0;
    jlong dmabufPss = 0;
    std::vector<dmabufinfo::DmaBuffer> dmabufs;
    std::vector<dmabufinfo::DmaBuffer> dmabufs;
@@ -936,6 +947,8 @@ static const JNINativeMethod gMethods[] = {
            (void*)android_os_Debug_getIonPoolsSizeKb },
            (void*)android_os_Debug_getIonPoolsSizeKb },
    { "getDmabufMappedSizeKb", "()J",
    { "getDmabufMappedSizeKb", "()J",
            (void*)android_os_Debug_getDmabufMappedSizeKb },
            (void*)android_os_Debug_getDmabufMappedSizeKb },
    { "getDmabufHeapPoolsSizeKb", "()J",
            (void*)android_os_Debug_getDmabufHeapPoolsSizeKb },
    { "getGpuTotalUsageKb", "()J",
    { "getGpuTotalUsageKb", "()J",
            (void*)android_os_Debug_getGpuTotalUsageKb },
            (void*)android_os_Debug_getGpuTotalUsageKb },
    { "isVmapStack", "()Z",
    { "isVmapStack", "()Z",
+21 −2
Original line number Original line Diff line number Diff line
@@ -13746,14 +13746,23 @@ public class ActivityManagerService extends IActivityManager.Stub
                    pw.print(" mapped + ");
                    pw.print(" mapped + ");
                    pw.print(stringifyKBSize(dmabufUnmapped));
                    pw.print(stringifyKBSize(dmabufUnmapped));
                    pw.println(" unmapped)");
                    pw.println(" unmapped)");
                    // TODO(b/167709539): also add pooled memory from DMA-BUF heaps
                    kernelUsed += totalExportedDmabuf;
                    kernelUsed += totalExportedDmabuf;
                }
                }
                final long totalDmabufHeapPool = Debug.getDmabufHeapPoolsSizeKb();
                if (totalDmabufHeapPool >= 0) {
                    pw.print("DMA-BUF Heaps pool: ");
                    pw.println(stringifyKBSize(totalDmabufHeapPool));
                }
            }
            }
            final long gpuUsage = Debug.getGpuTotalUsageKb();
            final long gpuUsage = Debug.getGpuTotalUsageKb();
            if (gpuUsage >= 0) {
            if (gpuUsage >= 0) {
                pw.print("      GPU: "); pw.println(stringifyKBSize(gpuUsage));
                pw.print("      GPU: "); pw.println(stringifyKBSize(gpuUsage));
            }
            }
            /*
             * Note: ION/DMA-BUF heap pools are reclaimable and hence, they are included as part of
             * memInfo.getCachedSizeKb().
             */
            final long lostRAM = memInfo.getTotalSizeKb() - (totalPss - totalSwapPss)
            final long lostRAM = memInfo.getTotalSizeKb() - (totalPss - totalSwapPss)
                    - memInfo.getFreeSizeKb() - memInfo.getCachedSizeKb()
                    - memInfo.getFreeSizeKb() - memInfo.getCachedSizeKb()
                    - kernelUsed - memInfo.getZramTotalSizeKb();
                    - kernelUsed - memInfo.getZramTotalSizeKb();
@@ -14565,9 +14574,14 @@ public class ActivityManagerService extends IActivityManager.Stub
                memInfoBuilder.append("DMA-BUF: ");
                memInfoBuilder.append("DMA-BUF: ");
                memInfoBuilder.append(stringifyKBSize(totalExportedDmabuf));
                memInfoBuilder.append(stringifyKBSize(totalExportedDmabuf));
                memInfoBuilder.append("\n");
                memInfoBuilder.append("\n");
                // TODO(b/167709539): also add pooled memory from DMA-BUF heaps
                kernelUsed += totalExportedDmabuf;
                kernelUsed += totalExportedDmabuf;
            }
            }
            final long totalDmabufHeapPool = Debug.getDmabufHeapPoolsSizeKb();
            if (totalDmabufHeapPool >= 0) {
                memInfoBuilder.append("DMA-BUF Heaps pool: ");
                memInfoBuilder.append(stringifyKBSize(totalDmabufHeapPool));
                memInfoBuilder.append("\n");
            }
        }
        }
        final long gpuUsage = Debug.getGpuTotalUsageKb();
        final long gpuUsage = Debug.getGpuTotalUsageKb();
@@ -14580,6 +14594,11 @@ public class ActivityManagerService extends IActivityManager.Stub
        memInfoBuilder.append(stringifyKBSize(
        memInfoBuilder.append(stringifyKBSize(
                                  totalPss - cachedPss + kernelUsed));
                                  totalPss - cachedPss + kernelUsed));
        memInfoBuilder.append("\n");
        memInfoBuilder.append("\n");
        /*
         * Note: ION/DMA-BUF heap pools are reclaimable and hence, they are included as part of
         * memInfo.getCachedSizeKb().
         */
        memInfoBuilder.append("  Lost RAM: ");
        memInfoBuilder.append("  Lost RAM: ");
        memInfoBuilder.append(stringifyKBSize(memInfo.getTotalSizeKb()
        memInfoBuilder.append(stringifyKBSize(memInfo.getTotalSizeKb()
                - (totalPss - totalSwapPss) - memInfo.getFreeSizeKb() - memInfo.getCachedSizeKb()
                - (totalPss - totalSwapPss) - memInfo.getFreeSizeKb() - memInfo.getCachedSizeKb()