Add additional meminfo fields to SystemMemory

This change adds 13 additional fields from /proc/meminfo to the
SystemMemory atom (MemTotal, MemFree, MemAvailable, Active, Inactive,
Active(anon), Inactive(anon), Active(file), Inactive(file), SwapTotal,
SwapFree, CmaTotal, CmaFree). This is intended to provide a view of
overall system memory usage.

7 of these fields were newly added to the Debug class.

Test: statsd_testdrive 10092; verify that new fields are populated.
Bug: 260245141
Change-Id: I2da2732a6f6153e67a03d8b2f616627ca13935c7
This commit is contained in:
Kevin Jeon
2022-12-08 18:06:56 +00:00
parent 0aa22095e9
commit 9e04cb3c3c
4 changed files with 62 additions and 2 deletions

View File

@@ -1956,7 +1956,21 @@ public final class Debug
/** @hide */
public static final int MEMINFO_UNEVICTABLE = 18;
/** @hide */
public static final int MEMINFO_COUNT = 19;
public static final int MEMINFO_AVAILABLE = 19;
/** @hide */
public static final int MEMINFO_ACTIVE_ANON = 20;
/** @hide */
public static final int MEMINFO_INACTIVE_ANON = 21;
/** @hide */
public static final int MEMINFO_ACTIVE_FILE = 22;
/** @hide */
public static final int MEMINFO_INACTIVE_FILE = 23;
/** @hide */
public static final int MEMINFO_CMA_TOTAL = 24;
/** @hide */
public static final int MEMINFO_CMA_FREE = 25;
/** @hide */
public static final int MEMINFO_COUNT = 26;
/**
* Retrieves /proc/meminfo. outSizes is filled with fields

View File

@@ -587,6 +587,13 @@ enum {
MEMINFO_ACTIVE,
MEMINFO_INACTIVE,
MEMINFO_UNEVICTABLE,
MEMINFO_AVAILABLE,
MEMINFO_ACTIVE_ANON,
MEMINFO_INACTIVE_ANON,
MEMINFO_ACTIVE_FILE,
MEMINFO_INACTIVE_FILE,
MEMINFO_CMA_TOTAL,
MEMINFO_CMA_FREE,
MEMINFO_COUNT
};

View File

@@ -2408,7 +2408,20 @@ public class StatsPullAtomService extends SystemService {
metrics.gpuTotalUsageKb,
metrics.gpuPrivateAllocationsKb,
metrics.dmaBufTotalExportedKb,
metrics.shmemKb));
metrics.shmemKb,
metrics.totalKb,
metrics.freeKb,
metrics.availableKb,
metrics.activeKb,
metrics.inactiveKb,
metrics.activeAnonKb,
metrics.inactiveAnonKb,
metrics.activeFileKb,
metrics.inactiveFileKb,
metrics.swapTotalKb,
metrics.swapFreeKb,
metrics.cmaTotalKb,
metrics.cmaFreeKb));
return StatsManager.PULL_SUCCESS;
}

View File

@@ -83,6 +83,19 @@ final class SystemMemoryUtil {
result.pageTablesKb = (int) mInfos[Debug.MEMINFO_PAGE_TABLES];
result.kernelStackKb = (int) mInfos[Debug.MEMINFO_KERNEL_STACK];
result.shmemKb = (int) mInfos[Debug.MEMINFO_SHMEM];
result.totalKb = (int) mInfos[Debug.MEMINFO_TOTAL];
result.freeKb = (int) mInfos[Debug.MEMINFO_FREE];
result.availableKb = (int) mInfos[Debug.MEMINFO_AVAILABLE];
result.activeKb = (int) mInfos[Debug.MEMINFO_ACTIVE];
result.inactiveKb = (int) mInfos[Debug.MEMINFO_INACTIVE];
result.activeAnonKb = (int) mInfos[Debug.MEMINFO_ACTIVE_ANON];
result.inactiveAnonKb = (int) mInfos[Debug.MEMINFO_INACTIVE_ANON];
result.activeFileKb = (int) mInfos[Debug.MEMINFO_ACTIVE_FILE];
result.inactiveFileKb = (int) mInfos[Debug.MEMINFO_INACTIVE_FILE];
result.swapTotalKb = (int) mInfos[Debug.MEMINFO_SWAP_TOTAL];
result.swapFreeKb = (int) mInfos[Debug.MEMINFO_SWAP_FREE];
result.cmaTotalKb = (int) mInfos[Debug.MEMINFO_CMA_TOTAL];
result.cmaFreeKb = (int) mInfos[Debug.MEMINFO_CMA_FREE];
result.totalIonKb = totalIonKb;
result.gpuTotalUsageKb = gpuTotalUsageKb;
result.gpuPrivateAllocationsKb = gpuPrivateAllocationsKb;
@@ -97,6 +110,19 @@ final class SystemMemoryUtil {
public int pageTablesKb;
public int kernelStackKb;
public int shmemKb;
public int totalKb;
public int freeKb;
public int availableKb;
public int activeKb;
public int inactiveKb;
public int activeAnonKb;
public int inactiveAnonKb;
public int activeFileKb;
public int inactiveFileKb;
public int swapTotalKb;
public int swapFreeKb;
public int cmaTotalKb;
public int cmaFreeKb;
public int totalIonKb;
public int gpuTotalUsageKb;
public int gpuPrivateAllocationsKb;