libprocessgroup: Add support for task profiles
Abstract usage of cgroups into task profiles that allows for changes
in cgroup hierarchy and version without affecting framework codebase.
Rework current processgroup and sched_policy API function implementations
to use task profiles instead of hardcoded paths and attributes.
Mount cgroups using information from cgroups.json rather than from init.rc
Exempt-From-Owner-Approval: already approved in internal master
Bug: 111307099
Test: builds, boots
Change-Id: If5532d6dc570add825cebd5b5148e00c7d688e32
Merged-In: If5532d6dc570add825cebd5b5148e00c7d688e32
Signed-off-by: Suren Baghdasaryan <surenb@google.com>
diff --git a/init/init.cpp b/init/init.cpp
index 4f4a15f..5a3cc15 100644
--- a/init/init.cpp
+++ b/init/init.cpp
@@ -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 @@
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 @@
// 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...