Loading core/jni/Android.mk +4 −0 Original line number Diff line number Diff line Loading @@ -20,6 +20,10 @@ ifneq ($(ENABLE_CPUSETS),) LOCAL_CFLAGS += -DENABLE_CPUSETS endif ifneq ($(ENABLE_SCHED_BOOST),) LOCAL_CFLAGS += -DENABLE_SCHED_BOOST endif LOCAL_CFLAGS += -DGL_GLEXT_PROTOTYPES -DEGL_EGLEXT_PROTOTYPES LOCAL_CFLAGS += -DU_USING_ICU_NAMESPACE=0 Loading core/jni/com_android_internal_os_Zygote.cpp +31 −0 Original line number Diff line number Diff line Loading @@ -408,6 +408,27 @@ void SetThreadName(const char* thread_name) { } } #ifdef ENABLE_SCHED_BOOST static void SetForkLoad(bool boost) { // set scheduler knob to boost forked processes pid_t currentPid = getpid(); // fits at most "/proc/XXXXXXX/sched_init_task_load\0" char schedPath[35]; snprintf(schedPath, sizeof(schedPath), "/proc/%u/sched_init_task_load", currentPid); int schedBoostFile = open(schedPath, O_WRONLY); if (schedBoostFile < 0) { ALOGW("Unable to set zygote scheduler boost"); return; } if (boost) { write(schedBoostFile, "100\0", 4); } else { write(schedBoostFile, "0\0", 2); } close(schedBoostFile); } #endif // Utility routine to fork zygote and specialize the child process. static pid_t ForkAndSpecializeCommon(JNIEnv* env, uid_t uid, gid_t gid, jintArray javaGids, jint debug_flags, jobjectArray javaRlimits, Loading @@ -418,6 +439,10 @@ static pid_t ForkAndSpecializeCommon(JNIEnv* env, uid_t uid, gid_t gid, jintArra jstring instructionSet, jstring dataDir) { SetSigChldHandler(); #ifdef ENABLE_SCHED_BOOST SetForkLoad(true); #endif pid_t pid = fork(); if (pid == 0) { Loading Loading @@ -558,6 +583,12 @@ static pid_t ForkAndSpecializeCommon(JNIEnv* env, uid_t uid, gid_t gid, jintArra } } else if (pid > 0) { // the parent process #ifdef ENABLE_SCHED_BOOST // unset scheduler knob SetForkLoad(false); #endif } return pid; } Loading Loading
core/jni/Android.mk +4 −0 Original line number Diff line number Diff line Loading @@ -20,6 +20,10 @@ ifneq ($(ENABLE_CPUSETS),) LOCAL_CFLAGS += -DENABLE_CPUSETS endif ifneq ($(ENABLE_SCHED_BOOST),) LOCAL_CFLAGS += -DENABLE_SCHED_BOOST endif LOCAL_CFLAGS += -DGL_GLEXT_PROTOTYPES -DEGL_EGLEXT_PROTOTYPES LOCAL_CFLAGS += -DU_USING_ICU_NAMESPACE=0 Loading
core/jni/com_android_internal_os_Zygote.cpp +31 −0 Original line number Diff line number Diff line Loading @@ -408,6 +408,27 @@ void SetThreadName(const char* thread_name) { } } #ifdef ENABLE_SCHED_BOOST static void SetForkLoad(bool boost) { // set scheduler knob to boost forked processes pid_t currentPid = getpid(); // fits at most "/proc/XXXXXXX/sched_init_task_load\0" char schedPath[35]; snprintf(schedPath, sizeof(schedPath), "/proc/%u/sched_init_task_load", currentPid); int schedBoostFile = open(schedPath, O_WRONLY); if (schedBoostFile < 0) { ALOGW("Unable to set zygote scheduler boost"); return; } if (boost) { write(schedBoostFile, "100\0", 4); } else { write(schedBoostFile, "0\0", 2); } close(schedBoostFile); } #endif // Utility routine to fork zygote and specialize the child process. static pid_t ForkAndSpecializeCommon(JNIEnv* env, uid_t uid, gid_t gid, jintArray javaGids, jint debug_flags, jobjectArray javaRlimits, Loading @@ -418,6 +439,10 @@ static pid_t ForkAndSpecializeCommon(JNIEnv* env, uid_t uid, gid_t gid, jintArra jstring instructionSet, jstring dataDir) { SetSigChldHandler(); #ifdef ENABLE_SCHED_BOOST SetForkLoad(true); #endif pid_t pid = fork(); if (pid == 0) { Loading Loading @@ -558,6 +583,12 @@ static pid_t ForkAndSpecializeCommon(JNIEnv* env, uid_t uid, gid_t gid, jintArra } } else if (pid > 0) { // the parent process #ifdef ENABLE_SCHED_BOOST // unset scheduler knob SetForkLoad(false); #endif } return pid; } Loading