diff options
author | Li Zefan <lizefan@huawei.com> | 2013-06-18 06:53:53 -0400 |
---|---|---|
committer | Tejun Heo <tj@kernel.org> | 2013-06-18 14:14:21 -0400 |
commit | 794611a1dfcb055d7d41ce133378dd8197d73e38 (patch) | |
tree | c89867196b18237422fddf6c62862de08038838a /kernel | |
parent | f57947d27711451a7739a25bba6cddc8a385e438 (diff) |
cgroup: make serial_nr_cursor available throughout cgroup.c
The next patch will use it to determine if a cgroup is newly created
while we're iterating the cgroup hierarchy.
tj: Rephrased the comment on top of cgroup_serial_nr_cursor.
Signed-off-by: Li Zefan <lizefan@huawei.com>
Signed-off-by: Tejun Heo <tj@kernel.org>
Diffstat (limited to 'kernel')
-rw-r--r-- | kernel/cgroup.c | 18 |
1 files changed, 10 insertions, 8 deletions
diff --git a/kernel/cgroup.c b/kernel/cgroup.c index 1d4f471de8d5..e6571ca822a0 100644 --- a/kernel/cgroup.c +++ b/kernel/cgroup.c | |||
@@ -198,6 +198,15 @@ static DEFINE_IDR(cgroup_hierarchy_idr); | |||
198 | 198 | ||
199 | static struct cgroup_name root_cgroup_name = { .name = "/" }; | 199 | static struct cgroup_name root_cgroup_name = { .name = "/" }; |
200 | 200 | ||
201 | /* | ||
202 | * Assign a monotonically increasing serial number to cgroups. It | ||
203 | * guarantees cgroups with bigger numbers are newer than those with smaller | ||
204 | * numbers. Also, as cgroups are always appended to the parent's | ||
205 | * ->children list, it guarantees that sibling cgroups are always sorted in | ||
206 | * the ascending serial number order on the list. | ||
207 | */ | ||
208 | static atomic64_t cgroup_serial_nr_cursor = ATOMIC64_INIT(0); | ||
209 | |||
201 | /* This flag indicates whether tasks in the fork and exit paths should | 210 | /* This flag indicates whether tasks in the fork and exit paths should |
202 | * check for fork/exit handlers to call. This avoids us having to do | 211 | * check for fork/exit handlers to call. This avoids us having to do |
203 | * extra work in the fork/exit path if none of the subsystems need to | 212 | * extra work in the fork/exit path if none of the subsystems need to |
@@ -4222,7 +4231,6 @@ static void offline_css(struct cgroup_subsys *ss, struct cgroup *cgrp) | |||
4222 | static long cgroup_create(struct cgroup *parent, struct dentry *dentry, | 4231 | static long cgroup_create(struct cgroup *parent, struct dentry *dentry, |
4223 | umode_t mode) | 4232 | umode_t mode) |
4224 | { | 4233 | { |
4225 | static atomic64_t serial_nr_cursor = ATOMIC64_INIT(0); | ||
4226 | struct cgroup *cgrp; | 4234 | struct cgroup *cgrp; |
4227 | struct cgroup_name *name; | 4235 | struct cgroup_name *name; |
4228 | struct cgroupfs_root *root = parent->root; | 4236 | struct cgroupfs_root *root = parent->root; |
@@ -4309,13 +4317,7 @@ static long cgroup_create(struct cgroup *parent, struct dentry *dentry, | |||
4309 | goto err_free_all; | 4317 | goto err_free_all; |
4310 | lockdep_assert_held(&dentry->d_inode->i_mutex); | 4318 | lockdep_assert_held(&dentry->d_inode->i_mutex); |
4311 | 4319 | ||
4312 | /* | 4320 | cgrp->serial_nr = atomic64_inc_return(&cgroup_serial_nr_cursor); |
4313 | * Assign a monotonically increasing serial number. With the list | ||
4314 | * appending below, it guarantees that sibling cgroups are always | ||
4315 | * sorted in the ascending serial number order on the parent's | ||
4316 | * ->children. | ||
4317 | */ | ||
4318 | cgrp->serial_nr = atomic64_inc_return(&serial_nr_cursor); | ||
4319 | 4321 | ||
4320 | /* allocation complete, commit to creation */ | 4322 | /* allocation complete, commit to creation */ |
4321 | list_add_tail(&cgrp->allcg_node, &root->allcg_list); | 4323 | list_add_tail(&cgrp->allcg_node, &root->allcg_list); |