OomAdjuster: skip persistent/system processes in cycle detection

Apps with negative oom_adj scores are either system_server or
persistent. As a result, those apps don't need to be considered in
cycle detection because no binding to that app can possibly promote
the persistent process to a more important process state.

Bug: 260854804
Test: atest MockingOomAdjusterTests

Change-Id: I632dc41a5660935b9c49af3c01243314dab4cc0a
This commit is contained in:
Tim Murray
2022-11-30 10:34:10 -08:00
parent 465e1a92e7
commit 17072cefab

View File

@@ -704,7 +704,9 @@ public class OomAdjuster {
ConnectionRecord cr = psr.getConnectionAt(i);
ProcessRecord service = (cr.flags & ServiceInfo.FLAG_ISOLATED_PROCESS) != 0
? cr.binding.service.isolationHostProc : cr.binding.service.app;
if (service == null || service == pr) {
if (service == null || service == pr
|| ((service.mState.getMaxAdj() >= ProcessList.SYSTEM_ADJ)
&& (service.mState.getMaxAdj() < FOREGROUND_APP_ADJ))) {
continue;
}
containsCycle |= service.mState.isReachable();
@@ -724,7 +726,9 @@ public class OomAdjuster {
for (int i = ppr.numberOfProviderConnections() - 1; i >= 0; i--) {
ContentProviderConnection cpc = ppr.getProviderConnectionAt(i);
ProcessRecord provider = cpc.provider.proc;
if (provider == null || provider == pr) {
if (provider == null || provider == pr
|| ((provider.mState.getMaxAdj() >= ProcessList.SYSTEM_ADJ)
&& (provider.mState.getMaxAdj() < FOREGROUND_APP_ADJ))) {
continue;
}
containsCycle |= provider.mState.isReachable();