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

Commit 193da6e6 authored by Suren Baghdasaryan's avatar Suren Baghdasaryan
Browse files

Report ION usage event when ION heap size is 0



In a situation when ION heap size is 0 dumpsys meminfo will not report
ION memory usage. Fix this by differentiating 0-size ION heap or pool
from the cases when /sys/kernel/ion/* do not exist or not readable.

Bug: 168942451
Test: emulate 0-size ION heap and run dumpsys meminfo
Signed-off-by: default avatarSuren Baghdasaryan <surenb@google.com>
Change-Id: I66624c9e3c73a59462cce8830a36323677db0029
parent f08e8871
Loading
Loading
Loading
Loading
+4 −2
Original line number Diff line number Diff line
@@ -2551,14 +2551,16 @@ public final class Debug
    public static native long getZramFreeKb();

    /**
     * Return memory size in kilobytes allocated for ION heaps.
     * Return memory size in kilobytes allocated for ION heaps or -1 if
     * /sys/kernel/ion/total_heaps_kb could not be read.
     *
     * @hide
     */
    public static native long getIonHeapsSizeKb();

    /**
     * Return memory size in kilobytes allocated for ION pools.
     * Return memory size in kilobytes allocated for ION pools or -1 if
     * /sys/kernel/ion/total_pools_kb could not be read.
     *
     * @hide
     */
+2 −2
Original line number Diff line number Diff line
@@ -792,7 +792,7 @@ static jlong android_os_Debug_getFreeZramKb(JNIEnv* env, jobject clazz) {
}

static jlong android_os_Debug_getIonHeapsSizeKb(JNIEnv* env, jobject clazz) {
    jlong heapsSizeKb = 0;
    jlong heapsSizeKb = -1;
    uint64_t size;

    if (meminfo::ReadIonHeapsSizeKb(&size)) {
@@ -803,7 +803,7 @@ static jlong android_os_Debug_getIonHeapsSizeKb(JNIEnv* env, jobject clazz) {
}

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

    if (meminfo::ReadIonPoolsSizeKb(&size)) {
+4 −4
Original line number Diff line number Diff line
@@ -13738,10 +13738,10 @@ public class ActivityManagerService extends IActivityManager.Stub
            }
            long kernelUsed = memInfo.getKernelUsedSizeKb();
            final long ionHeap = Debug.getIonHeapsSizeKb();
            if (ionHeap > 0) {
            final long ionPool = Debug.getIonPoolsSizeKb();
            if (ionHeap >= 0 && ionPool >= 0) {
                final long ionMapped = Debug.getIonMappedSizeKb();
                final long ionUnmapped = ionHeap - ionMapped;
                final long ionPool = Debug.getIonPoolsSizeKb();
                pw.print("      ION: ");
                        pw.print(stringifyKBSize(ionHeap + ionPool));
                        pw.print(" (");
@@ -14552,10 +14552,10 @@ public class ActivityManagerService extends IActivityManager.Stub
        memInfoBuilder.append("\n");
        long kernelUsed = memInfo.getKernelUsedSizeKb();
        final long ionHeap = Debug.getIonHeapsSizeKb();
        if (ionHeap > 0) {
        final long ionPool = Debug.getIonPoolsSizeKb();
        if (ionHeap >= 0 && ionPool >= 0) {
            final long ionMapped = Debug.getIonMappedSizeKb();
            final long ionUnmapped = ionHeap - ionMapped;
            final long ionPool = Debug.getIonPoolsSizeKb();
            memInfoBuilder.append("       ION: ");
            memInfoBuilder.append(stringifyKBSize(ionHeap + ionPool));
            memInfoBuilder.append("\n");