From e3d38969aa7329dcac4fc2ed20181ac8510a988b Mon Sep 17 00:00:00 2001 From: Suren Baghdasaryan Date: Mon, 26 Apr 2021 09:21:52 -0700 Subject: [PATCH] libprocessgroup: Fix warnings when legacy schedtune cgroup is absent Issue a warning about missing cpu/schedtune controller only if both of them are missing. Bug: 185437398 Signed-off-by: Suren Baghdasaryan Change-Id: I3a9d3c9a8c91c8d2c5346bcb431bb0407c64a811 --- libprocessgroup/sched_policy.cpp | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/libprocessgroup/sched_policy.cpp b/libprocessgroup/sched_policy.cpp index c51ee6189..1a4196a4d 100644 --- a/libprocessgroup/sched_policy.cpp +++ b/libprocessgroup/sched_policy.cpp @@ -159,10 +159,9 @@ static int getCGroupSubsys(int tid, const char* subsys, std::string& subgroup) { if (!controller.IsUsable()) return -1; - if (!controller.GetTaskGroup(tid, &subgroup)) { - LOG(ERROR) << "Failed to find cgroup for tid " << tid; + if (!controller.GetTaskGroup(tid, &subgroup)) return -1; - } + return 0; } @@ -174,11 +173,16 @@ int get_sched_policy(int tid, SchedPolicy* policy) { std::string group; if (schedboost_enabled()) { if ((getCGroupSubsys(tid, "schedtune", group) < 0) && - (getCGroupSubsys(tid, "cpu", group) < 0)) - return -1; + (getCGroupSubsys(tid, "cpu", group) < 0)) { + LOG(ERROR) << "Failed to find cpu cgroup for tid " << tid; + return -1; + } } if (group.empty() && cpusets_enabled()) { - if (getCGroupSubsys(tid, "cpuset", group) < 0) return -1; + if (getCGroupSubsys(tid, "cpuset", group) < 0) { + LOG(ERROR) << "Failed to find cpuset cgroup for tid " << tid; + return -1; + } } // TODO: replace hardcoded directories