From b4c4654c7ca829865c8ecfe74d1a15de11375926 Mon Sep 17 00:00:00 2001 From: Erik Staats Date: Mon, 24 Apr 2017 14:49:28 -0700 Subject: [PATCH] Change get_sched_policy to check "schedtune" and "cpuset". get_sched_policy will first attempt to get the policy from the "schedtune" subsystem cgroup and, if not set, attempt to get the policy from the "cpuset" subsystem cgroup. If neither subsystem has a cgroup set, SP_FOREGROUND is returned. Bug: 32972117 Test: Verified that SchedPolicy libcutils test passes and that ps displays the expected policies. See details in testing done comment in https://android-review.googlesource.com/379426 . Change-Id: I586a921a38eea99d65590b07ece96c9808a2e56d --- libcutils/sched_policy.cpp | 36 ++++++++++++++++++------------------ 1 file changed, 18 insertions(+), 18 deletions(-) diff --git a/libcutils/sched_policy.cpp b/libcutils/sched_policy.cpp index 4a0b03526..217733a22 100644 --- a/libcutils/sched_policy.cpp +++ b/libcutils/sched_policy.cpp @@ -263,26 +263,26 @@ int get_sched_policy(int tid, SchedPolicy *policy) char grpBuf[32]; - if (cpusets_enabled()) { + grpBuf[0] = '\0'; + if (schedboost_enabled()) { + if (getCGroupSubsys(tid, "schedtune", grpBuf, sizeof(grpBuf)) < 0) return -1; + } + if ((grpBuf[0] == '\0') && cpusets_enabled()) { if (getCGroupSubsys(tid, "cpuset", grpBuf, sizeof(grpBuf)) < 0) return -1; - if (grpBuf[0] == '\0') { - *policy = SP_FOREGROUND; - } else if (!strcmp(grpBuf, "foreground")) { - *policy = SP_FOREGROUND; - } else if (!strcmp(grpBuf, "system-background")) { - *policy = SP_SYSTEM; - } else if (!strcmp(grpBuf, "background")) { - *policy = SP_BACKGROUND; - } else if (!strcmp(grpBuf, "top-app")) { - *policy = SP_TOP_APP; - } else { - errno = ERANGE; - return -1; - } - } else { - // In b/34193533, we removed bg_non_interactive cgroup, so now - // all threads are in FOREGROUND cgroup + } + if (grpBuf[0] == '\0') { *policy = SP_FOREGROUND; + } else if (!strcmp(grpBuf, "foreground")) { + *policy = SP_FOREGROUND; + } else if (!strcmp(grpBuf, "system-background")) { + *policy = SP_SYSTEM; + } else if (!strcmp(grpBuf, "background")) { + *policy = SP_BACKGROUND; + } else if (!strcmp(grpBuf, "top-app")) { + *policy = SP_TOP_APP; + } else { + errno = ERANGE; + return -1; } return 0; }