From dd401253bc924d28099e1454e20d76f701aa8a45 Mon Sep 17 00:00:00 2001 From: Carmen Jackson Date: Thu, 23 Feb 2017 15:21:10 -0800 Subject: [PATCH] Added system_server to system group Test: on gobo pidof system_server appears in the correct file: $ adb shell pidof system_server 859 $ adb shell cat /dev/memcg/system/tasks | grep '859' 859 Bug: 65130832 Change-Id: Id63abd473a7f2001688b0be06bfec6472c7f8648 --- core/jni/com_android_internal_os_Zygote.cpp | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/core/jni/com_android_internal_os_Zygote.cpp b/core/jni/com_android_internal_os_Zygote.cpp index 3887c76419cc2..e1c2cb0deb73c 100644 --- a/core/jni/com_android_internal_os_Zygote.cpp +++ b/core/jni/com_android_internal_os_Zygote.cpp @@ -45,6 +45,8 @@ #include #include "android-base/logging.h" +#include +#include #include #include #include @@ -65,6 +67,8 @@ namespace { using android::String8; +using android::base::StringPrintf; +using android::base::WriteStringToFile; static pid_t gSystemServerPid = 0; @@ -754,6 +758,11 @@ static jint com_android_internal_os_Zygote_nativeForkSystemServer( ALOGE("System server process %d has died. Restarting Zygote!", pid); RuntimeAbort(env, __LINE__, "System server process has died. Restarting Zygote!"); } + + // Assign system_server to the correct memory cgroup. + if (!WriteStringToFile(StringPrintf("%d", pid), "/dev/memcg/system/tasks")) { + ALOGE("couldn't write %d to /dev/memcg/system/tasks", pid); + } } return pid; }