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

Commit 5fd2fe5f authored by Treehugger Robot's avatar Treehugger Robot Committed by Android (Google) Code Review
Browse files

Merge "Fix race applying SystemMemoryProcess for system_server" into main

parents e1e977d4 45d921c1
Loading
Loading
Loading
Loading
+9 −9
Original line number Original line Diff line number Diff line
@@ -1974,6 +1974,15 @@ static void SpecializeCommon(JNIEnv* env, uid_t uid, gid_t gid, jintArray gids,
                                 : CREATE_ERROR("createProcessGroup(%d, %d) failed: %s", uid,
                                 : CREATE_ERROR("createProcessGroup(%d, %d) failed: %s", uid,
                                                /* pid= */ 0, strerror(-rc)));
                                                /* pid= */ 0, strerror(-rc)));
        }
        }

        if (is_system_server && UsePerAppMemcg()) {
            // Assign system_server to the correct memory cgroup.
            // Not all devices mount memcg so check if it is mounted first
            // to avoid unnecessarily printing errors and denials in the logs.
            if (!SetTaskProfiles(getpid(), std::vector<std::string>{"SystemMemoryProcess"})) {
                ALOGE("couldn't add process %d into system memcg group", getpid());
            }
        }
    }
    }


    SetGids(env, gids, is_child_zygote, fail_fn);
    SetGids(env, gids, is_child_zygote, fail_fn);
@@ -2627,15 +2636,6 @@ static jint com_android_internal_os_Zygote_nativeForkSystemServer(
          ALOGE("System server process %d has died. Restarting Zygote!", pid);
          ALOGE("System server process %d has died. Restarting Zygote!", pid);
          RuntimeAbort(env, __LINE__, "System server process has died. Restarting Zygote!");
          RuntimeAbort(env, __LINE__, "System server process has died. Restarting Zygote!");
      }
      }

      if (UsePerAppMemcg()) {
          // Assign system_server to the correct memory cgroup.
          // Not all devices mount memcg so check if it is mounted first
          // to avoid unnecessarily printing errors and denials in the logs.
          if (!SetTaskProfiles(pid, std::vector<std::string>{"SystemMemoryProcess"})) {
              ALOGE("couldn't add process %d into system memcg group", pid);
          }
      }
  }
  }
  return pid;
  return pid;
}
}