summaryrefslogtreecommitdiff
path: root/libprocessgroup/sched_policy.cpp
diff options
context:
space:
mode:
authoralk3pInjection <webmaster@raspii.tech>2022-05-02 09:56:20 +0800
committeralk3pInjection <webmaster@raspii.tech>2022-05-02 09:56:20 +0800
commitd53ccefe1270307c78ac8f833c82abcaa262cc3a (patch)
tree6993ccbaec8f775df73b75d38c5b529889479417 /libprocessgroup/sched_policy.cpp
parentadbb1c10dd503804988344c1905df3c23973cf0d (diff)
parent8fc3f7296741ce589f7294113f8771837fb49bda (diff)
Merge tag 'LA.QSSI.12.0.r1-06800-qssi.0' into sugisawa-mr1
"LA.QSSI.12.0.r1-06800-qssi.0" Change-Id: I979d0f844cf44539ca87aade5929a4c84b4d31ff
Diffstat (limited to 'libprocessgroup/sched_policy.cpp')
-rw-r--r--libprocessgroup/sched_policy.cpp51
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. */