Loading services/core/java/com/android/server/stats/pull/ProcfsMemoryUtil.java +8 −4 Original line number Diff line number Diff line Loading @@ -28,7 +28,8 @@ public final class ProcfsMemoryUtil { "VmHWM:", "VmRSS:", "RssAnon:", "VmSwap:" "RssShmem:", "VmSwap:", }; private static final String[] VMSTAT_KEYS = new String[] { "oom_kill" Loading @@ -38,7 +39,7 @@ public final class ProcfsMemoryUtil { /** * Reads memory stats of a process from procfs. Returns values of the VmHWM, VmRss, AnonRSS, * VmSwap fields in /proc/pid/status in kilobytes or null if not available. * VmSwap, RssShmem fields in /proc/pid/status in kilobytes or null if not available. */ @Nullable public static MemorySnapshot readMemorySnapshotFromProcfs(int pid) { Loading @@ -46,8 +47,9 @@ public final class ProcfsMemoryUtil { output[0] = -1; output[3] = -1; output[4] = -1; output[5] = -1; Process.readProcLines("/proc/" + pid + "/status", STATUS_KEYS, output); if (output[0] == -1 || output[3] == -1 || output[4] == -1) { if (output[0] == -1 || output[3] == -1 || output[4] == -1 || output[5] == -1) { // Could not open or parse file. return null; } Loading @@ -56,7 +58,8 @@ public final class ProcfsMemoryUtil { snapshot.rssHighWaterMarkInKilobytes = (int) output[1]; snapshot.rssInKilobytes = (int) output[2]; snapshot.anonRssInKilobytes = (int) output[3]; snapshot.swapInKilobytes = (int) output[4]; snapshot.rssShmemKilobytes = (int) output[4]; snapshot.swapInKilobytes = (int) output[5]; return snapshot; } Loading Loading @@ -101,6 +104,7 @@ public final class ProcfsMemoryUtil { public int rssInKilobytes; public int anonRssInKilobytes; public int swapInKilobytes; public int rssShmemKilobytes; } /** Reads and parses selected entries of /proc/vmstat. */ Loading services/core/java/com/android/server/stats/pull/StatsPullAtomService.java +4 −2 Original line number Diff line number Diff line Loading @@ -2290,7 +2290,8 @@ public class StatsPullAtomService extends SystemService { managedProcess.processName, managedProcess.pid, managedProcess.oomScore, snapshot.rssInKilobytes, snapshot.anonRssInKilobytes, snapshot.swapInKilobytes, snapshot.anonRssInKilobytes + snapshot.swapInKilobytes, gpuMemPerPid.get(managedProcess.pid), managedProcess.hasForegroundServices)); gpuMemPerPid.get(managedProcess.pid), managedProcess.hasForegroundServices, snapshot.rssShmemKilobytes)); } // Complement the data with native system processes. Given these measurements can be taken // in response to LMKs happening, we want to first collect the managed app stats (to Loading @@ -2309,7 +2310,8 @@ public class StatsPullAtomService extends SystemService { -1001 /*Placeholder for native processes, OOM_SCORE_ADJ_MIN - 1.*/, snapshot.rssInKilobytes, snapshot.anonRssInKilobytes, snapshot.swapInKilobytes, snapshot.anonRssInKilobytes + snapshot.swapInKilobytes, gpuMemPerPid.get(pid), false /* has_foreground_services */)); gpuMemPerPid.get(pid), false /* has_foreground_services */, snapshot.rssShmemKilobytes)); } return StatsManager.PULL_SUCCESS; } Loading Loading
services/core/java/com/android/server/stats/pull/ProcfsMemoryUtil.java +8 −4 Original line number Diff line number Diff line Loading @@ -28,7 +28,8 @@ public final class ProcfsMemoryUtil { "VmHWM:", "VmRSS:", "RssAnon:", "VmSwap:" "RssShmem:", "VmSwap:", }; private static final String[] VMSTAT_KEYS = new String[] { "oom_kill" Loading @@ -38,7 +39,7 @@ public final class ProcfsMemoryUtil { /** * Reads memory stats of a process from procfs. Returns values of the VmHWM, VmRss, AnonRSS, * VmSwap fields in /proc/pid/status in kilobytes or null if not available. * VmSwap, RssShmem fields in /proc/pid/status in kilobytes or null if not available. */ @Nullable public static MemorySnapshot readMemorySnapshotFromProcfs(int pid) { Loading @@ -46,8 +47,9 @@ public final class ProcfsMemoryUtil { output[0] = -1; output[3] = -1; output[4] = -1; output[5] = -1; Process.readProcLines("/proc/" + pid + "/status", STATUS_KEYS, output); if (output[0] == -1 || output[3] == -1 || output[4] == -1) { if (output[0] == -1 || output[3] == -1 || output[4] == -1 || output[5] == -1) { // Could not open or parse file. return null; } Loading @@ -56,7 +58,8 @@ public final class ProcfsMemoryUtil { snapshot.rssHighWaterMarkInKilobytes = (int) output[1]; snapshot.rssInKilobytes = (int) output[2]; snapshot.anonRssInKilobytes = (int) output[3]; snapshot.swapInKilobytes = (int) output[4]; snapshot.rssShmemKilobytes = (int) output[4]; snapshot.swapInKilobytes = (int) output[5]; return snapshot; } Loading Loading @@ -101,6 +104,7 @@ public final class ProcfsMemoryUtil { public int rssInKilobytes; public int anonRssInKilobytes; public int swapInKilobytes; public int rssShmemKilobytes; } /** Reads and parses selected entries of /proc/vmstat. */ Loading
services/core/java/com/android/server/stats/pull/StatsPullAtomService.java +4 −2 Original line number Diff line number Diff line Loading @@ -2290,7 +2290,8 @@ public class StatsPullAtomService extends SystemService { managedProcess.processName, managedProcess.pid, managedProcess.oomScore, snapshot.rssInKilobytes, snapshot.anonRssInKilobytes, snapshot.swapInKilobytes, snapshot.anonRssInKilobytes + snapshot.swapInKilobytes, gpuMemPerPid.get(managedProcess.pid), managedProcess.hasForegroundServices)); gpuMemPerPid.get(managedProcess.pid), managedProcess.hasForegroundServices, snapshot.rssShmemKilobytes)); } // Complement the data with native system processes. Given these measurements can be taken // in response to LMKs happening, we want to first collect the managed app stats (to Loading @@ -2309,7 +2310,8 @@ public class StatsPullAtomService extends SystemService { -1001 /*Placeholder for native processes, OOM_SCORE_ADJ_MIN - 1.*/, snapshot.rssInKilobytes, snapshot.anonRssInKilobytes, snapshot.swapInKilobytes, snapshot.anonRssInKilobytes + snapshot.swapInKilobytes, gpuMemPerPid.get(pid), false /* has_foreground_services */)); gpuMemPerPid.get(pid), false /* has_foreground_services */, snapshot.rssShmemKilobytes)); } return StatsManager.PULL_SUCCESS; } Loading