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

Commit eb3382ca authored by TreeHugger Robot's avatar TreeHugger Robot Committed by Android (Google) Code Review
Browse files

Merge "Delete rss_high_watermark_in_bytes field"

parents b5ed9158 d03ae420
Loading
Loading
Loading
Loading
+2 −7
Original line number Diff line number Diff line
@@ -2543,10 +2543,7 @@ message ProcessMemoryState {
    // SWAP
    optional int64 swap_in_bytes = 8;

    // RSS high watermark.
    // Peak RSS usage of the process. Value is read from the VmHWM field in /proc/PID/status or
    // from memory.max_usage_in_bytes under /dev/memcg if the device uses per-app memory cgroups.
    // Deprecated: use ProcessMemoryHighWaterMark atom instead.
    // Deprecated: use ProcessMemoryHighWaterMark atom instead. Always 0.
    optional int64 rss_high_watermark_in_bytes = 9 [deprecated = true];

    // Elapsed real time when the process started.
@@ -2573,9 +2570,7 @@ message NativeProcessMemoryState {
    // RSS
    optional int64 rss_in_bytes = 5;

    // RSS high watermark.
    // Peak RSS usage of the process. Value is read from the VmHWM field in /proc/PID/status.
    // Deprecated: use ProcessMemoryHighWaterMark atom instead.
    // Deprecated: use ProcessMemoryHighWaterMark atom instead. Always 0.
    optional int64 rss_high_watermark_in_bytes = 6 [deprecated = true];

    // Elapsed real time when the process started.
+1 −6
Original line number Diff line number Diff line
@@ -32,13 +32,11 @@ public final class ProcessMemoryState implements Parcelable {
    public final long rssInBytes;
    public final long cacheInBytes;
    public final long swapInBytes;
    // TODO(rslawik): Delete this field once ProcessMemoryHighWaterMark is ready.
    public final long rssHighWatermarkInBytes;
    public final long startTimeNanos;

    public ProcessMemoryState(int uid, String processName, int oomScore, long pgfault,
                              long pgmajfault, long rssInBytes, long cacheInBytes,
                              long swapInBytes, long rssHighWatermarkInBytes, long startTimeNanos) {
                              long swapInBytes, long startTimeNanos) {
        this.uid = uid;
        this.processName = processName;
        this.oomScore = oomScore;
@@ -47,7 +45,6 @@ public final class ProcessMemoryState implements Parcelable {
        this.rssInBytes = rssInBytes;
        this.cacheInBytes = cacheInBytes;
        this.swapInBytes = swapInBytes;
        this.rssHighWatermarkInBytes = rssHighWatermarkInBytes;
        this.startTimeNanos = startTimeNanos;
    }

@@ -60,7 +57,6 @@ public final class ProcessMemoryState implements Parcelable {
        rssInBytes = in.readLong();
        cacheInBytes = in.readLong();
        swapInBytes = in.readLong();
        rssHighWatermarkInBytes = in.readLong();
        startTimeNanos = in.readLong();
    }

@@ -91,7 +87,6 @@ public final class ProcessMemoryState implements Parcelable {
        parcel.writeLong(rssInBytes);
        parcel.writeLong(cacheInBytes);
        parcel.writeLong(swapInBytes);
        parcel.writeLong(rssHighWatermarkInBytes);
        parcel.writeLong(startTimeNanos);
    }
}
+0 −2
Original line number Diff line number Diff line
@@ -18912,7 +18912,6 @@ public class ActivityManagerService extends IActivityManager.Stub
                    if (memoryStat == null) {
                        continue;
                    }
                    // TODO(rslawik): Delete RSS high-water mark field.
                    ProcessMemoryState processMemoryState =
                            new ProcessMemoryState(uid,
                                    r.processName,
@@ -18922,7 +18921,6 @@ public class ActivityManagerService extends IActivityManager.Stub
                                    memoryStat.rssInBytes,
                                    memoryStat.cacheInBytes,
                                    memoryStat.swapInBytes,
                                    memoryStat.rssHighWatermarkInBytes,
                                    memoryStat.startTimeNanos);
                    processMemoryStates.add(processMemoryState);
                }
+2 −34
Original line number Diff line number Diff line
@@ -49,13 +49,8 @@ public final class MemoryStatUtil {
    private static final boolean DEVICE_HAS_PER_APP_MEMCG =
            SystemProperties.getBoolean("ro.config.per_app_memcg", false);

    /** Path to check if device has memcg */
    private static final String MEMCG_TEST_PATH = "/dev/memcg/apps/memory.stat";
    /** Path to memory stat file for logging app start memory state */
    private static final String MEMORY_STAT_FILE_FMT = "/dev/memcg/apps/uid_%d/pid_%d/memory.stat";
    /** Path to memory max usage file for logging app memory state */
    private static final String MEMORY_MAX_USAGE_FILE_FMT =
            "/dev/memcg/apps/uid_%d/pid_%d/memory.max_usage_in_bytes";
    /** Path to procfs stat file for logging app start memory state */
    private static final String PROC_STAT_FILE_FMT = "/proc/%d/stat";
    /** Path to procfs status file for logging app memory state */
@@ -98,14 +93,7 @@ public final class MemoryStatUtil {
    @Nullable
    static MemoryStat readMemoryStatFromMemcg(int uid, int pid) {
        final String statPath = String.format(Locale.US, MEMORY_STAT_FILE_FMT, uid, pid);
        MemoryStat stat = parseMemoryStatFromMemcg(readFileContents(statPath));
        if (stat == null) {
            return null;
        }
        String maxUsagePath = String.format(Locale.US, MEMORY_MAX_USAGE_FILE_FMT, uid, pid);
        stat.rssHighWatermarkInBytes = parseMemoryMaxUsageFromMemCg(
                readFileContents(maxUsagePath));
        return stat;
        return parseMemoryStatFromMemcg(readFileContents(statPath));
    }

    /**
@@ -116,12 +104,7 @@ public final class MemoryStatUtil {
    @Nullable
    public static MemoryStat readMemoryStatFromProcfs(int pid) {
        final String statPath = String.format(Locale.US, PROC_STAT_FILE_FMT, pid);
        MemoryStat stat = parseMemoryStatFromProcfs(readFileContents(statPath));
        if (stat == null) {
            return null;
        }
        stat.rssHighWatermarkInBytes = readRssHighWaterMarkFromProcfs(pid);
        return stat;
        return parseMemoryStatFromProcfs(readFileContents(statPath));
    }

    /**
@@ -185,19 +168,6 @@ public final class MemoryStatUtil {
        return memoryStat;
    }

    @VisibleForTesting
    static long parseMemoryMaxUsageFromMemCg(String memoryMaxUsageContents) {
        if (memoryMaxUsageContents == null || memoryMaxUsageContents.isEmpty()) {
            return 0;
        }
        try {
            return Long.parseLong(memoryMaxUsageContents);
        } catch (NumberFormatException e) {
            Slog.e(TAG, "Failed to parse value", e);
            return 0;
        }
    }

    /**
     * Parses relevant statistics out from the contents of the /proc/pid/stat file in procfs.
     */
@@ -258,8 +228,6 @@ public final class MemoryStatUtil {
        public long cacheInBytes;
        /** Number of bytes of swap usage */
        public long swapInBytes;
        /** Number of bytes of peak anonymous and swap cache memory */
        public long rssHighWatermarkInBytes;
        /** Device time when the processes started. */
        public long startTimeNanos;
    }
+2 −2
Original line number Diff line number Diff line
@@ -1080,7 +1080,7 @@ public class StatsCompanionService extends IStatsCompanionService.Stub {
            e.writeLong(processMemoryState.rssInBytes);
            e.writeLong(processMemoryState.cacheInBytes);
            e.writeLong(processMemoryState.swapInBytes);
            e.writeLong(processMemoryState.rssHighWatermarkInBytes);
            e.writeLong(0);  // unused
            e.writeLong(processMemoryState.startTimeNanos);
            pulledData.add(e);
        }
@@ -1104,7 +1104,7 @@ public class StatsCompanionService extends IStatsCompanionService.Stub {
            e.writeLong(memoryStat.pgfault);
            e.writeLong(memoryStat.pgmajfault);
            e.writeLong(memoryStat.rssInBytes);
            e.writeLong(memoryStat.rssHighWatermarkInBytes);
            e.writeLong(0);  // unused
            e.writeLong(memoryStat.startTimeNanos);
            pulledData.add(e);
        }
Loading