* guarantees cgroups with bigger numbers are newer than those with smaller
* numbers. Also, as cgroups are always appended to the parent's
* ->children list, it guarantees that sibling cgroups are always sorted in
- * the ascending serial number order on the list.
+ * the ascending serial number order on the list. Protected by
+ * cgroup_mutex.
*/
-static atomic64_t cgroup_serial_nr_cursor = ATOMIC64_INIT(0);
+static u64 cgroup_serial_nr_next = 1;
/* This flag indicates whether tasks in the fork and exit paths should
* check for fork/exit handlers to call. This avoids us having to do
struct super_block *sb = ss->root->sb;
struct dentry *prev = NULL;
struct inode *inode;
- u64 update_upto;
+ u64 update_before;
/* %NULL @cfts indicates abort and don't bother if @ss isn't attached */
if (!cfts || ss->root == &rootnode ||
/*
* All cgroups which are created after we drop cgroup_mutex will
* have the updated set of files, so we only need to update the
- * cgroups created before the current @cgroup_serial_nr_cursor.
+ * cgroups created before the current @cgroup_serial_nr_next.
*/
- update_upto = atomic64_read(&cgroup_serial_nr_cursor);
+ update_before = cgroup_serial_nr_next;
mutex_unlock(&cgroup_mutex);
mutex_lock(&inode->i_mutex);
mutex_lock(&cgroup_mutex);
- if (cgrp->serial_nr <= update_upto && !cgroup_is_dead(cgrp))
+ if (cgrp->serial_nr < update_before && !cgroup_is_dead(cgrp))
cgroup_addrm_files(cgrp, ss, cfts, is_add);
mutex_unlock(&cgroup_mutex);
mutex_unlock(&inode->i_mutex);
goto err_free_all;
lockdep_assert_held(&dentry->d_inode->i_mutex);
- cgrp->serial_nr = atomic64_inc_return(&cgroup_serial_nr_cursor);
+ cgrp->serial_nr = cgroup_serial_nr_next++;
/* allocation complete, commit to creation */
list_add_tail_rcu(&cgrp->sibling, &cgrp->parent->children);