Merge "Add the process oom adj score prior to the activity start" into tm-qpr-dev
This commit is contained in:
@@ -497,6 +497,7 @@ final class ProcessStateRecord {
|
|||||||
@GuardedBy({"mService", "mProcLock"})
|
@GuardedBy({"mService", "mProcLock"})
|
||||||
void setCurAdj(int curAdj) {
|
void setCurAdj(int curAdj) {
|
||||||
mCurAdj = curAdj;
|
mCurAdj = curAdj;
|
||||||
|
mApp.getWindowProcessController().setCurrentAdj(curAdj);
|
||||||
}
|
}
|
||||||
|
|
||||||
@GuardedBy(anyOf = {"mService", "mProcLock"})
|
@GuardedBy(anyOf = {"mService", "mProcLock"})
|
||||||
|
|||||||
@@ -70,6 +70,7 @@ import static com.android.internal.util.FrameworkStatsLog.CAMERA_COMPAT_CONTROL_
|
|||||||
import static com.android.internal.util.FrameworkStatsLog.CAMERA_COMPAT_CONTROL_EVENT_REPORTED__EVENT__CLICKED_REVERT_TREATMENT;
|
import static com.android.internal.util.FrameworkStatsLog.CAMERA_COMPAT_CONTROL_EVENT_REPORTED__EVENT__CLICKED_REVERT_TREATMENT;
|
||||||
import static com.android.server.am.MemoryStatUtil.MemoryStat;
|
import static com.android.server.am.MemoryStatUtil.MemoryStat;
|
||||||
import static com.android.server.am.MemoryStatUtil.readMemoryStatFromFilesystem;
|
import static com.android.server.am.MemoryStatUtil.readMemoryStatFromFilesystem;
|
||||||
|
import static com.android.server.am.ProcessList.INVALID_ADJ;
|
||||||
import static com.android.server.wm.ActivityTaskManagerDebugConfig.DEBUG_METRICS;
|
import static com.android.server.wm.ActivityTaskManagerDebugConfig.DEBUG_METRICS;
|
||||||
import static com.android.server.wm.ActivityTaskManagerDebugConfig.TAG_ATM;
|
import static com.android.server.wm.ActivityTaskManagerDebugConfig.TAG_ATM;
|
||||||
import static com.android.server.wm.ActivityTaskManagerDebugConfig.TAG_WITH_CLASS_NAME;
|
import static com.android.server.wm.ActivityTaskManagerDebugConfig.TAG_WITH_CLASS_NAME;
|
||||||
@@ -277,6 +278,8 @@ class ActivityMetricsLogger {
|
|||||||
final boolean mProcessSwitch;
|
final boolean mProcessSwitch;
|
||||||
/** The process state of the launching activity prior to the launch */
|
/** The process state of the launching activity prior to the launch */
|
||||||
final int mProcessState;
|
final int mProcessState;
|
||||||
|
/** The oom adj score of the launching activity prior to the launch */
|
||||||
|
final int mProcessOomAdj;
|
||||||
/** Whether the last launched activity has reported drawn. */
|
/** Whether the last launched activity has reported drawn. */
|
||||||
boolean mIsDrawn;
|
boolean mIsDrawn;
|
||||||
/** The latest activity to have been launched. */
|
/** The latest activity to have been launched. */
|
||||||
@@ -312,7 +315,7 @@ class ActivityMetricsLogger {
|
|||||||
@Nullable
|
@Nullable
|
||||||
static TransitionInfo create(@NonNull ActivityRecord r,
|
static TransitionInfo create(@NonNull ActivityRecord r,
|
||||||
@NonNull LaunchingState launchingState, @Nullable ActivityOptions options,
|
@NonNull LaunchingState launchingState, @Nullable ActivityOptions options,
|
||||||
boolean processRunning, boolean processSwitch, int processState,
|
boolean processRunning, boolean processSwitch, int processState, int processOomAdj,
|
||||||
boolean newActivityCreated, int startResult) {
|
boolean newActivityCreated, int startResult) {
|
||||||
if (startResult != START_SUCCESS && startResult != START_TASK_TO_FRONT) {
|
if (startResult != START_SUCCESS && startResult != START_TASK_TO_FRONT) {
|
||||||
return null;
|
return null;
|
||||||
@@ -328,19 +331,20 @@ class ActivityMetricsLogger {
|
|||||||
transitionType = TYPE_TRANSITION_COLD_LAUNCH;
|
transitionType = TYPE_TRANSITION_COLD_LAUNCH;
|
||||||
}
|
}
|
||||||
return new TransitionInfo(r, launchingState, options, transitionType, processRunning,
|
return new TransitionInfo(r, launchingState, options, transitionType, processRunning,
|
||||||
processSwitch, processState);
|
processSwitch, processState, processOomAdj);
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Use {@link TransitionInfo#create} instead to ensure the transition type is valid. */
|
/** Use {@link TransitionInfo#create} instead to ensure the transition type is valid. */
|
||||||
private TransitionInfo(ActivityRecord r, LaunchingState launchingState,
|
private TransitionInfo(ActivityRecord r, LaunchingState launchingState,
|
||||||
ActivityOptions options, int transitionType, boolean processRunning,
|
ActivityOptions options, int transitionType, boolean processRunning,
|
||||||
boolean processSwitch, int processState) {
|
boolean processSwitch, int processState, int processOomAdj) {
|
||||||
mLaunchingState = launchingState;
|
mLaunchingState = launchingState;
|
||||||
mTransitionStartTimeNs = launchingState.mCurrentTransitionStartTimeNs;
|
mTransitionStartTimeNs = launchingState.mCurrentTransitionStartTimeNs;
|
||||||
mTransitionType = transitionType;
|
mTransitionType = transitionType;
|
||||||
mProcessRunning = processRunning;
|
mProcessRunning = processRunning;
|
||||||
mProcessSwitch = processSwitch;
|
mProcessSwitch = processSwitch;
|
||||||
mProcessState = processState;
|
mProcessState = processState;
|
||||||
|
mProcessOomAdj = processOomAdj;
|
||||||
mTransitionDeviceUptimeMs = launchingState.mCurrentUpTimeMs;
|
mTransitionDeviceUptimeMs = launchingState.mCurrentUpTimeMs;
|
||||||
setLatestLaunchedActivity(r);
|
setLatestLaunchedActivity(r);
|
||||||
// The launching state can be reused by consecutive launch. Its original association
|
// The launching state can be reused by consecutive launch. Its original association
|
||||||
@@ -644,9 +648,15 @@ class ActivityMetricsLogger {
|
|||||||
// interesting.
|
// interesting.
|
||||||
final boolean processSwitch = !processRunning
|
final boolean processSwitch = !processRunning
|
||||||
|| !processRecord.hasStartedActivity(launchedActivity);
|
|| !processRecord.hasStartedActivity(launchedActivity);
|
||||||
final int processState = processRunning
|
final int processState;
|
||||||
? processRecord.getCurrentProcState()
|
final int processOomAdj;
|
||||||
: PROCESS_STATE_NONEXISTENT;
|
if (processRunning) {
|
||||||
|
processState = processRecord.getCurrentProcState();
|
||||||
|
processOomAdj = processRecord.getCurrentAdj();
|
||||||
|
} else {
|
||||||
|
processState = PROCESS_STATE_NONEXISTENT;
|
||||||
|
processOomAdj = INVALID_ADJ;
|
||||||
|
}
|
||||||
|
|
||||||
final TransitionInfo info = launchingState.mAssociatedTransitionInfo;
|
final TransitionInfo info = launchingState.mAssociatedTransitionInfo;
|
||||||
if (DEBUG_METRICS) {
|
if (DEBUG_METRICS) {
|
||||||
@@ -654,6 +664,7 @@ class ActivityMetricsLogger {
|
|||||||
+ " launchedActivity=" + launchedActivity + " processRunning=" + processRunning
|
+ " launchedActivity=" + launchedActivity + " processRunning=" + processRunning
|
||||||
+ " processSwitch=" + processSwitch
|
+ " processSwitch=" + processSwitch
|
||||||
+ " processState=" + processState
|
+ " processState=" + processState
|
||||||
|
+ " processOomAdj=" + processOomAdj
|
||||||
+ " newActivityCreated=" + newActivityCreated + " info=" + info);
|
+ " newActivityCreated=" + newActivityCreated + " info=" + info);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -689,8 +700,8 @@ class ActivityMetricsLogger {
|
|||||||
}
|
}
|
||||||
|
|
||||||
final TransitionInfo newInfo = TransitionInfo.create(launchedActivity, launchingState,
|
final TransitionInfo newInfo = TransitionInfo.create(launchedActivity, launchingState,
|
||||||
options, processRunning, processSwitch, processState, newActivityCreated,
|
options, processRunning, processSwitch, processState, processOomAdj,
|
||||||
resultCode);
|
newActivityCreated, resultCode);
|
||||||
if (newInfo == null) {
|
if (newInfo == null) {
|
||||||
abort(launchingState, "unrecognized launch");
|
abort(launchingState, "unrecognized launch");
|
||||||
return;
|
return;
|
||||||
@@ -1005,8 +1016,10 @@ class ActivityMetricsLogger {
|
|||||||
final long uptime = info.mTransitionDeviceUptimeMs;
|
final long uptime = info.mTransitionDeviceUptimeMs;
|
||||||
final int transitionDelay = info.mCurrentTransitionDelayMs;
|
final int transitionDelay = info.mCurrentTransitionDelayMs;
|
||||||
final int processState = info.mProcessState;
|
final int processState = info.mProcessState;
|
||||||
|
final int processOomAdj = info.mProcessOomAdj;
|
||||||
mLoggerHandler.post(() -> logAppTransition(
|
mLoggerHandler.post(() -> logAppTransition(
|
||||||
timestamp, uptime, transitionDelay, infoSnapshot, isHibernating, processState));
|
timestamp, uptime, transitionDelay, infoSnapshot, isHibernating,
|
||||||
|
processState, processOomAdj));
|
||||||
}
|
}
|
||||||
mLoggerHandler.post(() -> logAppDisplayed(infoSnapshot));
|
mLoggerHandler.post(() -> logAppDisplayed(infoSnapshot));
|
||||||
if (info.mPendingFullyDrawn != null) {
|
if (info.mPendingFullyDrawn != null) {
|
||||||
@@ -1019,7 +1032,7 @@ class ActivityMetricsLogger {
|
|||||||
// This gets called on another thread without holding the activity manager lock.
|
// This gets called on another thread without holding the activity manager lock.
|
||||||
private void logAppTransition(long transitionStartTimeNs, long transitionDeviceUptimeMs,
|
private void logAppTransition(long transitionStartTimeNs, long transitionDeviceUptimeMs,
|
||||||
int currentTransitionDelayMs, TransitionInfoSnapshot info, boolean isHibernating,
|
int currentTransitionDelayMs, TransitionInfoSnapshot info, boolean isHibernating,
|
||||||
int processState) {
|
int processState, int processOomAdj) {
|
||||||
final LogMaker builder = new LogMaker(APP_TRANSITION);
|
final LogMaker builder = new LogMaker(APP_TRANSITION);
|
||||||
builder.setPackageName(info.packageName);
|
builder.setPackageName(info.packageName);
|
||||||
builder.setType(info.type);
|
builder.setType(info.type);
|
||||||
@@ -1086,7 +1099,8 @@ class ActivityMetricsLogger {
|
|||||||
isLoading,
|
isLoading,
|
||||||
info.launchedActivityName.hashCode(),
|
info.launchedActivityName.hashCode(),
|
||||||
TimeUnit.NANOSECONDS.toMillis(transitionStartTimeNs),
|
TimeUnit.NANOSECONDS.toMillis(transitionStartTimeNs),
|
||||||
processState);
|
processState,
|
||||||
|
processOomAdj);
|
||||||
|
|
||||||
if (DEBUG_METRICS) {
|
if (DEBUG_METRICS) {
|
||||||
Slog.i(TAG, String.format("APP_START_OCCURRED(%s, %s, %s, %s, %s)",
|
Slog.i(TAG, String.format("APP_START_OCCURRED(%s, %s, %s, %s, %s)",
|
||||||
|
|||||||
@@ -25,6 +25,7 @@ import static android.os.InputConstants.DEFAULT_DISPATCHING_TIMEOUT_MILLIS;
|
|||||||
|
|
||||||
import static com.android.internal.protolog.ProtoLogGroup.WM_DEBUG_CONFIGURATION;
|
import static com.android.internal.protolog.ProtoLogGroup.WM_DEBUG_CONFIGURATION;
|
||||||
import static com.android.internal.util.Preconditions.checkArgument;
|
import static com.android.internal.util.Preconditions.checkArgument;
|
||||||
|
import static com.android.server.am.ProcessList.INVALID_ADJ;
|
||||||
import static com.android.server.wm.ActivityRecord.State.DESTROYED;
|
import static com.android.server.wm.ActivityRecord.State.DESTROYED;
|
||||||
import static com.android.server.wm.ActivityRecord.State.DESTROYING;
|
import static com.android.server.wm.ActivityRecord.State.DESTROYING;
|
||||||
import static com.android.server.wm.ActivityRecord.State.PAUSED;
|
import static com.android.server.wm.ActivityRecord.State.PAUSED;
|
||||||
@@ -123,6 +124,8 @@ public class WindowProcessController extends ConfigurationContainer<Configuratio
|
|||||||
private volatile int mCurProcState = PROCESS_STATE_NONEXISTENT;
|
private volatile int mCurProcState = PROCESS_STATE_NONEXISTENT;
|
||||||
// Last reported process state;
|
// Last reported process state;
|
||||||
private volatile int mRepProcState = PROCESS_STATE_NONEXISTENT;
|
private volatile int mRepProcState = PROCESS_STATE_NONEXISTENT;
|
||||||
|
// Currently computed oom adj score
|
||||||
|
private volatile int mCurAdj = INVALID_ADJ;
|
||||||
// are we in the process of crashing?
|
// are we in the process of crashing?
|
||||||
private volatile boolean mCrashing;
|
private volatile boolean mCrashing;
|
||||||
// does the app have a not responding dialog?
|
// does the app have a not responding dialog?
|
||||||
@@ -317,6 +320,14 @@ public class WindowProcessController extends ConfigurationContainer<Configuratio
|
|||||||
return mCurProcState;
|
return mCurProcState;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void setCurrentAdj(int curAdj) {
|
||||||
|
mCurAdj = curAdj;
|
||||||
|
}
|
||||||
|
|
||||||
|
int getCurrentAdj() {
|
||||||
|
return mCurAdj;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Sets the computed process state from the oom adjustment calculation. This is frequently
|
* Sets the computed process state from the oom adjustment calculation. This is frequently
|
||||||
* called in activity manager's lock, so don't use window manager lock here.
|
* called in activity manager's lock, so don't use window manager lock here.
|
||||||
|
|||||||
Reference in New Issue
Block a user