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

Commit 097f6985 authored by Michael Wachenschwanz's avatar Michael Wachenschwanz Committed by Android (Google) Code Review
Browse files

Merge "Consolidate the collectReachable algorithm to one implementation" into main

parents 2b5a8e70 6c638e57
Loading
Loading
Loading
Loading
+20 −4
Original line number Diff line number Diff line
@@ -670,6 +670,14 @@ public abstract class OomAdjuster {
        return topProcessState;
    }

    /**
     * Expand the provided {@code reachables} list with all processes reachable from those
     * provided in the list.
     */
    @GuardedBy({"mService", "mProcLock"})
    protected abstract void collectReachableProcessesLSP(
            @NonNull ArrayList<ProcessRecord> reachables);

    /**
     * Collect the reachable processes from the given {@code apps}, the result will be
     * returned in the given {@code processes}, which will include the processes from
@@ -2562,10 +2570,18 @@ public abstract class OomAdjuster {
        }

        final ArrayList<ProcessRecord> processes = mTmpProcessList;

        if (Flags.consolidateCollectReachable()) {
            processes.add(app);
            synchronized (mProcLock) {
                collectReachableProcessesLSP(processes);
            }
        } else {
            final ActiveUids uids = mTmpUidRecords;
            mTmpProcessSet.add(app);
            collectReachableProcessesLocked(mTmpProcessSet, processes, uids);
            mTmpProcessSet.clear();
        }
        // Now processes contains app's downstream and app
        final int size = processes.size();
        for (int i = 0; i < size; i++) {
+10 −0
Original line number Diff line number Diff line
@@ -1095,6 +1095,16 @@ public class OomAdjusterImpl extends OomAdjuster {
        postUpdateOomAdjInnerLSP(oomAdjReason, activeUids, now, nowElapsed, oldTime, false);
    }

    @GuardedBy({"mService", "mProcLock"})
    @Override
    protected void collectReachableProcessesLSP(@NonNull ArrayList<ProcessRecord> reachables) {
        collectAndMarkReachableProcessesLSP(reachables);
        for (int i = 0, size = reachables.size(); i < size; i++) {
            final ProcessStateRecord state = reachables.get(i).mState;
            state.setReachable(false);
        }
    }

    /**
     * Mark all processes reachable from the {@code reachables} processes and add them to the
     * provided {@code reachables} list (targets excluded).
+10 −0
Original line number Diff line number Diff line
@@ -340,3 +340,13 @@ flag {
    description: "Limit the number of logcat logs included to fit in dropbox entries"
    bug: "354138103"
}

flag {
    name: "consolidate_collect_reachable"
    namespace: "backstage_power"
    description: "Consolidate collectReachable usage to one implementation."
    bug: "364936739"
    metadata {
        purpose: PURPOSE_BUGFIX
    }
}
 No newline at end of file