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

Commit 1e4b9d75 authored by Suren Baghdasaryan's avatar Suren Baghdasaryan Committed by Gerrit Code Review
Browse files

Merge "Replace hardcoded cgroup paths"

parents 996f0473 9c9b0257
Loading
Loading
Loading
Loading
+13 −9
Original line number Diff line number Diff line
@@ -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)
{
    FILE *file;
    const char *filename;
    std::string filename;

    CPU_ZERO(cpu_set);

    switch (policy) {
        case SP_BACKGROUND:
            filename = "/dev/cpuset/background/cpus";
            if (!CgroupGetAttributePath("LowCapacityCPUs", &filename)) {
                return;
            }
            break;
        case SP_FOREGROUND:
        case SP_AUDIO_APP:
        case SP_AUDIO_SYS:
        case SP_RT_APP:
            filename = "/dev/cpuset/foreground/cpus";
            if (!CgroupGetAttributePath("HighCapacityCPUs", &filename)) {
                return;
            }
            break;
        case SP_TOP_APP:
            filename = "/dev/cpuset/top-app/cpus";
            if (!CgroupGetAttributePath("MaxCapacityCPUs", &filename)) {
                return;
            }
            break;
        default:
            filename = NULL;
            return;
    }

    if (!filename) return;

    file = fopen(filename, "re");
    file = fopen(filename.c_str(), "re");
    if (file != NULL) {
        // Parse cpus string
        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) {
            parse_cpuset_cpus(line, cpu_set);
        } else {
            ALOGE("Failed to read %s", filename);
            ALOGE("Failed to read %s", filename.c_str());
        }
        free(line);
    }
+4 −7
Original line number Diff line number Diff line
@@ -1305,15 +1305,12 @@ static jint com_android_internal_os_Zygote_nativeForkSystemServer(
          RuntimeAbort(env, __LINE__, "System server process has died. Restarting Zygote!");
      }

      bool low_ram_device = GetBoolProperty("ro.config.low_ram", false);
      bool per_app_memcg = GetBoolProperty("ro.config.per_app_memcg", low_ram_device);
      if (per_app_memcg) {
      if (UsePerAppMemcg()) {
          // 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.
          if (!access("/dev/memcg/system/tasks", F_OK) &&
                !WriteStringToFile(StringPrintf("%d", pid), "/dev/memcg/system/tasks")) {
              ALOGE("couldn't write %d to /dev/memcg/system/tasks", pid);
          if (!SetTaskProfiles(pid, std::vector<std::string>{"SystemMemoryProcess"})) {
              ALOGE("couldn't add process %d into system memcg group", pid);
          }
      }
  }
+3 −0
Original line number Diff line number Diff line
@@ -51,6 +51,7 @@ cc_library_shared {
        "libmtp",
        "libexif",
        "libpiex",
        "libprocessgroup",
        "libandroidfw",
        "libhidlallocatorutils",
        "libhidlbase",
@@ -131,6 +132,7 @@ cc_library_shared {
        "libcutils",
        "libdexfile",
        "liblzma",
        "libjsoncpp",
        "libmedia_helper",
        "libmedia_player2_util",
        "libmediadrm",
@@ -140,6 +142,7 @@ cc_library_shared {
        "libmediautils",
        "libnativehelper",
        "libnetd_client",
        "libprocessgroup",
        "libstagefright_esds",
        "libstagefright_foundation",
        "libstagefright_httplive",