Loading libprocessgroup/sched_policy.cpp +30 −21 Original line number Diff line number Diff line Loading @@ -165,6 +165,26 @@ static int getCGroupSubsys(int tid, const char* subsys, std::string& subgroup) { return 0; } static int get_sched_policy_from_group(const std::string& group, SchedPolicy* policy) { if (group.empty()) { *policy = SP_FOREGROUND; } else if (group == "foreground") { *policy = SP_FOREGROUND; } else if (group == "system-background") { *policy = SP_SYSTEM; } else if (group == "background") { *policy = SP_BACKGROUND; } else if (group == "top-app") { *policy = SP_TOP_APP; } else if (group == "restricted") { *policy = SP_RESTRICTED; } else { errno = ERANGE; return -1; } return 0; } int get_sched_policy(int tid, SchedPolicy* policy) { if (tid == 0) { tid = GetThreadId(); Loading @@ -177,32 +197,21 @@ int get_sched_policy(int tid, SchedPolicy* policy) { 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 (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 if (group.empty()) { *policy = SP_FOREGROUND; } else if (group == "foreground") { *policy = SP_FOREGROUND; } else if (group == "system-background") { *policy = SP_SYSTEM; } else if (group == "background") { *policy = SP_BACKGROUND; } else if (group == "top-app") { *policy = SP_TOP_APP; } else if (group == "restricted") { *policy = SP_RESTRICTED; } else { errno = ERANGE; if (cpusets_enabled() && getCGroupSubsys(tid, "cpuset", group) < 0) { LOG(ERROR) << "Failed to find cpuset cgroup for tid " << tid; return -1; } return 0; return get_sched_policy_from_group(group, policy); } #else Loading Loading
libprocessgroup/sched_policy.cpp +30 −21 Original line number Diff line number Diff line Loading @@ -165,6 +165,26 @@ static int getCGroupSubsys(int tid, const char* subsys, std::string& subgroup) { return 0; } static int get_sched_policy_from_group(const std::string& group, SchedPolicy* policy) { if (group.empty()) { *policy = SP_FOREGROUND; } else if (group == "foreground") { *policy = SP_FOREGROUND; } else if (group == "system-background") { *policy = SP_SYSTEM; } else if (group == "background") { *policy = SP_BACKGROUND; } else if (group == "top-app") { *policy = SP_TOP_APP; } else if (group == "restricted") { *policy = SP_RESTRICTED; } else { errno = ERANGE; return -1; } return 0; } int get_sched_policy(int tid, SchedPolicy* policy) { if (tid == 0) { tid = GetThreadId(); Loading @@ -177,32 +197,21 @@ int get_sched_policy(int tid, SchedPolicy* policy) { 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 (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 if (group.empty()) { *policy = SP_FOREGROUND; } else if (group == "foreground") { *policy = SP_FOREGROUND; } else if (group == "system-background") { *policy = SP_SYSTEM; } else if (group == "background") { *policy = SP_BACKGROUND; } else if (group == "top-app") { *policy = SP_TOP_APP; } else if (group == "restricted") { *policy = SP_RESTRICTED; } else { errno = ERANGE; if (cpusets_enabled() && getCGroupSubsys(tid, "cpuset", group) < 0) { LOG(ERROR) << "Failed to find cpuset cgroup for tid " << tid; return -1; } return 0; return get_sched_policy_from_group(group, policy); } #else Loading