aboutsummaryrefslogtreecommitdiffstats
path: root/kernel
diff options
context:
space:
mode:
authorLinus Torvalds <torvalds@linux-foundation.org>2016-08-30 12:31:59 -0400
committerLinus Torvalds <torvalds@linux-foundation.org>2016-08-30 12:31:59 -0400
commit748e7fc20983fccd742e93c5b6a38ece1f71f80f (patch)
treea097b9e7875647416ca3a0661809a3ed63d2d21a /kernel
parente4e98c460ad38c78498622a164fd5ef09a2dc9cb (diff)
parent568ac888215c7fb2fabe8ea739b00ec3c1f5d440 (diff)
Merge branch 'for-4.8-fixes' of git://git.kernel.org/pub/scm/linux/kernel/git/tj/cgroup
Pull cgroup fixes from Tejun Heo: "Two fixes for cgroup. - There still was a hole in enforcing cpuset rules, fixed by Li. - The recent switch to global percpu_rwseom for threadgroup locking revealed a couple issues in how percpu_rwsem is implemented and used by cgroup. Balbir found that the read locking section was too wide unnecessarily including operations which can often depend on IOs. With percpu_rwsem updates (coming through a different tree) and reduction of read locking section, all the reported locking latency issues, including the android one, are resolved. It looks like we can keep global percpu_rwsem locking for now. If there actually are cases which can't be resolved, we can go back to more complex per-signal_struct locking" * 'for-4.8-fixes' of git://git.kernel.org/pub/scm/linux/kernel/git/tj/cgroup: cgroup: reduce read locked section of cgroup_threadgroup_rwsem during fork cpuset: make sure new tasks conform to the current config of the cpuset
Diffstat (limited to 'kernel')
-rw-r--r--kernel/cpuset.c15
-rw-r--r--kernel/fork.c4
2 files changed, 17 insertions, 2 deletions
diff --git a/kernel/cpuset.c b/kernel/cpuset.c
index c7fd2778ed50..c27e53326bef 100644
--- a/kernel/cpuset.c
+++ b/kernel/cpuset.c
@@ -2069,6 +2069,20 @@ static void cpuset_bind(struct cgroup_subsys_state *root_css)
2069 mutex_unlock(&cpuset_mutex); 2069 mutex_unlock(&cpuset_mutex);
2070} 2070}
2071 2071
2072/*
2073 * Make sure the new task conform to the current state of its parent,
2074 * which could have been changed by cpuset just after it inherits the
2075 * state from the parent and before it sits on the cgroup's task list.
2076 */
2077void cpuset_fork(struct task_struct *task)
2078{
2079 if (task_css_is_root(task, cpuset_cgrp_id))
2080 return;
2081
2082 set_cpus_allowed_ptr(task, &current->cpus_allowed);
2083 task->mems_allowed = current->mems_allowed;
2084}
2085
2072struct cgroup_subsys cpuset_cgrp_subsys = { 2086struct cgroup_subsys cpuset_cgrp_subsys = {
2073 .css_alloc = cpuset_css_alloc, 2087 .css_alloc = cpuset_css_alloc,
2074 .css_online = cpuset_css_online, 2088 .css_online = cpuset_css_online,
@@ -2079,6 +2093,7 @@ struct cgroup_subsys cpuset_cgrp_subsys = {
2079 .attach = cpuset_attach, 2093 .attach = cpuset_attach,
2080 .post_attach = cpuset_post_attach, 2094 .post_attach = cpuset_post_attach,
2081 .bind = cpuset_bind, 2095 .bind = cpuset_bind,
2096 .fork = cpuset_fork,
2082 .legacy_cftypes = files, 2097 .legacy_cftypes = files,
2083 .early_init = true, 2098 .early_init = true,
2084}; 2099};
diff --git a/kernel/fork.c b/kernel/fork.c
index 52e725d4a866..aaf782327bf3 100644
--- a/kernel/fork.c
+++ b/kernel/fork.c
@@ -1404,7 +1404,6 @@ static struct task_struct *copy_process(unsigned long clone_flags,
1404 p->real_start_time = ktime_get_boot_ns(); 1404 p->real_start_time = ktime_get_boot_ns();
1405 p->io_context = NULL; 1405 p->io_context = NULL;
1406 p->audit_context = NULL; 1406 p->audit_context = NULL;
1407 threadgroup_change_begin(current);
1408 cgroup_fork(p); 1407 cgroup_fork(p);
1409#ifdef CONFIG_NUMA 1408#ifdef CONFIG_NUMA
1410 p->mempolicy = mpol_dup(p->mempolicy); 1409 p->mempolicy = mpol_dup(p->mempolicy);
@@ -1556,6 +1555,7 @@ static struct task_struct *copy_process(unsigned long clone_flags,
1556 INIT_LIST_HEAD(&p->thread_group); 1555 INIT_LIST_HEAD(&p->thread_group);
1557 p->task_works = NULL; 1556 p->task_works = NULL;
1558 1557
1558 threadgroup_change_begin(current);
1559 /* 1559 /*
1560 * Ensure that the cgroup subsystem policies allow the new process to be 1560 * Ensure that the cgroup subsystem policies allow the new process to be
1561 * forked. It should be noted the the new process's css_set can be changed 1561 * forked. It should be noted the the new process's css_set can be changed
@@ -1656,6 +1656,7 @@ static struct task_struct *copy_process(unsigned long clone_flags,
1656bad_fork_cancel_cgroup: 1656bad_fork_cancel_cgroup:
1657 cgroup_cancel_fork(p); 1657 cgroup_cancel_fork(p);
1658bad_fork_free_pid: 1658bad_fork_free_pid:
1659 threadgroup_change_end(current);
1659 if (pid != &init_struct_pid) 1660 if (pid != &init_struct_pid)
1660 free_pid(pid); 1661 free_pid(pid);
1661bad_fork_cleanup_thread: 1662bad_fork_cleanup_thread:
@@ -1688,7 +1689,6 @@ bad_fork_cleanup_policy:
1688 mpol_put(p->mempolicy); 1689 mpol_put(p->mempolicy);
1689bad_fork_cleanup_threadgroup_lock: 1690bad_fork_cleanup_threadgroup_lock:
1690#endif 1691#endif
1691 threadgroup_change_end(current);
1692 delayacct_tsk_free(p); 1692 delayacct_tsk_free(p);
1693bad_fork_cleanup_count: 1693bad_fork_cleanup_count:
1694 atomic_dec(&p->cred->user->processes); 1694 atomic_dec(&p->cred->user->processes);