diff options
author | Lai Jiangshan <laijs@cn.fujitsu.com> | 2009-01-07 21:08:39 -0500 |
---|---|---|
committer | Linus Torvalds <torvalds@linux-foundation.org> | 2009-01-08 11:31:11 -0500 |
commit | 13337714f3b0307dc7f75ef5d83ecf0db2abbd65 (patch) | |
tree | f76dd8961b9287b25e2ea24d2d34fecc52d2c8a0 | |
parent | e7c5ec9193d32b9559a3bb8893ceedbda85201ff (diff) |
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: Lai Jiangshan <laijs@cn.fujitsu.com>
Acked-by: Paul 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: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
-rw-r--r-- | kernel/cpuset.c | 11 |
1 files changed, 3 insertions, 8 deletions
diff --git a/kernel/cpuset.c b/kernel/cpuset.c index 345ace5117de..a841b5c01ef9 100644 --- a/kernel/cpuset.c +++ b/kernel/cpuset.c | |||
@@ -375,14 +375,9 @@ void cpuset_update_task_memory_state(void) | |||
375 | struct task_struct *tsk = current; | 375 | struct task_struct *tsk = current; |
376 | struct cpuset *cs; | 376 | struct cpuset *cs; |
377 | 377 | ||
378 | if (task_cs(tsk) == &top_cpuset) { | 378 | rcu_read_lock(); |
379 | /* Don't need rcu for top_cpuset. It's never freed. */ | 379 | my_cpusets_mem_gen = task_cs(tsk)->mems_generation; |
380 | my_cpusets_mem_gen = top_cpuset.mems_generation; | 380 | rcu_read_unlock(); |
381 | } else { | ||
382 | rcu_read_lock(); | ||
383 | my_cpusets_mem_gen = task_cs(tsk)->mems_generation; | ||
384 | rcu_read_unlock(); | ||
385 | } | ||
386 | 381 | ||
387 | if (my_cpusets_mem_gen != tsk->cpuset_mems_generation) { | 382 | if (my_cpusets_mem_gen != tsk->cpuset_mems_generation) { |
388 | mutex_lock(&callback_mutex); | 383 | mutex_lock(&callback_mutex); |