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

Commit 3a8e5c50 authored by Makoto Onuki's avatar Makoto Onuki
Browse files

Fix "Tracking association..." logspam.

In the previous code, updateTrackingAssociationsLocked() was called too early.
There's still code that changes procstates, so let's move
updateTrackingAssociationsLocked() to the end of updateOomAdjLocked().

Also change Slog.w() to Slog.wtf() so we can monitor it on APR.

Also rate limit the WTF to at most one in ten seconds.

Bug: 118826162
Test: Boot with and without the fix and make sure the number of the warnings
reduces.
(We still have a couple WTFs from during a boot with this CL, which requires
further investigation.)

Change-Id: Ifa1fe85de82fa1d1d8f843372c54c1248966a62a
parent 20e5558d
Loading
Loading
Loading
Loading
+20 −3
Original line number Diff line number Diff line
@@ -1396,6 +1396,11 @@ public final class ProcessStats implements Parcelable {
        return as;
    }

    // See b/118826162 -- to avoid logspaming, we rate limit the WTF.
    private static final long INVERSE_PROC_STATE_WTF_MIN_INTERVAL_MS = 10_000L;
    private long mNextInverseProcStateWtfUptime;
    private int mSkippedInverseProcStateWtfCount;

    public void updateTrackingAssociationsLocked(int curSeq, long now) {
        final int NUM = mTrackingAssociations.size();
        for (int i = NUM - 1; i >= 0; i--) {
@@ -1417,12 +1422,24 @@ public final class ProcessStats implements Parcelable {
                    } else {
                        act.stopActive(now);
                        if (act.mProcState < procState) {
                            Slog.w(TAG, "Tracking association " + act + " whose proc state "
                            final long nowUptime = SystemClock.uptimeMillis();
                            if (mNextInverseProcStateWtfUptime > nowUptime) {
                                mSkippedInverseProcStateWtfCount++;
                            } else {
                                // TODO We still see it during boot related to GMS-core.
                                // b/118826162
                                Slog.wtf(TAG, "Tracking association " + act + " whose proc state "
                                        + act.mProcState + " is better than process " + proc
                                    + " proc state " + procState);
                                        + " proc state " + procState
                                        + " (" +  mSkippedInverseProcStateWtfCount + " skipped)");
                                mSkippedInverseProcStateWtfCount = 0;
                                mNextInverseProcStateWtfUptime =
                                        nowUptime + INVERSE_PROC_STATE_WTF_MIN_INTERVAL_MS;
                            }
                        }
                    }
                } else {
                    // Don't need rate limiting on it.
                    Slog.wtf(TAG, "Tracking association without process: " + act
                            + " in " + act.getAssociationState());
                }
+3 −2
Original line number Diff line number Diff line
@@ -17343,8 +17343,6 @@ public class ActivityManagerService extends IActivityManager.Stub
            }
        }
        mProcessStats.updateTrackingAssociationsLocked(mAdjSeq, now);
        incrementProcStateSeqAndNotifyAppsLocked();
        mNumServiceProcs = mNewNumServiceProcs;
@@ -17606,6 +17604,9 @@ public class ActivityManagerService extends IActivityManager.Stub
            mHandler.post(new ProcStatsRunnable(ActivityManagerService.this, mProcessStats));
        }
        // Run this after making sure all procstates are updated.
        mProcessStats.updateTrackingAssociationsLocked(mAdjSeq, now);
        if (DEBUG_OOM_ADJ) {
            final long duration = SystemClock.uptimeMillis() - now;
            if (false) {