From a636b0b4b6d7c4794b3a3bc7dde943f78a38db92 Mon Sep 17 00:00:00 2001 From: Tim Murray Date: Wed, 27 Jul 2016 15:07:00 -0700 Subject: [PATCH] Increase UI and RenderThread priority when not using FIFO. bug 30441279 Change-Id: I5714179236af59ce79dbe118c7870d5f1771168a --- .../android/server/am/ActivityManagerService.java | 22 +++++++++++++++++++--- 1 file changed, 19 insertions(+), 3 deletions(-) diff --git a/services/core/java/com/android/server/am/ActivityManagerService.java b/services/core/java/com/android/server/am/ActivityManagerService.java index 8e4af12f2d0e..71280be76f5e 100644 --- a/services/core/java/com/android/server/am/ActivityManagerService.java +++ b/services/core/java/com/android/server/am/ActivityManagerService.java @@ -12585,7 +12585,7 @@ public final class ActivityManagerService extends ActivityManagerNative synchronized (mPidsSelfLocked) { int pid = Binder.getCallingPid(); proc = mPidsSelfLocked.get(pid); - if (mUseFifoUiScheduling && proc != null && proc.renderThreadTid == 0 && tid > 0) { + if (proc != null && proc.renderThreadTid == 0 && tid > 0) { // ensure the tid belongs to the process if (!Process.isThreadInProcess(pid, tid)) { throw new IllegalArgumentException( @@ -12598,8 +12598,12 @@ public final class ActivityManagerService extends ActivityManagerNative // promote to FIFO now if (proc.curSchedGroup == ProcessList.SCHED_GROUP_TOP_APP) { if (DEBUG_OOM_ADJ) Slog.d("UI_FIFO", "Promoting " + tid + "out of band"); - Process.setThreadScheduler(proc.renderThreadTid, - Process.SCHED_FIFO | Process.SCHED_RESET_ON_FORK, 1); + if (mUseFifoUiScheduling) { + Process.setThreadScheduler(proc.renderThreadTid, + Process.SCHED_FIFO | Process.SCHED_RESET_ON_FORK, 1); + } else { + Process.setThreadPriority(proc.renderThreadTid, -10); + } } } else { if (DEBUG_OOM_ADJ) { @@ -20294,6 +20298,12 @@ public final class ActivityManagerService extends ActivityManagerNative Slog.d("UI_FIFO", "Not setting RenderThread TID"); } } + } else { + // Boost priority for top app UI and render threads + Process.setThreadPriority(app.pid, -10); + if (app.renderThreadTid != 0) { + Process.setThreadPriority(app.renderThreadTid, -10); + } } } } else if (oldSchedGroup == ProcessList.SCHED_GROUP_TOP_APP && @@ -20312,6 +20322,12 @@ public final class ActivityManagerService extends ActivityManagerNative Process.SCHED_OTHER, 0); Process.setThreadPriority(app.renderThreadTid, -4); } + } else { + // Reset priority for top app UI and render threads + Process.setThreadPriority(app.pid, 0); + if (app.renderThreadTid != 0) { + Process.setThreadPriority(app.renderThreadTid, 0); + } } } } catch (Exception e) { -- 2.11.0