Skip to content
This repository was archived by the owner on Nov 8, 2023. It is now read-only.

Commit 0475cf0

Browse files
committed
Revert "cgroup: Make operations on the cgroup root_list RCU safe"
This reverts commit dd9542a which is commit d23b5c5 upstream. It breaks the Android kernel abi and can be brought back in the future in an abi-safe way if it is really needed. Bug: 161946584 Change-Id: Ia7245694cbdf47e4bf9410f21ff4676f2f5ac528 Signed-off-by: Greg Kroah-Hartman <[email protected]>
1 parent 4cf1497 commit 0475cf0

File tree

3 files changed

+8
-19
lines changed

3 files changed

+8
-19
lines changed

include/linux/cgroup-defs.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -575,7 +575,6 @@ struct cgroup_root {
575575

576576
/* A list running through the active hierarchies */
577577
struct list_head root_list;
578-
struct rcu_head rcu;
579578

580579
/* Hierarchy-specific flags */
581580
unsigned int flags;

kernel/cgroup/cgroup-internal.h

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -170,8 +170,7 @@ extern struct list_head cgroup_roots;
170170

171171
/* iterate across the hierarchies */
172172
#define for_each_root(root) \
173-
list_for_each_entry_rcu((root), &cgroup_roots, root_list, \
174-
lockdep_is_held(&cgroup_mutex))
173+
list_for_each_entry((root), &cgroup_roots, root_list)
175174

176175
/**
177176
* for_each_subsys - iterate all enabled cgroup subsystems

kernel/cgroup/cgroup.c

Lines changed: 7 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1317,7 +1317,7 @@ static void cgroup_exit_root_id(struct cgroup_root *root)
13171317

13181318
void cgroup_free_root(struct cgroup_root *root)
13191319
{
1320-
kfree_rcu(root, rcu);
1320+
kfree(root);
13211321
}
13221322

13231323
static void cgroup_destroy_root(struct cgroup_root *root)
@@ -1350,7 +1350,7 @@ static void cgroup_destroy_root(struct cgroup_root *root)
13501350
spin_unlock_irq(&css_set_lock);
13511351

13521352
if (!list_empty(&root->root_list)) {
1353-
list_del_rcu(&root->root_list);
1353+
list_del(&root->root_list);
13541354
cgroup_root_count--;
13551355
}
13561356

@@ -1390,15 +1390,7 @@ static inline struct cgroup *__cset_cgroup_from_root(struct css_set *cset,
13901390
}
13911391
}
13921392

1393-
/*
1394-
* If cgroup_mutex is not held, the cgrp_cset_link will be freed
1395-
* before we remove the cgroup root from the root_list. Consequently,
1396-
* when accessing a cgroup root, the cset_link may have already been
1397-
* freed, resulting in a NULL res_cgroup. However, by holding the
1398-
* cgroup_mutex, we ensure that res_cgroup can't be NULL.
1399-
* If we don't hold cgroup_mutex in the caller, we must do the NULL
1400-
* check.
1401-
*/
1393+
BUG_ON(!res_cgroup);
14021394
return res_cgroup;
14031395
}
14041396

@@ -1457,16 +1449,15 @@ static struct cgroup *current_cgns_cgroup_dfl(void)
14571449
static struct cgroup *cset_cgroup_from_root(struct css_set *cset,
14581450
struct cgroup_root *root)
14591451
{
1452+
lockdep_assert_held(&cgroup_mutex);
14601453
lockdep_assert_held(&css_set_lock);
14611454

14621455
return __cset_cgroup_from_root(cset, root);
14631456
}
14641457

14651458
/*
14661459
* Return the cgroup for "task" from the given hierarchy. Must be
1467-
* called with css_set_lock held to prevent task's groups from being modified.
1468-
* Must be called with either cgroup_mutex or rcu read lock to prevent the
1469-
* cgroup root from being destroyed.
1460+
* called with cgroup_mutex and css_set_lock held.
14701461
*/
14711462
struct cgroup *task_cgroup_from_root(struct task_struct *task,
14721463
struct cgroup_root *root)
@@ -2027,7 +2018,7 @@ void init_cgroup_root(struct cgroup_fs_context *ctx)
20272018
struct cgroup_root *root = ctx->root;
20282019
struct cgroup *cgrp = &root->cgrp;
20292020

2030-
INIT_LIST_HEAD_RCU(&root->root_list);
2021+
INIT_LIST_HEAD(&root->root_list);
20312022
atomic_set(&root->nr_cgrps, 1);
20322023
cgrp->root = root;
20332024
init_cgroup_housekeeping(cgrp);
@@ -2110,7 +2101,7 @@ int cgroup_setup_root(struct cgroup_root *root, u16 ss_mask)
21102101
* care of subsystems' refcounts, which are explicitly dropped in
21112102
* the failure exit path.
21122103
*/
2113-
list_add_rcu(&root->root_list, &cgroup_roots);
2104+
list_add(&root->root_list, &cgroup_roots);
21142105
cgroup_root_count++;
21152106

21162107
/*

0 commit comments

Comments
 (0)