From 4074ad01e898605c64a80a8cb14c10bdbedf1bdb Mon Sep 17 00:00:00 2001 From: Tim Murray Date: Fri, 8 Jul 2016 15:45:45 -0700 Subject: [PATCH] Sets android.ui to be in the fg stune group. setThreadGroup(TOP_APP) will place a thread in the fg stune group but not the top_app cpuset. This allows android.ui to get more runtime to render transitions between activities without impacting its CPU placement. bug 29512132 Change-Id: I95e031975f83290f88ac6e538abf1062aea27ed4 --- core/java/android/os/Process.java | 5 +++++ services/core/java/com/android/server/UiThread.java | 5 ++++- 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/core/java/android/os/Process.java b/core/java/android/os/Process.java index c26d974b2cbab..84d2c98ba93d1 100644 --- a/core/java/android/os/Process.java +++ b/core/java/android/os/Process.java @@ -971,6 +971,9 @@ public class Process { * priority. * If the thread is a thread group leader, that is it's gettid() == getpid(), * then the other threads in the same thread group are _not_ affected. + * + * Does not set cpuset for some historical reason, just calls + * libcutils::set_sched_policy(). */ public static final native void setThreadGroup(int tid, int group) throws IllegalArgumentException, SecurityException; @@ -992,6 +995,8 @@ public class Process { * priority threads alone. group == THREAD_GROUP_BG_NONINTERACTIVE moves all * threads, regardless of priority, to the background scheduling group. * group == THREAD_GROUP_FOREGROUND is not allowed. + * + * Always sets cpusets. */ public static final native void setProcessGroup(int pid, int group) throws IllegalArgumentException, SecurityException; diff --git a/services/core/java/com/android/server/UiThread.java b/services/core/java/com/android/server/UiThread.java index c06afc2505ee0..1bc6250d699a5 100644 --- a/services/core/java/com/android/server/UiThread.java +++ b/services/core/java/com/android/server/UiThread.java @@ -17,6 +17,7 @@ package com.android.server; import android.os.Handler; +import android.os.Process; import android.os.Trace; /** @@ -29,7 +30,9 @@ public final class UiThread extends ServiceThread { private static Handler sHandler; private UiThread() { - super("android.ui", android.os.Process.THREAD_PRIORITY_FOREGROUND, false /*allowIo*/); + super("android.ui", Process.THREAD_PRIORITY_FOREGROUND, false /*allowIo*/); + // Make sure UiThread is in the fg stune boost group + Process.setThreadGroup(Process.myTid(), Process.THREAD_GROUP_TOP_APP); } private static void ensureThreadLocked() {