summaryrefslogtreecommitdiffstats
path: root/init/service.cpp
diff options
context:
space:
mode:
authorSuren Baghdasaryan <surenb@google.com>2018-12-21 12:36:20 -0800
committerColin Cross <ccross@android.com>2019-02-03 16:49:08 +0000
commite01ae8deca817c6128427c09b6fb0cfc0e00ec36 (patch)
treefa4b4385c5637ee74576a60019de46324c3dc8bb /init/service.cpp
parent82b72a566761b8379fd2964ed801696803867510 (diff)
downloadsystem_core-e01ae8deca817c6128427c09b6fb0cfc0e00ec36.tar.gz
system_core-e01ae8deca817c6128427c09b6fb0cfc0e00ec36.tar.bz2
system_core-e01ae8deca817c6128427c09b6fb0cfc0e00ec36.zip
init: Replace cgroup hardcoded path with detected one
Remove hardcoded cpuset path usage and replace it with a request to get the path using new API. Exempt-From-Owner-Approval: already approved in internal master Bug: 111307099 Test: builds, boots Change-Id: I211d093c24a682e2d1992c08e4c1d980379711a4 Merged-In: I211d093c24a682e2d1992c08e4c1d980379711a4 Signed-off-by: Suren Baghdasaryan <surenb@google.com>
Diffstat (limited to 'init/service.cpp')
-rw-r--r--init/service.cpp44
1 files changed, 25 insertions, 19 deletions
diff --git a/init/service.cpp b/init/service.cpp
index a6eb7f7ab..84cb2d88d 100644
--- a/init/service.cpp
+++ b/init/service.cpp
@@ -991,27 +991,33 @@ 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/");
- };
- 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.
- std::string default_cpuset = GetProperty("ro.cpuset.default", "");
- if (!default_cpuset.empty()) {
- // Make sure the cpuset name starts and ends with '/'.
- // A single '/' means the 'root' cpuset.
- if (default_cpuset.front() != '/') {
- default_cpuset.insert(0, 1, '/');
+ // 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);
+ 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.
+ std::string default_cpuset = GetProperty("ro.cpuset.default", "");
+ if (!default_cpuset.empty()) {
+ // Make sure the cpuset name starts and ends with '/'.
+ // A single '/' means the 'root' cpuset.
+ if (default_cpuset.front() != '/') {
+ default_cpuset.insert(0, 1, '/');
+ }
+ if (default_cpuset.back() != '/') {
+ default_cpuset.push_back('/');
+ }
+ writepid_files_.push_back(
+ StringPrintf("%s%stasks", cpuset_path.c_str(), default_cpuset.c_str()));
}
- if (default_cpuset.back() != '/') {
- default_cpuset.push_back('/');
- }
- writepid_files_.push_back(
- StringPrintf("/dev/cpuset%stasks", 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_) {