diff options
author | Lai Jiangshan <laijs@cn.fujitsu.com> | 2008-10-18 23:28:03 -0400 |
---|---|---|
committer | Linus Torvalds <torvalds@linux-foundation.org> | 2008-10-20 11:52:38 -0400 |
commit | 146aa1bd0511f88ddb4e92fafa2b8aad4f2f65f3 (patch) | |
tree | d7deb46b9a38f82f109b2126317899efbbce41c2 /include | |
parent | 248736c2a57206388c86f8cdd3392ee986e84f9f (diff) |
cgroups: fix probable race with put_css_set[_taskexit] and find_css_set
put_css_set_taskexit may be called when find_css_set is called on other
cpu. And the race will occur:
put_css_set_taskexit side find_css_set side
|
atomic_dec_and_test(&kref->refcount) |
/* kref->refcount = 0 */ |
....................................................................
| read_lock(&css_set_lock)
| find_existing_css_set
| get_css_set
| read_unlock(&css_set_lock);
....................................................................
__release_css_set |
....................................................................
| /* use a released css_set */
|
[put_css_set is the same. But in the current code, all put_css_set are
put into cgroup mutex critical region as the same as find_css_set.]
[akpm@linux-foundation.org: repair comments]
[menage@google.com: eliminate race in css_set refcounting]
Signed-off-by: Lai Jiangshan <laijs@cn.fujitsu.com>
Cc: Balbir Singh <balbir@in.ibm.com>
Cc: KAMEZAWA Hiroyuki <kamezawa.hiroyu@jp.fujitsu.com>
Signed-off-by: Paul Menage <menage@google.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to 'include')
-rw-r--r-- | include/linux/cgroup.h | 3 |
1 files changed, 1 insertions, 2 deletions
diff --git a/include/linux/cgroup.h b/include/linux/cgroup.h index 30934e4bfaab..7166023e07d2 100644 --- a/include/linux/cgroup.h +++ b/include/linux/cgroup.h | |||
@@ -9,7 +9,6 @@ | |||
9 | */ | 9 | */ |
10 | 10 | ||
11 | #include <linux/sched.h> | 11 | #include <linux/sched.h> |
12 | #include <linux/kref.h> | ||
13 | #include <linux/cpumask.h> | 12 | #include <linux/cpumask.h> |
14 | #include <linux/nodemask.h> | 13 | #include <linux/nodemask.h> |
15 | #include <linux/rcupdate.h> | 14 | #include <linux/rcupdate.h> |
@@ -149,7 +148,7 @@ struct cgroup { | |||
149 | struct css_set { | 148 | struct css_set { |
150 | 149 | ||
151 | /* Reference count */ | 150 | /* Reference count */ |
152 | struct kref ref; | 151 | atomic_t refcount; |
153 | 152 | ||
154 | /* | 153 | /* |
155 | * List running through all cgroup groups in the same hash | 154 | * List running through all cgroup groups in the same hash |