aboutsummaryrefslogtreecommitdiffstats
path: root/kernel/cgroup.c
diff options
context:
space:
mode:
Diffstat (limited to 'kernel/cgroup.c')
-rw-r--r--kernel/cgroup.c18
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
199static struct cgroup_name root_cgroup_name = { .name = "/" }; 199static 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 */
208static 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)
4222static long cgroup_create(struct cgroup *parent, struct dentry *dentry, 4231static 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);