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

Commit a3916fb3 authored by guolun Xue's avatar guolun Xue
Browse files

[Optimize][am_kill]add pss for process exit due to am_kill



There are so many processes in cache or other priority exit due to
am_kill, such as OnekeyClean, swipeup clean and so on. This processes
exit without pss can not show develop how much memory it can free.

Process which kill by lmkd can show memory detail, this patch aim to
have same effect with lmkd. If one abnormal memory using process exit, it can tell develop this process may have problem so develop can do something for this terrible process.

BUG:318323015

Signed-off-by: default avatar <xueguolun@xiaomi.corp-partner.google.com>
Change-Id: Ie0f9d599fc929d3055038f9a28e21b95e17fec38
parent bf88ecf8
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -31,7 +31,7 @@ option java_package com.android.server.am
30017 am_low_memory (Num Processes|1|1)

# Kill a process to reclaim memory.
30023 am_kill (User|1|5),(PID|1|5),(Process Name|3),(OomAdj|1|5),(Reason|3)
30023 am_kill (User|1|5),(PID|1|5),(Process Name|3),(OomAdj|1|5),(Reason|3),(Rss|2|2)
# Discard an undelivered serialized broadcast (timeout/ANR/crash)
30024 am_broadcast_discard_filter (User|1|5),(Broadcast|1|5),(Action|3),(Receiver Number|1|1),(BroadcastFilter|1|5)
30025 am_broadcast_discard_app (User|1|5),(Broadcast|1|5),(Action|3),(Receiver Number|1|1),(App|3)
+6 −1
Original line number Diff line number Diff line
@@ -105,6 +105,11 @@ public final class PhantomProcessRecord {
        }
    }

    public long getRss(int pid) {
        long[] rss = Process.getRss(pid);
        return (rss != null && rss.length > 0) ? rss[0] : 0;
    }

    @GuardedBy("mLock")
    void killLocked(String reason, boolean noisy) {
        if (!mKilled) {
@@ -115,7 +120,7 @@ public final class PhantomProcessRecord {
            }
            if (mPid > 0) {
                EventLog.writeEvent(EventLogTags.AM_KILL, UserHandle.getUserId(mUid),
                        mPid, mProcessName, mAdj, reason);
                        mPid, mProcessName, mAdj, reason, getRss(mPid));
                if (!Process.supportsPidFd()) {
                    onProcDied(false);
                } else {
+6 −1
Original line number Diff line number Diff line
@@ -1170,6 +1170,11 @@ class ProcessRecord implements WindowProcessListener {
        }
    }

    public long getRss(int pid) {
        long[] rss = Process.getRss(pid);
        return (rss != null && rss.length > 0) ? rss[0] : 0;
    }

    @GuardedBy("mService")
    void killLocked(String reason, @Reason int reasonCode, boolean noisy) {
        killLocked(reason, reasonCode, ApplicationExitInfo.SUBREASON_UNKNOWN, noisy, true);
@@ -1213,7 +1218,7 @@ class ProcessRecord implements WindowProcessListener {
            if (mPid > 0) {
                mService.mProcessList.noteAppKill(this, reasonCode, subReason, description);
                EventLog.writeEvent(EventLogTags.AM_KILL,
                        userId, mPid, processName, mState.getSetAdj(), reason);
                        userId, mPid, processName, mState.getSetAdj(), reason, getRss(mPid));
                Process.killProcessQuiet(mPid);
                killProcessGroupIfNecessaryLocked(asyncKPG);
            } else {