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

Commit 5630218f authored by Suren Baghdasaryan's avatar Suren Baghdasaryan
Browse files

Eliminate memtrack variability in Lost RAM when ION is being used



Modify lost RAM calculation to account unmapped ION buffers as part of
kernel memory and mapped ION buffers as PSS. Because mapped ION buffers
might be accounted in memtrack HAL's reported Graphics memory, we
need to replace it with the mapped dmabufs representing mapped ION
buffers.

Bug: 174546244
Test: dumpsys meminfo
Signed-off-by: default avatarSuren Baghdasaryan <surenb@google.com>
Change-Id: Ia7f5fc2ca95389a5f2ae78d4cdbf8ba3ef8e3972
Merged-In: Ia7f5fc2ca95389a5f2ae78d4cdbf8ba3ef8e3972
parent 26c49045
Loading
Loading
Loading
Loading
+12 −5
Original line number Diff line number Diff line
@@ -13772,9 +13772,12 @@ public class ActivityManagerService extends IActivityManager.Stub
                        pw.print(" unmapped + ");
                        pw.print(stringifyKBSize(ionPool));
                        pw.println(" pools)");
                kernelUsed += ionUnmapped;
                // Note: mapped ION memory is not accounted in PSS due to VM_PFNMAP flag being
                // set on ION VMAs, therefore consider the entire ION heap as used kernel memory
                kernelUsed += ionHeap;
                // set on ION VMAs, however it might be included by the memtrack HAL.
                // Replace memtrack HAL reported Graphics category with mapped dmabufs
                totalPss -= totalMemtrackGraphics;
                totalPss += dmabufMapped;
            } else {
                final long totalExportedDmabuf = Debug.getDmabufTotalExportedKb();
                if (totalExportedDmabuf >= 0) {
@@ -14634,17 +14637,21 @@ public class ActivityManagerService extends IActivityManager.Stub
        long kernelUsed = memInfo.getKernelUsedSizeKb();
        final long ionHeap = Debug.getIonHeapsSizeKb();
        final long ionPool = Debug.getIonPoolsSizeKb();
        final long dmabufMapped = Debug.getDmabufMappedSizeKb();
        if (ionHeap >= 0 && ionPool >= 0) {
            final long ionUnmapped = ionHeap - dmabufMapped;
            memInfoBuilder.append("       ION: ");
            memInfoBuilder.append(stringifyKBSize(ionHeap + ionPool));
            memInfoBuilder.append("\n");
            kernelUsed += ionUnmapped;
            // Note: mapped ION memory is not accounted in PSS due to VM_PFNMAP flag being
            // set on ION VMAs, therefore consider the entire ION heap as used kernel memory
            kernelUsed += ionHeap;
            // set on ION VMAs, however it might be included by the memtrack HAL.
            // Replace memtrack HAL reported Graphics category with mapped dmabufs
            totalPss -= totalMemtrackGraphics;
            totalPss += dmabufMapped;
        } else {
            final long totalExportedDmabuf = Debug.getDmabufTotalExportedKb();
            if (totalExportedDmabuf >= 0) {
                final long dmabufMapped = Debug.getDmabufMappedSizeKb();
                final long dmabufUnmapped = totalExportedDmabuf - dmabufMapped;
                memInfoBuilder.append("DMA-BUF: ");
                memInfoBuilder.append(stringifyKBSize(totalExportedDmabuf));