From 0b8534e817eb9066e5b2d60a1c4913ec7692e673 Mon Sep 17 00:00:00 2001 From: Ioannis Ilkos Date: Thu, 7 Jan 2021 15:35:24 +0000 Subject: [PATCH] Add GPU memory stats to SystemMemory atom On S+ devices we started tracking GPU driver mem allocations. Record the allocations in the SystemMemory atom (pulled periodically and at LMK time) Given the GPU memory overlaps with ion allocations do not (yet) account for it in untracked memory calculations Test: manual Bug: 149462065 Change-Id: I8cc09d7240ccf0fecd1bab1f62e8daf352edd8ea --- .../com/android/server/stats/pull/StatsPullAtomService.java | 3 ++- .../java/com/android/server/stats/pull/SystemMemoryUtil.java | 3 +++ 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/services/core/java/com/android/server/stats/pull/StatsPullAtomService.java b/services/core/java/com/android/server/stats/pull/StatsPullAtomService.java index 8071672462ef5..347fe69dd3ed4 100644 --- a/services/core/java/com/android/server/stats/pull/StatsPullAtomService.java +++ b/services/core/java/com/android/server/stats/pull/StatsPullAtomService.java @@ -1976,7 +1976,8 @@ public class StatsPullAtomService extends SystemService { metrics.pageTablesKb, metrics.kernelStackKb, metrics.totalIonKb, - metrics.unaccountedKb)); + metrics.unaccountedKb, + metrics.gpuTotalUsageKb)); return StatsManager.PULL_SUCCESS; } diff --git a/services/core/java/com/android/server/stats/pull/SystemMemoryUtil.java b/services/core/java/com/android/server/stats/pull/SystemMemoryUtil.java index 99fc7c11c5b30..1e80c4fe89fb2 100644 --- a/services/core/java/com/android/server/stats/pull/SystemMemoryUtil.java +++ b/services/core/java/com/android/server/stats/pull/SystemMemoryUtil.java @@ -27,6 +27,7 @@ final class SystemMemoryUtil { static Metrics getMetrics() { int totalIonKb = (int) Debug.getIonHeapsSizeKb(); + int gpuTotalUsageKb = (int) Debug.getGpuTotalUsageKb(); long[] mInfos = new long[Debug.MEMINFO_COUNT]; Debug.getMemInfo(mInfos); @@ -62,6 +63,7 @@ final class SystemMemoryUtil { result.pageTablesKb = (int) mInfos[Debug.MEMINFO_PAGE_TABLES]; result.kernelStackKb = (int) mInfos[Debug.MEMINFO_KERNEL_STACK]; result.totalIonKb = totalIonKb; + result.gpuTotalUsageKb = gpuTotalUsageKb; result.unaccountedKb = (int) (mInfos[Debug.MEMINFO_TOTAL] - accountedKb); return result; } @@ -72,6 +74,7 @@ final class SystemMemoryUtil { public int pageTablesKb; public int kernelStackKb; public int totalIonKb; + public int gpuTotalUsageKb; public int unaccountedKb; } }