diff options
author | V S Ganga VaraPrasad (VARA) Adabala <quic_vadabala@quicinc.com> | 2022-04-26 00:19:43 +0530 |
---|---|---|
committer | V S Ganga VaraPrasad (VARA) Adabala <quic_vadabala@quicinc.com> | 2022-04-26 00:19:43 +0530 |
commit | 353533af41298a9fd2ad7cf5de8a476974df10f9 (patch) | |
tree | 55e0faf09f5f9137fd8f3d46b22a47d868483c8e /services | |
parent | 577642b25a65a1e681731ac4e4fe1e72802f15c8 (diff) |
Improve compaction to abort when system changes to awake state
While the screen is off we sometimes issue compactions as they are not
disruptive to the user. However, it is possible to wake up and have
compactions running or scheduled so this may lead to jank. This patch
cancels any pending or running compactions that were scheduled to happen
during this non interactive type when the system becomes awake to avoid
jank.
Test: Manual
Bug: 214654755
CRs-Fixed:3121545
Change-Id: Ie9b2cbaa7093d63e77f8666d1e6f050ab5610a1d
(cherry picked from commit 00fe2b907bf684b0030d1e95b52c84c88d27b48f)
Change-Id: I8dceb1e75562b3e5b33b1aeec3357eaaabfdde4f
Diffstat (limited to 'services')
4 files changed, 16 insertions, 0 deletions
diff --git a/services/core/java/com/android/server/am/ActivityManagerService.java b/services/core/java/com/android/server/am/ActivityManagerService.java index 3e3a4a51f372..dbdb2ab54e89 100644 --- a/services/core/java/com/android/server/am/ActivityManagerService.java +++ b/services/core/java/com/android/server/am/ActivityManagerService.java @@ -6447,6 +6447,7 @@ public class ActivityManagerService extends IActivityManager.Stub reportCurWakefulnessUsageEvent(); mActivityTaskManager.onScreenAwakeChanged(isAwake); mOomAdjProfiler.onWakefulnessChanged(wakefulness); + mOomAdjuster.onWakefulnessChanged(wakefulness); } updateOomAdjLocked(OomAdjuster.OOM_ADJ_REASON_UI_VISIBILITY); } diff --git a/services/core/java/com/android/server/am/CachedAppOptimizer.java b/services/core/java/com/android/server/am/CachedAppOptimizer.java index 2761a7c6d937..6ee41eff1fcf 100644 --- a/services/core/java/com/android/server/am/CachedAppOptimizer.java +++ b/services/core/java/com/android/server/am/CachedAppOptimizer.java @@ -28,6 +28,7 @@ import android.net.Uri; import android.os.Debug; import android.os.Handler; import android.os.Message; +import android.os.PowerManagerInternal; import android.os.Process; import android.os.SystemClock; import android.os.SystemProperties; @@ -1127,6 +1128,15 @@ public final class CachedAppOptimizer { } } + void onWakefulnessChanged(int wakefulness) { + if(wakefulness == PowerManagerInternal.WAKEFULNESS_AWAKE) { + // Remove any pending compaction we may have scheduled to happen while screen was off + Slog.e(TAG_AM, "Cancel pending or running compactions as system is awake"); + mPendingCompactionProcesses.clear(); + cancelCompaction(); + } + } + @GuardedBy({"mService", "mProcLock"}) void onOomAdjustChanged(int oldAdj, int newAdj, ProcessRecord app) { // Cancel any currently executing compactions diff --git a/services/core/java/com/android/server/am/OomAdjuster.java b/services/core/java/com/android/server/am/OomAdjuster.java index e94c2fa60fc1..2ed6fc483e31 100644 --- a/services/core/java/com/android/server/am/OomAdjuster.java +++ b/services/core/java/com/android/server/am/OomAdjuster.java @@ -2687,6 +2687,10 @@ public class OomAdjuster { } } + void onWakefulnessChanged(int wakefulness) { + mCachedAppOptimizer.onWakefulnessChanged(wakefulness); + } + /** Applies the computed oomadj, procstate and sched group values and freezes them in set* */ @GuardedBy({"mService", "mProcLock"}) private boolean applyOomAdjLSP(ProcessRecord app, boolean doingAll, long now, diff --git a/services/core/jni/com_android_server_am_CachedAppOptimizer.cpp b/services/core/jni/com_android_server_am_CachedAppOptimizer.cpp index 0271277acb7a..636ca4143a33 100644 --- a/services/core/jni/com_android_server_am_CachedAppOptimizer.cpp +++ b/services/core/jni/com_android_server_am_CachedAppOptimizer.cpp @@ -113,6 +113,7 @@ static int64_t compactMemory(const std::vector<Vma>& vmas, int pid, int madviseT // There could be a significant delay between when a compaction // is requested and when it is handled during this time our // OOM adjust could have improved. + LOG(DEBUG) << "Cancelled running compaction for " << pid; break; } |