Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 96f92954 authored by TreeHugger Robot's avatar TreeHugger Robot Committed by Android (Google) Code Review
Browse files

Merge changes I627e47c6,I9f949799

* changes:
  Revert "Add boost to increase the load on newly-forked zygote processes."
  Revert "Enable migration to big cores for app launches."
parents a14864c7 0f2ded62
Loading
Loading
Loading
Loading
+0 −4
Original line number Diff line number Diff line
@@ -19,10 +19,6 @@ 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
+0 −31
Original line number Diff line number Diff line
@@ -435,27 +435,6 @@ 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

// The list of open zygote file descriptors.
static FileDescriptorTable* gOpenFdTable = NULL;

@@ -469,10 +448,6 @@ 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

  // Close any logging related FDs before we start evaluating the list of
  // file descriptors.
  __android_log_close();
@@ -633,12 +608,6 @@ 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;
}
+0 −33
Original line number Diff line number Diff line
@@ -527,11 +527,6 @@ public final class ActivityManagerService extends ActivityManagerNative
    private static final String INTENT_REMOTE_BUGREPORT_FINISHED =
            "android.intent.action.REMOTE_BUGREPORT_FINISHED";
    // Delay to disable app launch boost
    static final int APP_BOOST_MESSAGE_DELAY = 3000;
    // Lower delay than APP_BOOST_MESSAGE_DELAY to disable the boost
    static final int APP_BOOST_TIMEOUT = 2500;
    // Used to indicate that a task is removed it should also be removed from recents.
    private static final boolean REMOVE_FROM_RECENTS = true;
    // Used to indicate that an app transition should be animated.
@@ -541,11 +536,6 @@ public final class ActivityManagerService extends ActivityManagerNative
    static final boolean TAKE_FULLSCREEN_SCREENSHOTS = true;
    public static final float FULLSCREEN_SCREENSHOT_SCALE = 0.6f;
    private static native int nativeMigrateToBoost();
    private static native int nativeMigrateFromBoost();
    private boolean mIsBoosted = false;
    private long mBoostStartTime = 0;
    /** All system services */
    SystemServiceManager mSystemServiceManager;
@@ -1520,7 +1510,6 @@ public final class ActivityManagerService extends ActivityManagerNative
    static final int REPORT_TIME_TRACKER_MSG = 55;
    static final int REPORT_USER_SWITCH_COMPLETE_MSG = 56;
    static final int SHUTDOWN_UI_AUTOMATION_CONNECTION_MSG = 57;
    static final int APP_BOOST_DEACTIVATE_MSG = 58;
    static final int CONTENT_PROVIDER_PUBLISH_TIMEOUT_MSG = 59;
    static final int IDLE_UIDS_MSG = 60;
    static final int SYSTEM_USER_UNLOCK_MSG = 61;
@@ -2292,20 +2281,6 @@ public final class ActivityManagerService extends ActivityManagerNative
                // it is finished we make sure it is reset to its default.
                mUserIsMonkey = false;
            } break;
            case APP_BOOST_DEACTIVATE_MSG: {
                synchronized(ActivityManagerService.this) {
                    if (mIsBoosted) {
                        if (mBoostStartTime < (SystemClock.uptimeMillis() - APP_BOOST_TIMEOUT)) {
                            nativeMigrateFromBoost();
                            mIsBoosted = false;
                            mBoostStartTime = 0;
                        } else {
                            Message newmsg = mHandler.obtainMessage(APP_BOOST_DEACTIVATE_MSG);
                            mHandler.sendMessageDelayed(newmsg, APP_BOOST_TIMEOUT);
                        }
                    }
                }
            } break;
            case IDLE_UIDS_MSG: {
                idleUids();
            } break;
@@ -3544,14 +3519,6 @@ public final class ActivityManagerService extends ActivityManagerNative
            app = null;
        }
        // app launch boost for big.little configurations
        // use cpusets to migrate freshly launched tasks to big cores
        nativeMigrateToBoost();
        mIsBoosted = true;
        mBoostStartTime = SystemClock.uptimeMillis();
        Message msg = mHandler.obtainMessage(APP_BOOST_DEACTIVATE_MSG);
        mHandler.sendMessageDelayed(msg, APP_BOOST_MESSAGE_DELAY);
        // We don't have to do anything more if:
        // (1) There is an existing application record; and
        // (2) The caller doesn't think it is dead, OR there is no thread
+0 −7
Original line number Diff line number Diff line
@@ -4,16 +4,9 @@ LOCAL_REL_DIR := core/jni

LOCAL_CFLAGS += -Wall -Werror -Wno-unused-parameter

ifneq ($(ENABLE_CPUSETS),)
ifneq ($(ENABLE_SCHED_BOOST),)
LOCAL_CFLAGS += -DUSE_SCHED_BOOST
endif
endif

LOCAL_SRC_FILES += \
    $(LOCAL_REL_DIR)/com_android_server_AlarmManagerService.cpp \
    $(LOCAL_REL_DIR)/com_android_server_am_BatteryStatsService.cpp \
    $(LOCAL_REL_DIR)/com_android_server_am_ActivityManagerService.cpp \
    $(LOCAL_REL_DIR)/com_android_server_AssetAtlasService.cpp \
    $(LOCAL_REL_DIR)/com_android_server_connectivity_Vpn.cpp \
    $(LOCAL_REL_DIR)/com_android_server_ConsumerIrService.cpp \
+0 −150
Original line number Diff line number Diff line
/*
 * Copyright (C) 2015 The Android Open Source Project
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

#define LOG_TAG "ActivityManagerService"
//#define LOG_NDEBUG 0

#include <android_runtime/AndroidRuntime.h>
#include <jni.h>

#include <ScopedLocalRef.h>
#include <ScopedPrimitiveArray.h>

#include <cutils/log.h>
#include <utils/misc.h>
#include <utils/Log.h>

#include <stdio.h>
#include <errno.h>
#include <fcntl.h>
#include <semaphore.h>
#include <stddef.h>
#include <string.h>
#include <sys/stat.h>
#include <sys/types.h>
#include <unistd.h>

namespace android
{

    // migrate from foreground to foreground_boost
    static jint migrateToBoost(JNIEnv *env, jobject _this)
    {
#ifdef USE_SCHED_BOOST
        // File descriptors open to /dev/cpuset/../tasks, setup by initialize, or -1 on error
        FILE* fg_cpuset_file = NULL;
        int   boost_cpuset_fd = 0;
        if (!access("/dev/cpuset/tasks", F_OK)) {
            fg_cpuset_file = fopen("/dev/cpuset/foreground/tasks", "r+");
            if (ferror(fg_cpuset_file)) {
                return 0;
            }
            boost_cpuset_fd = open("/dev/cpuset/foreground/boost/tasks", O_WRONLY);
            if (boost_cpuset_fd < 0) {
                fclose(fg_cpuset_file);
                return 0;
            }

        }
        if (!fg_cpuset_file || !boost_cpuset_fd) {
            fclose(fg_cpuset_file);
            close(boost_cpuset_fd);
            return 0;
        }
        char buf[17];
        while (fgets(buf, 16, fg_cpuset_file)) {
            int i = 0;
            for (; i < 16; i++) {
                if (buf[i] == '\n') {
                    buf[i] = 0;
                    break;
                }
            }
            if (write(boost_cpuset_fd, buf, i) < 0) {
                // ignore error
            }
            if (feof(fg_cpuset_file))
                break;
        }
        fclose(fg_cpuset_file);
        close(boost_cpuset_fd);
#endif
        return 0;
    }

    // migrate from foreground_boost to foreground
    static jint migrateFromBoost(JNIEnv *env, jobject _this)
    {
#ifdef USE_SCHED_BOOST
        // File descriptors open to /dev/cpuset/../tasks, setup by initialize, or -1 on error
        int   fg_cpuset_fd = 0;
        FILE* boost_cpuset_file = NULL;
        if (!access("/dev/cpuset/tasks", F_OK)) {
            boost_cpuset_file = fopen("/dev/cpuset/foreground/boost/tasks", "r+");
            if (ferror(boost_cpuset_file)) {
                return 0;
            }
            fg_cpuset_fd = open("/dev/cpuset/foreground/tasks", O_WRONLY);
            if (fg_cpuset_fd < 0) {
                fclose(boost_cpuset_file);
                return 0;
            }

        }
        if (!boost_cpuset_file || !fg_cpuset_fd) {
            fclose(boost_cpuset_file);
            close(fg_cpuset_fd);
            return 0;
        }
        char buf[17];
        while (fgets(buf, 16, boost_cpuset_file)) {
            //ALOGE("Appending FD %s to fg", buf);
            int i = 0;
            for (; i < 16; i++) {
                if (buf[i] == '\n') {
                    buf[i] = 0;
                    break;
                }
            }
            if (write(fg_cpuset_fd, buf, i) < 0) {
                //ALOGE("Appending FD %s to fg ERROR", buf);
                // handle error?
            }
            if (feof(boost_cpuset_file))
                break;
        }

        close(fg_cpuset_fd);
        fclose(boost_cpuset_file);

#endif
        return 0;

    }


    static JNINativeMethod method_table[] = {
        { "nativeMigrateToBoost",   "()I", (void*)migrateToBoost },
        { "nativeMigrateFromBoost", "()I", (void*)migrateFromBoost },
    };

    int register_android_server_ActivityManagerService(JNIEnv *env)
    {
        return jniRegisterNativeMethods(env, "com/android/server/am/ActivityManagerService",
                                        method_table, NELEM(method_table));
    }

}
Loading