summaryrefslogtreecommitdiffstats
path: root/libcutils
diff options
context:
space:
mode:
authorPat Erley <perley@cyngn.com>2016-03-18 14:01:14 -0700
committerPat Erley <perley@cyngn.com>2016-03-24 16:56:36 -0700
commitbc667ac5f12fd82fe16f4aa9f4883a4b010f10ca (patch)
treee144f3c35abd0a843f207f0d2f925b518e255791 /libcutils
parent266e3dd01105ad4e7004835d0688a7a3d9edf5dc (diff)
downloadsystem_core-bc667ac5f12fd82fe16f4aa9f4883a4b010f10ca.zip
system_core-bc667ac5f12fd82fe16f4aa9f4883a4b010f10ca.tar.gz
system_core-bc667ac5f12fd82fe16f4aa9f4883a4b010f10ca.tar.bz2
sched_policy: Split cpuset/cgroup init
If a task only ever touches cgroups, don't initialize cpusets. This makes logging fails for cpusets much less spammy. Change-Id: Iad9c58db68ecd2c2445255bfe5564318064949a5
Diffstat (limited to 'libcutils')
-rw-r--r--libcutils/sched_policy.c21
1 files changed, 18 insertions, 3 deletions
diff --git a/libcutils/sched_policy.c b/libcutils/sched_policy.c
index 4d69eac..2c29003 100644
--- a/libcutils/sched_policy.c
+++ b/libcutils/sched_policy.c
@@ -53,6 +53,8 @@ static inline SchedPolicy _policy(SchedPolicy p)
#define TIMER_SLACK_FG 50000
static pthread_once_t the_once = PTHREAD_ONCE_INIT;
+static pthread_once_t sched_once = PTHREAD_ONCE_INIT;
+static pthread_once_t cpuset_once = PTHREAD_ONCE_INIT;
static int __sys_supports_schedgroups = -1;
static int __sys_supports_cpusets = -1;
@@ -113,8 +115,13 @@ static void __initialize(void) {
read(pfd, proc_name, sizeof(proc_name) - 1);
close(pfd);
}
+}
+static void __init_sched(void) {
char* filename;
+
+ pthread_once(&the_once, __initialize);
+
if (!access("/dev/cpuctl/tasks", F_OK)) {
__sys_supports_schedgroups = 1;
@@ -142,6 +149,12 @@ static void __initialize(void) {
} else {
__sys_supports_schedgroups = 0;
}
+}
+
+static void __init_cpuset(void) {
+ char *filename;
+
+ pthread_once(&the_once, __initialize);
#ifdef USE_CPUSETS
if (!access("/dev/cpuset/tasks", F_OK)) {
@@ -262,7 +275,8 @@ int get_sched_policy(int tid, SchedPolicy *policy)
if (tid == 0) {
tid = gettid();
}
- pthread_once(&the_once, __initialize);
+
+ pthread_once(&sched_once, __init_sched);
if (__sys_supports_schedgroups) {
char grpBuf[32];
@@ -302,7 +316,7 @@ int set_cpuset_policy(int tid, SchedPolicy policy)
tid = gettid();
}
- pthread_once(&the_once, __initialize);
+ pthread_once(&cpuset_once, __init_cpuset);
if (!__sys_supports_cpusets)
return set_sched_policy(tid, policy);
@@ -342,7 +356,8 @@ int set_sched_policy(int tid, SchedPolicy policy)
tid = gettid();
}
policy = _policy(policy);
- pthread_once(&the_once, __initialize);
+
+ pthread_once(&sched_once, __init_sched);
#if POLICY_DEBUG
char statfile[64];