Commit 13337714 authored by Lai Jiangshan's avatar Lai Jiangshan Committed by Linus Torvalds

cpuset: rcu_read_lock() to protect task_cs()

task_cs() calls task_subsys_state().

We must use rcu_read_lock() to protect cgroup_subsys_state().

It's correct that top_cpuset is never freed, but cgroup_subsys_state()
accesses css_set, this css_set maybe freed when task_cs() called.

We use use rcu_read_lock() to protect it.
Signed-off-by: default avatarLai Jiangshan <laijs@cn.fujitsu.com>
Acked-by: default avatarPaul Menage <menage@google.com>
Cc: KAMEZAWA Hiroyuki <kamezawa.hiroyu@jp.fujitsu.com>
Cc: Pavel Emelyanov <xemul@openvz.org>
Cc: Balbir Singh <balbir@in.ibm.com>
Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
parent e7c5ec91
...@@ -375,14 +375,9 @@ void cpuset_update_task_memory_state(void) ...@@ -375,14 +375,9 @@ void cpuset_update_task_memory_state(void)
struct task_struct *tsk = current; struct task_struct *tsk = current;
struct cpuset *cs; struct cpuset *cs;
if (task_cs(tsk) == &top_cpuset) {
/* Don't need rcu for top_cpuset. It's never freed. */
my_cpusets_mem_gen = top_cpuset.mems_generation;
} else {
rcu_read_lock(); rcu_read_lock();
my_cpusets_mem_gen = task_cs(tsk)->mems_generation; my_cpusets_mem_gen = task_cs(tsk)->mems_generation;
rcu_read_unlock(); rcu_read_unlock();
}
if (my_cpusets_mem_gen != tsk->cpuset_mems_generation) { if (my_cpusets_mem_gen != tsk->cpuset_mems_generation) {
mutex_lock(&callback_mutex); mutex_lock(&callback_mutex);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment