diff options
author | Android Build Coastguard Worker <android-build-coastguard-worker@google.com> | 2022-03-23 10:12:14 +0000 |
---|---|---|
committer | Android Build Coastguard Worker <android-build-coastguard-worker@google.com> | 2022-03-23 10:12:14 +0000 |
commit | 38191dc6b7f795cb9a96e418f47ee0de0b0a8d13 (patch) | |
tree | 0ebec0729083e0de6d9544751372bdc238b8b717 /libprocessgroup/sched_policy.cpp | |
parent | dfab2cef81678d45d673d5e2e8c7ac4af8064a83 (diff) | |
parent | cb706d277b521508bdd037b78379c1c6a635f6e6 (diff) |
Snap for 8343869 from cb706d277b521508bdd037b78379c1c6a635f6e6 to s-keystone-qcom-release
Change-Id: I08154d17257bd4f2a43fb55017a7f6b06d2cb2aa
Diffstat (limited to 'libprocessgroup/sched_policy.cpp')
-rw-r--r-- | libprocessgroup/sched_policy.cpp | 51 |
1 files changed, 30 insertions, 21 deletions
diff --git a/libprocessgroup/sched_policy.cpp b/libprocessgroup/sched_policy.cpp index 03d347973..f743ed81b 100644 --- a/libprocessgroup/sched_policy.cpp +++ b/libprocessgroup/sched_policy.cpp @@ -166,27 +166,7 @@ static int getCGroupSubsys(int tid, const char* subsys, std::string& subgroup) { return 0; } -int get_sched_policy(int tid, SchedPolicy* policy) { - if (tid == 0) { - tid = GetThreadId(); - } - - std::string group; - if (schedboost_enabled()) { - if ((getCGroupSubsys(tid, "schedtune", group) < 0) && - (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) { - LOG(ERROR) << "Failed to find cpuset cgroup for tid " << tid; - return -1; - } - } - - // TODO: replace hardcoded directories +static int get_sched_policy_from_group(const std::string& group, SchedPolicy* policy) { if (group.empty()) { *policy = SP_FOREGROUND; } else if (group == "foreground") { @@ -208,6 +188,35 @@ int get_sched_policy(int tid, SchedPolicy* policy) { return 0; } +int get_sched_policy(int tid, SchedPolicy* policy) { + if (tid == 0) { + tid = GetThreadId(); + } + + std::string group; + if (schedboost_enabled()) { + if ((getCGroupSubsys(tid, "schedtune", group) < 0) && + (getCGroupSubsys(tid, "cpu", group) < 0)) { + LOG(ERROR) << "Failed to find cpu cgroup for tid " << tid; + return -1; + } + // Wipe invalid group to fallback to cpuset + if (!group.empty()) { + if (get_sched_policy_from_group(group, policy) < 0) { + group.clear(); + } else { + return 0; + } + } + } + + if (cpusets_enabled() && getCGroupSubsys(tid, "cpuset", group) < 0) { + LOG(ERROR) << "Failed to find cpuset cgroup for tid " << tid; + return -1; + } + return get_sched_policy_from_group(group, policy); +} + #else /* Stubs for non-Android targets. */ |