Merge "Add private gpu and total dmabuf size to SystemMemory atom" into sc-dev
This commit is contained in:
committed by
Android (Google) Code Review
commit
20f9ba618f
@@ -2134,7 +2134,9 @@ public class StatsPullAtomService extends SystemService {
|
||||
metrics.kernelStackKb,
|
||||
metrics.totalIonKb,
|
||||
metrics.unaccountedKb,
|
||||
metrics.gpuTotalUsageKb));
|
||||
metrics.gpuTotalUsageKb,
|
||||
metrics.gpuPrivateAllocationsKb,
|
||||
metrics.dmaBufTotalExportedKb));
|
||||
return StatsManager.PULL_SUCCESS;
|
||||
}
|
||||
|
||||
|
||||
@@ -28,6 +28,8 @@ final class SystemMemoryUtil {
|
||||
static Metrics getMetrics() {
|
||||
int totalIonKb = (int) Debug.getIonHeapsSizeKb();
|
||||
int gpuTotalUsageKb = (int) Debug.getGpuTotalUsageKb();
|
||||
int gpuDmaBufUsageKb = (int) Debug.getGpuDmaBufUsageKb();
|
||||
int dmaBufTotalExportedKb = (int) Debug.getDmabufTotalExportedKb();
|
||||
|
||||
long[] mInfos = new long[Debug.MEMINFO_COUNT];
|
||||
Debug.getMemInfo(mInfos);
|
||||
@@ -49,14 +51,36 @@ final class SystemMemoryUtil {
|
||||
+ mInfos[Debug.MEMINFO_SLAB_UNRECLAIMABLE]
|
||||
+ kReclaimableKb
|
||||
+ mInfos[Debug.MEMINFO_VM_ALLOC_USED]
|
||||
+ mInfos[Debug.MEMINFO_PAGE_TABLES]
|
||||
+ Math.max(totalIonKb, 0);
|
||||
+ mInfos[Debug.MEMINFO_PAGE_TABLES];
|
||||
|
||||
if (!Debug.isVmapStack()) {
|
||||
// See b/146088882
|
||||
accountedKb += mInfos[Debug.MEMINFO_KERNEL_STACK];
|
||||
}
|
||||
|
||||
int gpuPrivateAllocationsKb = -1;
|
||||
if (gpuTotalUsageKb >= 0 && gpuDmaBufUsageKb >= 0) {
|
||||
gpuPrivateAllocationsKb = gpuTotalUsageKb - gpuDmaBufUsageKb;
|
||||
}
|
||||
// If we can distinguish gpu private allocs it means the dmabuf metrics
|
||||
// are supported already.
|
||||
if (dmaBufTotalExportedKb >= 0 && gpuPrivateAllocationsKb >= 0) {
|
||||
// If we can calculate the overlap between dma memory and gpu
|
||||
// drivers we can do more accurate tracking. But this is only
|
||||
// available on 5.4+ kernels.
|
||||
accountedKb += dmaBufTotalExportedKb + gpuPrivateAllocationsKb;
|
||||
} else {
|
||||
// If we cannot distinguish, accept that we will double count the
|
||||
// dma buffers also used by the gpu driver.
|
||||
accountedKb += Math.max(0, gpuTotalUsageKb);
|
||||
if (dmaBufTotalExportedKb >= 0) {
|
||||
accountedKb += dmaBufTotalExportedKb;
|
||||
} else if (totalIonKb >= 0) {
|
||||
// ION is a subset of total exported dmabuf memory.
|
||||
accountedKb += totalIonKb;
|
||||
}
|
||||
}
|
||||
|
||||
Metrics result = new Metrics();
|
||||
result.unreclaimableSlabKb = (int) mInfos[Debug.MEMINFO_SLAB_UNRECLAIMABLE];
|
||||
result.vmallocUsedKb = (int) mInfos[Debug.MEMINFO_VM_ALLOC_USED];
|
||||
@@ -64,6 +88,8 @@ final class SystemMemoryUtil {
|
||||
result.kernelStackKb = (int) mInfos[Debug.MEMINFO_KERNEL_STACK];
|
||||
result.totalIonKb = totalIonKb;
|
||||
result.gpuTotalUsageKb = gpuTotalUsageKb;
|
||||
result.gpuPrivateAllocationsKb = gpuPrivateAllocationsKb;
|
||||
result.dmaBufTotalExportedKb = dmaBufTotalExportedKb;
|
||||
result.unaccountedKb = (int) (mInfos[Debug.MEMINFO_TOTAL] - accountedKb);
|
||||
return result;
|
||||
}
|
||||
@@ -75,6 +101,8 @@ final class SystemMemoryUtil {
|
||||
public int kernelStackKb;
|
||||
public int totalIonKb;
|
||||
public int gpuTotalUsageKb;
|
||||
public int gpuPrivateAllocationsKb;
|
||||
public int dmaBufTotalExportedKb;
|
||||
public int unaccountedKb;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user