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

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

Merge changes from topic "cgroup abstraction layer"

* changes:
  Disable SetupCgroup for non-Android targets
  Fix non-Android build targets
  init: Replace cgroup hardcoded path with detected one
  libprocessgroup: Add support for task profiles
  rootdir: Add cgroups and task profiles description files
parents e077c582 ff25a5f5
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -109,6 +109,7 @@ CHARGER_STATIC_LIBRARIES := \
    libbase \
    libutils \
    libcutils \
    libjsoncpp \
    libprocessgroup \
    liblog \
    libm \
+1 −1
Original line number Diff line number Diff line
@@ -60,7 +60,6 @@ cc_defaults {
    },
    static_libs: [
        "libseccomp_policy",
        "libprocessgroup",
        "libavb",
        "libprotobuf-cpp-lite",
        "libpropertyinfoserializer",
@@ -82,6 +81,7 @@ cc_defaults {
        "liblog",
        "liblogwrap",
        "liblp",
        "libprocessgroup",
        "libselinux",
        "libutils",
    ],
+14 −0
Original line number Diff line number Diff line
@@ -42,6 +42,7 @@
#include <fs_mgr_vendor_overlay.h>
#include <keyutils.h>
#include <libavb/libavb.h>
#include <processgroup/processgroup.h>
#include <selinux/android.h>

#ifndef RECOVERY
@@ -347,6 +348,17 @@ static Result<Success> console_init_action(const BuiltinArguments& args) {
    return Success();
}

static Result<Success> SetupCgroupsAction(const BuiltinArguments&) {
    // Have to create <CGROUPS_RC_DIR> using make_dir function
    // for appropriate sepolicy to be set for it
    make_dir(CGROUPS_RC_DIR, 0711);
    if (!CgroupSetupCgroups()) {
        return ErrnoError() << "Failed to setup cgroups";
    }

    return Success();
}

static void import_kernel_nv(const std::string& key, const std::string& value, bool for_emulator) {
    if (key.empty()) return;

@@ -682,6 +694,8 @@ int SecondStageMain(int argc, char** argv) {
    // Nexus 9 boot time, so it's disabled by default.
    if (false) DumpState();

    am.QueueBuiltinAction(SetupCgroupsAction, "SetupCgroups");

    am.QueueEventTrigger("early-init");

    // Queue an action that waits for coldboot done so we know ueventd has set up all of /dev...
+25 −19
Original line number Diff line number Diff line
@@ -991,11 +991,14 @@ Result<Success> Service::Start() {
        std::for_each(descriptors_.begin(), descriptors_.end(),
                      std::bind(&DescriptorInfo::CreateAndPublish, std::placeholders::_1, scon));

        // See if there were "writepid" instructions to write to files under /dev/cpuset/.
        auto cpuset_predicate = [](const std::string& path) {
            return StartsWith(path, "/dev/cpuset/");
        // See if there were "writepid" instructions to write to files under cpuset path.
        std::string cpuset_path;
        if (CgroupGetControllerPath("cpuset", &cpuset_path)) {
            auto cpuset_predicate = [&cpuset_path](const std::string& path) {
                return StartsWith(path, cpuset_path + "/");
            };
        auto iter = std::find_if(writepid_files_.begin(), writepid_files_.end(), cpuset_predicate);
            auto iter =
                    std::find_if(writepid_files_.begin(), writepid_files_.end(), cpuset_predicate);
            if (iter == writepid_files_.end()) {
                // There were no "writepid" instructions for cpusets, check if the system default
                // cpuset is specified to be used for the process.
@@ -1010,9 +1013,12 @@ Result<Success> Service::Start() {
                        default_cpuset.push_back('/');
                    }
                    writepid_files_.push_back(
                    StringPrintf("/dev/cpuset%stasks", default_cpuset.c_str()));
                            StringPrintf("%s%stasks", cpuset_path.c_str(), default_cpuset.c_str()));
                }
            }
        } else {
            LOG(ERROR) << "cpuset cgroup controller is not mounted!";
        }
        std::string pid_str = std::to_string(getpid());
        for (const auto& file : writepid_files_) {
            if (!WriteStringToFile(pid_str, file)) {
+1 −0
Original line number Diff line number Diff line
@@ -59,6 +59,7 @@ test_libraries = [
    "libcutils",
    "liblog",
    "libbase",
    "libjsoncpp",
    "libprocessgroup",
]

Loading