Merge "Replace hardcoded cgroup paths"
This commit is contained in:
@@ -346,30 +346,34 @@ static void parse_cpuset_cpus(char *cpus, cpu_set_t *cpu_set) {
|
|||||||
static void get_cpuset_cores_for_policy(SchedPolicy policy, cpu_set_t *cpu_set)
|
static void get_cpuset_cores_for_policy(SchedPolicy policy, cpu_set_t *cpu_set)
|
||||||
{
|
{
|
||||||
FILE *file;
|
FILE *file;
|
||||||
const char *filename;
|
std::string filename;
|
||||||
|
|
||||||
CPU_ZERO(cpu_set);
|
CPU_ZERO(cpu_set);
|
||||||
|
|
||||||
switch (policy) {
|
switch (policy) {
|
||||||
case SP_BACKGROUND:
|
case SP_BACKGROUND:
|
||||||
filename = "/dev/cpuset/background/cpus";
|
if (!CgroupGetAttributePath("LowCapacityCPUs", &filename)) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
case SP_FOREGROUND:
|
case SP_FOREGROUND:
|
||||||
case SP_AUDIO_APP:
|
case SP_AUDIO_APP:
|
||||||
case SP_AUDIO_SYS:
|
case SP_AUDIO_SYS:
|
||||||
case SP_RT_APP:
|
case SP_RT_APP:
|
||||||
filename = "/dev/cpuset/foreground/cpus";
|
if (!CgroupGetAttributePath("HighCapacityCPUs", &filename)) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
case SP_TOP_APP:
|
case SP_TOP_APP:
|
||||||
filename = "/dev/cpuset/top-app/cpus";
|
if (!CgroupGetAttributePath("MaxCapacityCPUs", &filename)) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
filename = NULL;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!filename) return;
|
file = fopen(filename.c_str(), "re");
|
||||||
|
|
||||||
file = fopen(filename, "re");
|
|
||||||
if (file != NULL) {
|
if (file != NULL) {
|
||||||
// Parse cpus string
|
// Parse cpus string
|
||||||
char *line = NULL;
|
char *line = NULL;
|
||||||
@@ -379,7 +383,7 @@ static void get_cpuset_cores_for_policy(SchedPolicy policy, cpu_set_t *cpu_set)
|
|||||||
if (num_read > 0) {
|
if (num_read > 0) {
|
||||||
parse_cpuset_cpus(line, cpu_set);
|
parse_cpuset_cpus(line, cpu_set);
|
||||||
} else {
|
} else {
|
||||||
ALOGE("Failed to read %s", filename);
|
ALOGE("Failed to read %s", filename.c_str());
|
||||||
}
|
}
|
||||||
free(line);
|
free(line);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1305,15 +1305,12 @@ static jint com_android_internal_os_Zygote_nativeForkSystemServer(
|
|||||||
RuntimeAbort(env, __LINE__, "System server process has died. Restarting Zygote!");
|
RuntimeAbort(env, __LINE__, "System server process has died. Restarting Zygote!");
|
||||||
}
|
}
|
||||||
|
|
||||||
bool low_ram_device = GetBoolProperty("ro.config.low_ram", false);
|
if (UsePerAppMemcg()) {
|
||||||
bool per_app_memcg = GetBoolProperty("ro.config.per_app_memcg", low_ram_device);
|
|
||||||
if (per_app_memcg) {
|
|
||||||
// Assign system_server to the correct memory cgroup.
|
// Assign system_server to the correct memory cgroup.
|
||||||
// Not all devices mount /dev/memcg so check for the file first
|
// Not all devices mount memcg so check if it is mounted first
|
||||||
// to avoid unnecessarily printing errors and denials in the logs.
|
// to avoid unnecessarily printing errors and denials in the logs.
|
||||||
if (!access("/dev/memcg/system/tasks", F_OK) &&
|
if (!SetTaskProfiles(pid, std::vector<std::string>{"SystemMemoryProcess"})) {
|
||||||
!WriteStringToFile(StringPrintf("%d", pid), "/dev/memcg/system/tasks")) {
|
ALOGE("couldn't add process %d into system memcg group", pid);
|
||||||
ALOGE("couldn't write %d to /dev/memcg/system/tasks", pid);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -51,6 +51,7 @@ cc_library_shared {
|
|||||||
"libmtp",
|
"libmtp",
|
||||||
"libexif",
|
"libexif",
|
||||||
"libpiex",
|
"libpiex",
|
||||||
|
"libprocessgroup",
|
||||||
"libandroidfw",
|
"libandroidfw",
|
||||||
"libhidlallocatorutils",
|
"libhidlallocatorutils",
|
||||||
"libhidlbase",
|
"libhidlbase",
|
||||||
@@ -131,6 +132,7 @@ cc_library_shared {
|
|||||||
"libcutils",
|
"libcutils",
|
||||||
"libdexfile",
|
"libdexfile",
|
||||||
"liblzma",
|
"liblzma",
|
||||||
|
"libjsoncpp",
|
||||||
"libmedia_helper",
|
"libmedia_helper",
|
||||||
"libmedia_player2_util",
|
"libmedia_player2_util",
|
||||||
"libmediadrm",
|
"libmediadrm",
|
||||||
@@ -140,6 +142,7 @@ cc_library_shared {
|
|||||||
"libmediautils",
|
"libmediautils",
|
||||||
"libnativehelper",
|
"libnativehelper",
|
||||||
"libnetd_client",
|
"libnetd_client",
|
||||||
|
"libprocessgroup",
|
||||||
"libstagefright_esds",
|
"libstagefright_esds",
|
||||||
"libstagefright_foundation",
|
"libstagefright_foundation",
|
||||||
"libstagefright_httplive",
|
"libstagefright_httplive",
|
||||||
|
|||||||
Reference in New Issue
Block a user