Commit 5f617ebb authored by Tejun Heo's avatar Tejun Heo

cgroup: reorder css_set fields

Reorder css_set fields so that they're roughly in the order of how hot
they are.  The rough order is

1. the actual csses
2. reference counter and the default cgroup pointer.
3. task lists and iterations
4. fields used during merge including css_set lookup
5. the rest
Signed-off-by: default avatarTejun Heo <tj@kernel.org>
Acked-by: default avatarAcked-by: Zefan Li <lizefan@huawei.com>
parent 2fae9863
...@@ -148,14 +148,18 @@ struct cgroup_subsys_state { ...@@ -148,14 +148,18 @@ struct cgroup_subsys_state {
* set for a task. * set for a task.
*/ */
struct css_set { struct css_set {
/* Reference count */
atomic_t refcount;
/* /*
* List running through all cgroup groups in the same hash * Set of subsystem states, one for each subsystem. This array is
* slot. Protected by css_set_lock * immutable after creation apart from the init_css_set during
* subsystem registration (at boot time).
*/ */
struct hlist_node hlist; struct cgroup_subsys_state *subsys[CGROUP_SUBSYS_COUNT];
/* reference count */
atomic_t refcount;
/* the default cgroup associated with this css_set */
struct cgroup *dfl_cgrp;
/* /*
* Lists running through all tasks using this cgroup group. * Lists running through all tasks using this cgroup group.
...@@ -167,21 +171,29 @@ struct css_set { ...@@ -167,21 +171,29 @@ struct css_set {
struct list_head tasks; struct list_head tasks;
struct list_head mg_tasks; struct list_head mg_tasks;
/* all css_task_iters currently walking this cset */
struct list_head task_iters;
/* /*
* List of cgrp_cset_links pointing at cgroups referenced from this * On the default hierarhcy, ->subsys[ssid] may point to a css
* css_set. Protected by css_set_lock. * attached to an ancestor instead of the cgroup this css_set is
* associated with. The following node is anchored at
* ->subsys[ssid]->cgroup->e_csets[ssid] and provides a way to
* iterate through all css's attached to a given cgroup.
*/ */
struct list_head cgrp_links; struct list_head e_cset_node[CGROUP_SUBSYS_COUNT];
/* the default cgroup associated with this css_set */ /*
struct cgroup *dfl_cgrp; * List running through all cgroup groups in the same hash
* slot. Protected by css_set_lock
*/
struct hlist_node hlist;
/* /*
* Set of subsystem states, one for each subsystem. This array is * List of cgrp_cset_links pointing at cgroups referenced from this
* immutable after creation apart from the init_css_set during * css_set. Protected by css_set_lock.
* subsystem registration (at boot time).
*/ */
struct cgroup_subsys_state *subsys[CGROUP_SUBSYS_COUNT]; struct list_head cgrp_links;
/* /*
* List of csets participating in the on-going migration either as * List of csets participating in the on-going migration either as
...@@ -201,18 +213,6 @@ struct css_set { ...@@ -201,18 +213,6 @@ struct css_set {
struct cgroup *mg_dst_cgrp; struct cgroup *mg_dst_cgrp;
struct css_set *mg_dst_cset; struct css_set *mg_dst_cset;
/*
* On the default hierarhcy, ->subsys[ssid] may point to a css
* attached to an ancestor instead of the cgroup this css_set is
* associated with. The following node is anchored at
* ->subsys[ssid]->cgroup->e_csets[ssid] and provides a way to
* iterate through all css's attached to a given cgroup.
*/
struct list_head e_cset_node[CGROUP_SUBSYS_COUNT];
/* all css_task_iters currently walking this cset */
struct list_head task_iters;
/* dead and being drained, ignore for migration */ /* dead and being drained, ignore for migration */
bool dead; bool dead;
......
...@@ -647,12 +647,12 @@ struct cgrp_cset_link { ...@@ -647,12 +647,12 @@ struct cgrp_cset_link {
*/ */
struct css_set init_css_set = { struct css_set init_css_set = {
.refcount = ATOMIC_INIT(1), .refcount = ATOMIC_INIT(1),
.cgrp_links = LIST_HEAD_INIT(init_css_set.cgrp_links),
.tasks = LIST_HEAD_INIT(init_css_set.tasks), .tasks = LIST_HEAD_INIT(init_css_set.tasks),
.mg_tasks = LIST_HEAD_INIT(init_css_set.mg_tasks), .mg_tasks = LIST_HEAD_INIT(init_css_set.mg_tasks),
.task_iters = LIST_HEAD_INIT(init_css_set.task_iters),
.cgrp_links = LIST_HEAD_INIT(init_css_set.cgrp_links),
.mg_preload_node = LIST_HEAD_INIT(init_css_set.mg_preload_node), .mg_preload_node = LIST_HEAD_INIT(init_css_set.mg_preload_node),
.mg_node = LIST_HEAD_INIT(init_css_set.mg_node), .mg_node = LIST_HEAD_INIT(init_css_set.mg_node),
.task_iters = LIST_HEAD_INIT(init_css_set.task_iters),
}; };
static int css_set_count = 1; /* 1 for init_css_set */ static int css_set_count = 1; /* 1 for init_css_set */
...@@ -1095,13 +1095,13 @@ static struct css_set *find_css_set(struct css_set *old_cset, ...@@ -1095,13 +1095,13 @@ static struct css_set *find_css_set(struct css_set *old_cset,
} }
atomic_set(&cset->refcount, 1); atomic_set(&cset->refcount, 1);
INIT_LIST_HEAD(&cset->cgrp_links);
INIT_LIST_HEAD(&cset->tasks); INIT_LIST_HEAD(&cset->tasks);
INIT_LIST_HEAD(&cset->mg_tasks); INIT_LIST_HEAD(&cset->mg_tasks);
INIT_LIST_HEAD(&cset->mg_preload_node);
INIT_LIST_HEAD(&cset->mg_node);
INIT_LIST_HEAD(&cset->task_iters); INIT_LIST_HEAD(&cset->task_iters);
INIT_HLIST_NODE(&cset->hlist); INIT_HLIST_NODE(&cset->hlist);
INIT_LIST_HEAD(&cset->cgrp_links);
INIT_LIST_HEAD(&cset->mg_preload_node);
INIT_LIST_HEAD(&cset->mg_node);
/* Copy the set of subsystem state objects generated in /* Copy the set of subsystem state objects generated in
* find_existing_css_set() */ * find_existing_css_set() */
...@@ -4384,6 +4384,9 @@ int cgroup_transfer_tasks(struct cgroup *to, struct cgroup *from) ...@@ -4384,6 +4384,9 @@ int cgroup_transfer_tasks(struct cgroup *to, struct cgroup *from)
struct task_struct *task; struct task_struct *task;
int ret; int ret;
if (cgroup_on_dfl(to))
return -EINVAL;
if (!cgroup_may_migrate_to(to)) if (!cgroup_may_migrate_to(to))
return -EBUSY; return -EBUSY;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment