Skip to content

Commit 748e7fc

Browse files
committed
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
2 parents e4e98c4 + 568ac88 commit 748e7fc

File tree

2 files changed

+17
-2
lines changed

2 files changed

+17
-2
lines changed

kernel/cpuset.c

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2069,6 +2069,20 @@ static void cpuset_bind(struct cgroup_subsys_state *root_css)
20692069
mutex_unlock(&cpuset_mutex);
20702070
}
20712071

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+
*/
2077+
void 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+
20722086
struct cgroup_subsys cpuset_cgrp_subsys = {
20732087
.css_alloc = cpuset_css_alloc,
20742088
.css_online = cpuset_css_online,
@@ -2079,6 +2093,7 @@ struct cgroup_subsys cpuset_cgrp_subsys = {
20792093
.attach = cpuset_attach,
20802094
.post_attach = cpuset_post_attach,
20812095
.bind = cpuset_bind,
2096+
.fork = cpuset_fork,
20822097
.legacy_cftypes = files,
20832098
.early_init = true,
20842099
};

kernel/fork.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1404,7 +1404,6 @@ static struct task_struct *copy_process(unsigned long clone_flags,
14041404
p->real_start_time = ktime_get_boot_ns();
14051405
p->io_context = NULL;
14061406
p->audit_context = NULL;
1407-
threadgroup_change_begin(current);
14081407
cgroup_fork(p);
14091408
#ifdef CONFIG_NUMA
14101409
p->mempolicy = mpol_dup(p->mempolicy);
@@ -1556,6 +1555,7 @@ static struct task_struct *copy_process(unsigned long clone_flags,
15561555
INIT_LIST_HEAD(&p->thread_group);
15571556
p->task_works = NULL;
15581557

1558+
threadgroup_change_begin(current);
15591559
/*
15601560
* Ensure that the cgroup subsystem policies allow the new process to be
15611561
* 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,
16561656
bad_fork_cancel_cgroup:
16571657
cgroup_cancel_fork(p);
16581658
bad_fork_free_pid:
1659+
threadgroup_change_end(current);
16591660
if (pid != &init_struct_pid)
16601661
free_pid(pid);
16611662
bad_fork_cleanup_thread:
@@ -1688,7 +1689,6 @@ static struct task_struct *copy_process(unsigned long clone_flags,
16881689
mpol_put(p->mempolicy);
16891690
bad_fork_cleanup_threadgroup_lock:
16901691
#endif
1691-
threadgroup_change_end(current);
16921692
delayacct_tsk_free(p);
16931693
bad_fork_cleanup_count:
16941694
atomic_dec(&p->cred->user->processes);

0 commit comments

Comments
 (0)