aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--block/blk-cgroup.c25
-rw-r--r--include/linux/cgroup.h24
-rw-r--r--kernel/cgroup.c57
-rw-r--r--kernel/cgroup_freezer.c40
-rw-r--r--kernel/cpuset.c39
-rw-r--r--kernel/events/core.c18
-rw-r--r--kernel/sched/core.c39
-rw-r--r--kernel/sched/cpuacct.c9
-rw-r--r--mm/hugetlb_cgroup.c19
-rw-r--r--mm/memcontrol.c38
-rw-r--r--net/core/netprio_cgroup.c20
-rw-r--r--net/sched/cls_cgroup.c18
-rw-r--r--security/device_cgroup.c22
13 files changed, 197 insertions, 171 deletions
diff --git a/block/blk-cgroup.c b/block/blk-cgroup.c
index 290792a13e3c..79fd9f4fadb7 100644
--- a/block/blk-cgroup.c
+++ b/block/blk-cgroup.c
@@ -765,18 +765,18 @@ struct cftype blkcg_files[] = {
765 765
766/** 766/**
767 * blkcg_css_offline - cgroup css_offline callback 767 * blkcg_css_offline - cgroup css_offline callback
768 * @cgroup: cgroup of interest 768 * @css: css of interest
769 * 769 *
770 * This function is called when @cgroup is about to go away and responsible 770 * This function is called when @css is about to go away and responsible
771 * for shooting down all blkgs associated with @cgroup. blkgs should be 771 * for shooting down all blkgs associated with @css. blkgs should be
772 * removed while holding both q and blkcg locks. As blkcg lock is nested 772 * removed while holding both q and blkcg locks. As blkcg lock is nested
773 * inside q lock, this function performs reverse double lock dancing. 773 * inside q lock, this function performs reverse double lock dancing.
774 * 774 *
775 * This is the blkcg counterpart of ioc_release_fn(). 775 * This is the blkcg counterpart of ioc_release_fn().
776 */ 776 */
777static void blkcg_css_offline(struct cgroup *cgroup) 777static void blkcg_css_offline(struct cgroup_subsys_state *css)
778{ 778{
779 struct blkcg *blkcg = cgroup_to_blkcg(cgroup); 779 struct blkcg *blkcg = css_to_blkcg(css);
780 780
781 spin_lock_irq(&blkcg->lock); 781 spin_lock_irq(&blkcg->lock);
782 782
@@ -798,21 +798,21 @@ static void blkcg_css_offline(struct cgroup *cgroup)
798 spin_unlock_irq(&blkcg->lock); 798 spin_unlock_irq(&blkcg->lock);
799} 799}
800 800
801static void blkcg_css_free(struct cgroup *cgroup) 801static void blkcg_css_free(struct cgroup_subsys_state *css)
802{ 802{
803 struct blkcg *blkcg = cgroup_to_blkcg(cgroup); 803 struct blkcg *blkcg = css_to_blkcg(css);
804 804
805 if (blkcg != &blkcg_root) 805 if (blkcg != &blkcg_root)
806 kfree(blkcg); 806 kfree(blkcg);
807} 807}
808 808
809static struct cgroup_subsys_state *blkcg_css_alloc(struct cgroup *cgroup) 809static struct cgroup_subsys_state *
810blkcg_css_alloc(struct cgroup_subsys_state *parent_css)
810{ 811{
811 static atomic64_t id_seq = ATOMIC64_INIT(0); 812 static atomic64_t id_seq = ATOMIC64_INIT(0);
812 struct blkcg *blkcg; 813 struct blkcg *blkcg;
813 struct cgroup *parent = cgroup->parent;
814 814
815 if (!parent) { 815 if (!parent_css) {
816 blkcg = &blkcg_root; 816 blkcg = &blkcg_root;
817 goto done; 817 goto done;
818 } 818 }
@@ -883,14 +883,15 @@ void blkcg_exit_queue(struct request_queue *q)
883 * of the main cic data structures. For now we allow a task to change 883 * of the main cic data structures. For now we allow a task to change
884 * its cgroup only if it's the only owner of its ioc. 884 * its cgroup only if it's the only owner of its ioc.
885 */ 885 */
886static int blkcg_can_attach(struct cgroup *cgrp, struct cgroup_taskset *tset) 886static int blkcg_can_attach(struct cgroup_subsys_state *css,
887 struct cgroup_taskset *tset)
887{ 888{
888 struct task_struct *task; 889 struct task_struct *task;
889 struct io_context *ioc; 890 struct io_context *ioc;
890 int ret = 0; 891 int ret = 0;
891 892
892 /* task_lock() is needed to avoid races with exit_io_context() */ 893 /* task_lock() is needed to avoid races with exit_io_context() */
893 cgroup_taskset_for_each(task, cgrp, tset) { 894 cgroup_taskset_for_each(task, css->cgroup, tset) {
894 task_lock(task); 895 task_lock(task);
895 ioc = task->io_context; 896 ioc = task->io_context;
896 if (ioc && atomic_read(&ioc->nr_tasks) > 1) 897 if (ioc && atomic_read(&ioc->nr_tasks) > 1)
diff --git a/include/linux/cgroup.h b/include/linux/cgroup.h
index 18112a3bb12b..9c2b9dd9121d 100644
--- a/include/linux/cgroup.h
+++ b/include/linux/cgroup.h
@@ -579,18 +579,22 @@ int cgroup_taskset_size(struct cgroup_taskset *tset);
579 */ 579 */
580 580
581struct cgroup_subsys { 581struct cgroup_subsys {
582 struct cgroup_subsys_state *(*css_alloc)(struct cgroup *cgrp); 582 struct cgroup_subsys_state *(*css_alloc)(struct cgroup_subsys_state *parent_css);
583 int (*css_online)(struct cgroup *cgrp); 583 int (*css_online)(struct cgroup_subsys_state *css);
584 void (*css_offline)(struct cgroup *cgrp); 584 void (*css_offline)(struct cgroup_subsys_state *css);
585 void (*css_free)(struct cgroup *cgrp); 585 void (*css_free)(struct cgroup_subsys_state *css);
586 586
587 int (*can_attach)(struct cgroup *cgrp, struct cgroup_taskset *tset); 587 int (*can_attach)(struct cgroup_subsys_state *css,
588 void (*cancel_attach)(struct cgroup *cgrp, struct cgroup_taskset *tset); 588 struct cgroup_taskset *tset);
589 void (*attach)(struct cgroup *cgrp, struct cgroup_taskset *tset); 589 void (*cancel_attach)(struct cgroup_subsys_state *css,
590 struct cgroup_taskset *tset);
591 void (*attach)(struct cgroup_subsys_state *css,
592 struct cgroup_taskset *tset);
590 void (*fork)(struct task_struct *task); 593 void (*fork)(struct task_struct *task);
591 void (*exit)(struct cgroup *cgrp, struct cgroup *old_cgrp, 594 void (*exit)(struct cgroup_subsys_state *css,
595 struct cgroup_subsys_state *old_css,
592 struct task_struct *task); 596 struct task_struct *task);
593 void (*bind)(struct cgroup *root); 597 void (*bind)(struct cgroup_subsys_state *root_css);
594 598
595 int subsys_id; 599 int subsys_id;
596 int disabled; 600 int disabled;
diff --git a/kernel/cgroup.c b/kernel/cgroup.c
index 4234428f1014..271d9a5cde5f 100644
--- a/kernel/cgroup.c
+++ b/kernel/cgroup.c
@@ -853,8 +853,11 @@ static void cgroup_free_fn(struct work_struct *work)
853 /* 853 /*
854 * Release the subsystem state objects. 854 * Release the subsystem state objects.
855 */ 855 */
856 for_each_root_subsys(cgrp->root, ss) 856 for_each_root_subsys(cgrp->root, ss) {
857 ss->css_free(cgrp); 857 struct cgroup_subsys_state *css = cgrp->subsys[ss->subsys_id];
858
859 ss->css_free(css);
860 }
858 861
859 cgrp->root->number_of_cgroups--; 862 cgrp->root->number_of_cgroups--;
860 mutex_unlock(&cgroup_mutex); 863 mutex_unlock(&cgroup_mutex);
@@ -1056,7 +1059,7 @@ static int rebind_subsystems(struct cgroupfs_root *root,
1056 list_move(&ss->sibling, &root->subsys_list); 1059 list_move(&ss->sibling, &root->subsys_list);
1057 ss->root = root; 1060 ss->root = root;
1058 if (ss->bind) 1061 if (ss->bind)
1059 ss->bind(cgrp); 1062 ss->bind(cgrp->subsys[i]);
1060 1063
1061 /* refcount was already taken, and we're keeping it */ 1064 /* refcount was already taken, and we're keeping it */
1062 root->subsys_mask |= bit; 1065 root->subsys_mask |= bit;
@@ -1066,7 +1069,7 @@ static int rebind_subsystems(struct cgroupfs_root *root,
1066 BUG_ON(cgrp->subsys[i]->cgroup != cgrp); 1069 BUG_ON(cgrp->subsys[i]->cgroup != cgrp);
1067 1070
1068 if (ss->bind) 1071 if (ss->bind)
1069 ss->bind(cgroup_dummy_top); 1072 ss->bind(cgroup_dummy_top->subsys[i]);
1070 cgroup_dummy_top->subsys[i]->cgroup = cgroup_dummy_top; 1073 cgroup_dummy_top->subsys[i]->cgroup = cgroup_dummy_top;
1071 cgrp->subsys[i] = NULL; 1074 cgrp->subsys[i] = NULL;
1072 cgroup_subsys[i]->root = &cgroup_dummy_root; 1075 cgroup_subsys[i]->root = &cgroup_dummy_root;
@@ -2049,8 +2052,10 @@ static int cgroup_attach_task(struct cgroup *cgrp, struct task_struct *tsk,
2049 * step 1: check that we can legitimately attach to the cgroup. 2052 * step 1: check that we can legitimately attach to the cgroup.
2050 */ 2053 */
2051 for_each_root_subsys(root, ss) { 2054 for_each_root_subsys(root, ss) {
2055 struct cgroup_subsys_state *css = cgrp->subsys[ss->subsys_id];
2056
2052 if (ss->can_attach) { 2057 if (ss->can_attach) {
2053 retval = ss->can_attach(cgrp, &tset); 2058 retval = ss->can_attach(css, &tset);
2054 if (retval) { 2059 if (retval) {
2055 failed_ss = ss; 2060 failed_ss = ss;
2056 goto out_cancel_attach; 2061 goto out_cancel_attach;
@@ -2089,8 +2094,10 @@ static int cgroup_attach_task(struct cgroup *cgrp, struct task_struct *tsk,
2089 * step 4: do subsystem attach callbacks. 2094 * step 4: do subsystem attach callbacks.
2090 */ 2095 */
2091 for_each_root_subsys(root, ss) { 2096 for_each_root_subsys(root, ss) {
2097 struct cgroup_subsys_state *css = cgrp->subsys[ss->subsys_id];
2098
2092 if (ss->attach) 2099 if (ss->attach)
2093 ss->attach(cgrp, &tset); 2100 ss->attach(css, &tset);
2094 } 2101 }
2095 2102
2096 /* 2103 /*
@@ -2109,10 +2116,12 @@ out_put_css_set_refs:
2109out_cancel_attach: 2116out_cancel_attach:
2110 if (retval) { 2117 if (retval) {
2111 for_each_root_subsys(root, ss) { 2118 for_each_root_subsys(root, ss) {
2119 struct cgroup_subsys_state *css = cgrp->subsys[ss->subsys_id];
2120
2112 if (ss == failed_ss) 2121 if (ss == failed_ss)
2113 break; 2122 break;
2114 if (ss->cancel_attach) 2123 if (ss->cancel_attach)
2115 ss->cancel_attach(cgrp, &tset); 2124 ss->cancel_attach(css, &tset);
2116 } 2125 }
2117 } 2126 }
2118out_free_group_list: 2127out_free_group_list:
@@ -4206,14 +4215,15 @@ static void init_cgroup_css(struct cgroup_subsys_state *css,
4206/* invoke ->css_online() on a new CSS and mark it online if successful */ 4215/* invoke ->css_online() on a new CSS and mark it online if successful */
4207static int online_css(struct cgroup_subsys *ss, struct cgroup *cgrp) 4216static int online_css(struct cgroup_subsys *ss, struct cgroup *cgrp)
4208{ 4217{
4218 struct cgroup_subsys_state *css = cgrp->subsys[ss->subsys_id];
4209 int ret = 0; 4219 int ret = 0;
4210 4220
4211 lockdep_assert_held(&cgroup_mutex); 4221 lockdep_assert_held(&cgroup_mutex);
4212 4222
4213 if (ss->css_online) 4223 if (ss->css_online)
4214 ret = ss->css_online(cgrp); 4224 ret = ss->css_online(css);
4215 if (!ret) 4225 if (!ret)
4216 cgrp->subsys[ss->subsys_id]->flags |= CSS_ONLINE; 4226 css->flags |= CSS_ONLINE;
4217 return ret; 4227 return ret;
4218} 4228}
4219 4229
@@ -4228,9 +4238,9 @@ static void offline_css(struct cgroup_subsys *ss, struct cgroup *cgrp)
4228 return; 4238 return;
4229 4239
4230 if (ss->css_offline) 4240 if (ss->css_offline)
4231 ss->css_offline(cgrp); 4241 ss->css_offline(css);
4232 4242
4233 cgrp->subsys[ss->subsys_id]->flags &= ~CSS_ONLINE; 4243 css->flags &= ~CSS_ONLINE;
4234} 4244}
4235 4245
4236/* 4246/*
@@ -4305,7 +4315,7 @@ static long cgroup_create(struct cgroup *parent, struct dentry *dentry,
4305 for_each_root_subsys(root, ss) { 4315 for_each_root_subsys(root, ss) {
4306 struct cgroup_subsys_state *css; 4316 struct cgroup_subsys_state *css;
4307 4317
4308 css = ss->css_alloc(cgrp); 4318 css = ss->css_alloc(parent->subsys[ss->subsys_id]);
4309 if (IS_ERR(css)) { 4319 if (IS_ERR(css)) {
4310 err = PTR_ERR(css); 4320 err = PTR_ERR(css);
4311 goto err_free_all; 4321 goto err_free_all;
@@ -4313,7 +4323,7 @@ static long cgroup_create(struct cgroup *parent, struct dentry *dentry,
4313 4323
4314 err = percpu_ref_init(&css->refcnt, css_release); 4324 err = percpu_ref_init(&css->refcnt, css_release);
4315 if (err) { 4325 if (err) {
4316 ss->css_free(cgrp); 4326 ss->css_free(css);
4317 goto err_free_all; 4327 goto err_free_all;
4318 } 4328 }
4319 4329
@@ -4386,7 +4396,7 @@ err_free_all:
4386 4396
4387 if (css) { 4397 if (css) {
4388 percpu_ref_cancel_init(&css->refcnt); 4398 percpu_ref_cancel_init(&css->refcnt);
4389 ss->css_free(cgrp); 4399 ss->css_free(css);
4390 } 4400 }
4391 } 4401 }
4392 mutex_unlock(&cgroup_mutex); 4402 mutex_unlock(&cgroup_mutex);
@@ -4641,7 +4651,7 @@ static void __init cgroup_init_subsys(struct cgroup_subsys *ss)
4641 /* Create the top cgroup state for this subsystem */ 4651 /* Create the top cgroup state for this subsystem */
4642 list_add(&ss->sibling, &cgroup_dummy_root.subsys_list); 4652 list_add(&ss->sibling, &cgroup_dummy_root.subsys_list);
4643 ss->root = &cgroup_dummy_root; 4653 ss->root = &cgroup_dummy_root;
4644 css = ss->css_alloc(cgroup_dummy_top); 4654 css = ss->css_alloc(cgroup_dummy_top->subsys[ss->subsys_id]);
4645 /* We don't handle early failures gracefully */ 4655 /* We don't handle early failures gracefully */
4646 BUG_ON(IS_ERR(css)); 4656 BUG_ON(IS_ERR(css));
4647 init_cgroup_css(css, ss, cgroup_dummy_top); 4657 init_cgroup_css(css, ss, cgroup_dummy_top);
@@ -4720,7 +4730,7 @@ int __init_or_module cgroup_load_subsys(struct cgroup_subsys *ss)
4720 * struct, so this can happen first (i.e. before the dummy root 4730 * struct, so this can happen first (i.e. before the dummy root
4721 * attachment). 4731 * attachment).
4722 */ 4732 */
4723 css = ss->css_alloc(cgroup_dummy_top); 4733 css = ss->css_alloc(cgroup_dummy_top->subsys[ss->subsys_id]);
4724 if (IS_ERR(css)) { 4734 if (IS_ERR(css)) {
4725 /* failure case - need to deassign the cgroup_subsys[] slot. */ 4735 /* failure case - need to deassign the cgroup_subsys[] slot. */
4726 cgroup_subsys[ss->subsys_id] = NULL; 4736 cgroup_subsys[ss->subsys_id] = NULL;
@@ -4836,7 +4846,7 @@ void cgroup_unload_subsys(struct cgroup_subsys *ss)
4836 * the cgrp->subsys pointer to find their state. note that this 4846 * the cgrp->subsys pointer to find their state. note that this
4837 * also takes care of freeing the css_id. 4847 * also takes care of freeing the css_id.
4838 */ 4848 */
4839 ss->css_free(cgroup_dummy_top); 4849 ss->css_free(cgroup_dummy_top->subsys[ss->subsys_id]);
4840 cgroup_dummy_top->subsys[ss->subsys_id] = NULL; 4850 cgroup_dummy_top->subsys[ss->subsys_id] = NULL;
4841 4851
4842 mutex_unlock(&cgroup_mutex); 4852 mutex_unlock(&cgroup_mutex);
@@ -5192,10 +5202,10 @@ void cgroup_exit(struct task_struct *tsk, int run_callbacks)
5192 */ 5202 */
5193 for_each_builtin_subsys(ss, i) { 5203 for_each_builtin_subsys(ss, i) {
5194 if (ss->exit) { 5204 if (ss->exit) {
5195 struct cgroup *old_cgrp = cset->subsys[i]->cgroup; 5205 struct cgroup_subsys_state *old_css = cset->subsys[i];
5196 struct cgroup *cgrp = task_cgroup(tsk, i); 5206 struct cgroup_subsys_state *css = task_css(tsk, i);
5197 5207
5198 ss->exit(cgrp, old_cgrp, tsk); 5208 ss->exit(css, old_css, tsk);
5199 } 5209 }
5200 } 5210 }
5201 } 5211 }
@@ -5529,7 +5539,8 @@ struct cgroup_subsys_state *cgroup_css_from_dir(struct file *f, int id)
5529} 5539}
5530 5540
5531#ifdef CONFIG_CGROUP_DEBUG 5541#ifdef CONFIG_CGROUP_DEBUG
5532static struct cgroup_subsys_state *debug_css_alloc(struct cgroup *cgrp) 5542static struct cgroup_subsys_state *
5543debug_css_alloc(struct cgroup_subsys_state *parent_css)
5533{ 5544{
5534 struct cgroup_subsys_state *css = kzalloc(sizeof(*css), GFP_KERNEL); 5545 struct cgroup_subsys_state *css = kzalloc(sizeof(*css), GFP_KERNEL);
5535 5546
@@ -5539,9 +5550,9 @@ static struct cgroup_subsys_state *debug_css_alloc(struct cgroup *cgrp)
5539 return css; 5550 return css;
5540} 5551}
5541 5552
5542static void debug_css_free(struct cgroup *cgrp) 5553static void debug_css_free(struct cgroup_subsys_state *css)
5543{ 5554{
5544 kfree(cgrp->subsys[debug_subsys_id]); 5555 kfree(css);
5545} 5556}
5546 5557
5547static u64 debug_taskcount_read(struct cgroup *cgrp, struct cftype *cft) 5558static u64 debug_taskcount_read(struct cgroup *cgrp, struct cftype *cft)
diff --git a/kernel/cgroup_freezer.c b/kernel/cgroup_freezer.c
index 657a73cd44c4..f03a85719c3c 100644
--- a/kernel/cgroup_freezer.c
+++ b/kernel/cgroup_freezer.c
@@ -91,7 +91,8 @@ static const char *freezer_state_strs(unsigned int state)
91 91
92struct cgroup_subsys freezer_subsys; 92struct cgroup_subsys freezer_subsys;
93 93
94static struct cgroup_subsys_state *freezer_css_alloc(struct cgroup *cgroup) 94static struct cgroup_subsys_state *
95freezer_css_alloc(struct cgroup_subsys_state *parent_css)
95{ 96{
96 struct freezer *freezer; 97 struct freezer *freezer;
97 98
@@ -104,16 +105,16 @@ static struct cgroup_subsys_state *freezer_css_alloc(struct cgroup *cgroup)
104} 105}
105 106
106/** 107/**
107 * freezer_css_online - commit creation of a freezer cgroup 108 * freezer_css_online - commit creation of a freezer css
108 * @cgroup: cgroup being created 109 * @css: css being created
109 * 110 *
110 * We're committing to creation of @cgroup. Mark it online and inherit 111 * We're committing to creation of @css. Mark it online and inherit
111 * parent's freezing state while holding both parent's and our 112 * parent's freezing state while holding both parent's and our
112 * freezer->lock. 113 * freezer->lock.
113 */ 114 */
114static int freezer_css_online(struct cgroup *cgroup) 115static int freezer_css_online(struct cgroup_subsys_state *css)
115{ 116{
116 struct freezer *freezer = cgroup_freezer(cgroup); 117 struct freezer *freezer = css_freezer(css);
117 struct freezer *parent = parent_freezer(freezer); 118 struct freezer *parent = parent_freezer(freezer);
118 119
119 /* 120 /*
@@ -140,15 +141,15 @@ static int freezer_css_online(struct cgroup *cgroup)
140} 141}
141 142
142/** 143/**
143 * freezer_css_offline - initiate destruction of @cgroup 144 * freezer_css_offline - initiate destruction of a freezer css
144 * @cgroup: cgroup being destroyed 145 * @css: css being destroyed
145 * 146 *
146 * @cgroup is going away. Mark it dead and decrement system_freezing_count 147 * @css is going away. Mark it dead and decrement system_freezing_count if
147 * if it was holding one. 148 * it was holding one.
148 */ 149 */
149static void freezer_css_offline(struct cgroup *cgroup) 150static void freezer_css_offline(struct cgroup_subsys_state *css)
150{ 151{
151 struct freezer *freezer = cgroup_freezer(cgroup); 152 struct freezer *freezer = css_freezer(css);
152 153
153 spin_lock_irq(&freezer->lock); 154 spin_lock_irq(&freezer->lock);
154 155
@@ -160,9 +161,9 @@ static void freezer_css_offline(struct cgroup *cgroup)
160 spin_unlock_irq(&freezer->lock); 161 spin_unlock_irq(&freezer->lock);
161} 162}
162 163
163static void freezer_css_free(struct cgroup *cgroup) 164static void freezer_css_free(struct cgroup_subsys_state *css)
164{ 165{
165 kfree(cgroup_freezer(cgroup)); 166 kfree(css_freezer(css));
166} 167}
167 168
168/* 169/*
@@ -174,25 +175,26 @@ static void freezer_css_free(struct cgroup *cgroup)
174 * @freezer->lock. freezer_attach() makes the new tasks conform to the 175 * @freezer->lock. freezer_attach() makes the new tasks conform to the
175 * current state and all following state changes can see the new tasks. 176 * current state and all following state changes can see the new tasks.
176 */ 177 */
177static void freezer_attach(struct cgroup *new_cgrp, struct cgroup_taskset *tset) 178static void freezer_attach(struct cgroup_subsys_state *new_css,
179 struct cgroup_taskset *tset)
178{ 180{
179 struct freezer *freezer = cgroup_freezer(new_cgrp); 181 struct freezer *freezer = css_freezer(new_css);
180 struct task_struct *task; 182 struct task_struct *task;
181 bool clear_frozen = false; 183 bool clear_frozen = false;
182 184
183 spin_lock_irq(&freezer->lock); 185 spin_lock_irq(&freezer->lock);
184 186
185 /* 187 /*
186 * Make the new tasks conform to the current state of @new_cgrp. 188 * Make the new tasks conform to the current state of @new_css.
187 * For simplicity, when migrating any task to a FROZEN cgroup, we 189 * For simplicity, when migrating any task to a FROZEN cgroup, we
188 * revert it to FREEZING and let update_if_frozen() determine the 190 * revert it to FREEZING and let update_if_frozen() determine the
189 * correct state later. 191 * correct state later.
190 * 192 *
191 * Tasks in @tset are on @new_cgrp but may not conform to its 193 * Tasks in @tset are on @new_css but may not conform to its
192 * current state before executing the following - !frozen tasks may 194 * current state before executing the following - !frozen tasks may
193 * be visible in a FROZEN cgroup and frozen tasks in a THAWED one. 195 * be visible in a FROZEN cgroup and frozen tasks in a THAWED one.
194 */ 196 */
195 cgroup_taskset_for_each(task, new_cgrp, tset) { 197 cgroup_taskset_for_each(task, new_css->cgroup, tset) {
196 if (!(freezer->state & CGROUP_FREEZING)) { 198 if (!(freezer->state & CGROUP_FREEZING)) {
197 __thaw_task(task); 199 __thaw_task(task);
198 } else { 200 } else {
diff --git a/kernel/cpuset.c b/kernel/cpuset.c
index 259a4af37e69..8ce3fdc3dfcc 100644
--- a/kernel/cpuset.c
+++ b/kernel/cpuset.c
@@ -1455,9 +1455,10 @@ static int fmeter_getrate(struct fmeter *fmp)
1455} 1455}
1456 1456
1457/* Called by cgroups to determine if a cpuset is usable; cpuset_mutex held */ 1457/* Called by cgroups to determine if a cpuset is usable; cpuset_mutex held */
1458static int cpuset_can_attach(struct cgroup *cgrp, struct cgroup_taskset *tset) 1458static int cpuset_can_attach(struct cgroup_subsys_state *css,
1459 struct cgroup_taskset *tset)
1459{ 1460{
1460 struct cpuset *cs = cgroup_cs(cgrp); 1461 struct cpuset *cs = css_cs(css);
1461 struct task_struct *task; 1462 struct task_struct *task;
1462 int ret; 1463 int ret;
1463 1464
@@ -1468,11 +1469,11 @@ static int cpuset_can_attach(struct cgroup *cgrp, struct cgroup_taskset *tset)
1468 * flag is set. 1469 * flag is set.
1469 */ 1470 */
1470 ret = -ENOSPC; 1471 ret = -ENOSPC;
1471 if (!cgroup_sane_behavior(cgrp) && 1472 if (!cgroup_sane_behavior(css->cgroup) &&
1472 (cpumask_empty(cs->cpus_allowed) || nodes_empty(cs->mems_allowed))) 1473 (cpumask_empty(cs->cpus_allowed) || nodes_empty(cs->mems_allowed)))
1473 goto out_unlock; 1474 goto out_unlock;
1474 1475
1475 cgroup_taskset_for_each(task, cgrp, tset) { 1476 cgroup_taskset_for_each(task, css->cgroup, tset) {
1476 /* 1477 /*
1477 * Kthreads which disallow setaffinity shouldn't be moved 1478 * Kthreads which disallow setaffinity shouldn't be moved
1478 * to a new cpuset; we don't want to change their cpu 1479 * to a new cpuset; we don't want to change their cpu
@@ -1501,11 +1502,11 @@ out_unlock:
1501 return ret; 1502 return ret;
1502} 1503}
1503 1504
1504static void cpuset_cancel_attach(struct cgroup *cgrp, 1505static void cpuset_cancel_attach(struct cgroup_subsys_state *css,
1505 struct cgroup_taskset *tset) 1506 struct cgroup_taskset *tset)
1506{ 1507{
1507 mutex_lock(&cpuset_mutex); 1508 mutex_lock(&cpuset_mutex);
1508 cgroup_cs(cgrp)->attach_in_progress--; 1509 css_cs(css)->attach_in_progress--;
1509 mutex_unlock(&cpuset_mutex); 1510 mutex_unlock(&cpuset_mutex);
1510} 1511}
1511 1512
@@ -1516,7 +1517,8 @@ static void cpuset_cancel_attach(struct cgroup *cgrp,
1516 */ 1517 */
1517static cpumask_var_t cpus_attach; 1518static cpumask_var_t cpus_attach;
1518 1519
1519static void cpuset_attach(struct cgroup *cgrp, struct cgroup_taskset *tset) 1520static void cpuset_attach(struct cgroup_subsys_state *css,
1521 struct cgroup_taskset *tset)
1520{ 1522{
1521 /* static buf protected by cpuset_mutex */ 1523 /* static buf protected by cpuset_mutex */
1522 static nodemask_t cpuset_attach_nodemask_to; 1524 static nodemask_t cpuset_attach_nodemask_to;
@@ -1524,7 +1526,7 @@ static void cpuset_attach(struct cgroup *cgrp, struct cgroup_taskset *tset)
1524 struct task_struct *task; 1526 struct task_struct *task;
1525 struct task_struct *leader = cgroup_taskset_first(tset); 1527 struct task_struct *leader = cgroup_taskset_first(tset);
1526 struct cgroup *oldcgrp = cgroup_taskset_cur_cgroup(tset); 1528 struct cgroup *oldcgrp = cgroup_taskset_cur_cgroup(tset);
1527 struct cpuset *cs = cgroup_cs(cgrp); 1529 struct cpuset *cs = css_cs(css);
1528 struct cpuset *oldcs = cgroup_cs(oldcgrp); 1530 struct cpuset *oldcs = cgroup_cs(oldcgrp);
1529 struct cpuset *cpus_cs = effective_cpumask_cpuset(cs); 1531 struct cpuset *cpus_cs = effective_cpumask_cpuset(cs);
1530 struct cpuset *mems_cs = effective_nodemask_cpuset(cs); 1532 struct cpuset *mems_cs = effective_nodemask_cpuset(cs);
@@ -1539,7 +1541,7 @@ static void cpuset_attach(struct cgroup *cgrp, struct cgroup_taskset *tset)
1539 1541
1540 guarantee_online_mems(mems_cs, &cpuset_attach_nodemask_to); 1542 guarantee_online_mems(mems_cs, &cpuset_attach_nodemask_to);
1541 1543
1542 cgroup_taskset_for_each(task, cgrp, tset) { 1544 cgroup_taskset_for_each(task, css->cgroup, tset) {
1543 /* 1545 /*
1544 * can_attach beforehand should guarantee that this doesn't 1546 * can_attach beforehand should guarantee that this doesn't
1545 * fail. TODO: have a better way to handle failure here 1547 * fail. TODO: have a better way to handle failure here
@@ -1940,11 +1942,12 @@ static struct cftype files[] = {
1940 * cgrp: control group that the new cpuset will be part of 1942 * cgrp: control group that the new cpuset will be part of
1941 */ 1943 */
1942 1944
1943static struct cgroup_subsys_state *cpuset_css_alloc(struct cgroup *cgrp) 1945static struct cgroup_subsys_state *
1946cpuset_css_alloc(struct cgroup_subsys_state *parent_css)
1944{ 1947{
1945 struct cpuset *cs; 1948 struct cpuset *cs;
1946 1949
1947 if (!cgrp->parent) 1950 if (!parent_css)
1948 return &top_cpuset.css; 1951 return &top_cpuset.css;
1949 1952
1950 cs = kzalloc(sizeof(*cs), GFP_KERNEL); 1953 cs = kzalloc(sizeof(*cs), GFP_KERNEL);
@@ -1964,9 +1967,9 @@ static struct cgroup_subsys_state *cpuset_css_alloc(struct cgroup *cgrp)
1964 return &cs->css; 1967 return &cs->css;
1965} 1968}
1966 1969
1967static int cpuset_css_online(struct cgroup *cgrp) 1970static int cpuset_css_online(struct cgroup_subsys_state *css)
1968{ 1971{
1969 struct cpuset *cs = cgroup_cs(cgrp); 1972 struct cpuset *cs = css_cs(css);
1970 struct cpuset *parent = parent_cs(cs); 1973 struct cpuset *parent = parent_cs(cs);
1971 struct cpuset *tmp_cs; 1974 struct cpuset *tmp_cs;
1972 struct cgroup *pos_cgrp; 1975 struct cgroup *pos_cgrp;
@@ -1984,7 +1987,7 @@ static int cpuset_css_online(struct cgroup *cgrp)
1984 1987
1985 number_of_cpusets++; 1988 number_of_cpusets++;
1986 1989
1987 if (!test_bit(CGRP_CPUSET_CLONE_CHILDREN, &cgrp->flags)) 1990 if (!test_bit(CGRP_CPUSET_CLONE_CHILDREN, &css->cgroup->flags))
1988 goto out_unlock; 1991 goto out_unlock;
1989 1992
1990 /* 1993 /*
@@ -2024,9 +2027,9 @@ out_unlock:
2024 * will call rebuild_sched_domains_locked(). 2027 * will call rebuild_sched_domains_locked().
2025 */ 2028 */
2026 2029
2027static void cpuset_css_offline(struct cgroup *cgrp) 2030static void cpuset_css_offline(struct cgroup_subsys_state *css)
2028{ 2031{
2029 struct cpuset *cs = cgroup_cs(cgrp); 2032 struct cpuset *cs = css_cs(css);
2030 2033
2031 mutex_lock(&cpuset_mutex); 2034 mutex_lock(&cpuset_mutex);
2032 2035
@@ -2039,9 +2042,9 @@ static void cpuset_css_offline(struct cgroup *cgrp)
2039 mutex_unlock(&cpuset_mutex); 2042 mutex_unlock(&cpuset_mutex);
2040} 2043}
2041 2044
2042static void cpuset_css_free(struct cgroup *cgrp) 2045static void cpuset_css_free(struct cgroup_subsys_state *css)
2043{ 2046{
2044 struct cpuset *cs = cgroup_cs(cgrp); 2047 struct cpuset *cs = css_cs(css);
2045 2048
2046 free_cpumask_var(cs->cpus_allowed); 2049 free_cpumask_var(cs->cpus_allowed);
2047 kfree(cs); 2050 kfree(cs);
diff --git a/kernel/events/core.c b/kernel/events/core.c
index 414c61f4d776..9705a0ed1dce 100644
--- a/kernel/events/core.c
+++ b/kernel/events/core.c
@@ -7778,7 +7778,8 @@ unlock:
7778device_initcall(perf_event_sysfs_init); 7778device_initcall(perf_event_sysfs_init);
7779 7779
7780#ifdef CONFIG_CGROUP_PERF 7780#ifdef CONFIG_CGROUP_PERF
7781static struct cgroup_subsys_state *perf_cgroup_css_alloc(struct cgroup *cont) 7781static struct cgroup_subsys_state *
7782perf_cgroup_css_alloc(struct cgroup_subsys_state *parent_css)
7782{ 7783{
7783 struct perf_cgroup *jc; 7784 struct perf_cgroup *jc;
7784 7785
@@ -7795,11 +7796,10 @@ static struct cgroup_subsys_state *perf_cgroup_css_alloc(struct cgroup *cont)
7795 return &jc->css; 7796 return &jc->css;
7796} 7797}
7797 7798
7798static void perf_cgroup_css_free(struct cgroup *cont) 7799static void perf_cgroup_css_free(struct cgroup_subsys_state *css)
7799{ 7800{
7800 struct perf_cgroup *jc; 7801 struct perf_cgroup *jc = container_of(css, struct perf_cgroup, css);
7801 jc = container_of(cgroup_css(cont, perf_subsys_id), 7802
7802 struct perf_cgroup, css);
7803 free_percpu(jc->info); 7803 free_percpu(jc->info);
7804 kfree(jc); 7804 kfree(jc);
7805} 7805}
@@ -7811,15 +7811,17 @@ static int __perf_cgroup_move(void *info)
7811 return 0; 7811 return 0;
7812} 7812}
7813 7813
7814static void perf_cgroup_attach(struct cgroup *cgrp, struct cgroup_taskset *tset) 7814static void perf_cgroup_attach(struct cgroup_subsys_state *css,
7815 struct cgroup_taskset *tset)
7815{ 7816{
7816 struct task_struct *task; 7817 struct task_struct *task;
7817 7818
7818 cgroup_taskset_for_each(task, cgrp, tset) 7819 cgroup_taskset_for_each(task, css->cgroup, tset)
7819 task_function_call(task, __perf_cgroup_move, task); 7820 task_function_call(task, __perf_cgroup_move, task);
7820} 7821}
7821 7822
7822static void perf_cgroup_exit(struct cgroup *cgrp, struct cgroup *old_cgrp, 7823static void perf_cgroup_exit(struct cgroup_subsys_state *css,
7824 struct cgroup_subsys_state *old_css,
7823 struct task_struct *task) 7825 struct task_struct *task)
7824{ 7826{
7825 /* 7827 /*
diff --git a/kernel/sched/core.c b/kernel/sched/core.c
index 7a10742b389a..622b7efc5ade 100644
--- a/kernel/sched/core.c
+++ b/kernel/sched/core.c
@@ -7094,16 +7094,17 @@ static inline struct task_group *cgroup_tg(struct cgroup *cgrp)
7094 return css_tg(cgroup_css(cgrp, cpu_cgroup_subsys_id)); 7094 return css_tg(cgroup_css(cgrp, cpu_cgroup_subsys_id));
7095} 7095}
7096 7096
7097static struct cgroup_subsys_state *cpu_cgroup_css_alloc(struct cgroup *cgrp) 7097static struct cgroup_subsys_state *
7098cpu_cgroup_css_alloc(struct cgroup_subsys_state *parent_css)
7098{ 7099{
7099 struct task_group *tg, *parent; 7100 struct task_group *parent = css_tg(parent_css);
7101 struct task_group *tg;
7100 7102
7101 if (!cgrp->parent) { 7103 if (!parent) {
7102 /* This is early initialization for the top cgroup */ 7104 /* This is early initialization for the top cgroup */
7103 return &root_task_group.css; 7105 return &root_task_group.css;
7104 } 7106 }
7105 7107
7106 parent = cgroup_tg(cgrp->parent);
7107 tg = sched_create_group(parent); 7108 tg = sched_create_group(parent);
7108 if (IS_ERR(tg)) 7109 if (IS_ERR(tg))
7109 return ERR_PTR(-ENOMEM); 7110 return ERR_PTR(-ENOMEM);
@@ -7111,38 +7112,38 @@ static struct cgroup_subsys_state *cpu_cgroup_css_alloc(struct cgroup *cgrp)
7111 return &tg->css; 7112 return &tg->css;
7112} 7113}
7113 7114
7114static int cpu_cgroup_css_online(struct cgroup *cgrp) 7115static int cpu_cgroup_css_online(struct cgroup_subsys_state *css)
7115{ 7116{
7116 struct task_group *tg = cgroup_tg(cgrp); 7117 struct task_group *tg = css_tg(css);
7117 struct task_group *parent = css_tg(css_parent(&tg->css)); 7118 struct task_group *parent = css_tg(css_parent(css));
7118 7119
7119 if (parent) 7120 if (parent)
7120 sched_online_group(tg, parent); 7121 sched_online_group(tg, parent);
7121 return 0; 7122 return 0;
7122} 7123}
7123 7124
7124static void cpu_cgroup_css_free(struct cgroup *cgrp) 7125static void cpu_cgroup_css_free(struct cgroup_subsys_state *css)
7125{ 7126{
7126 struct task_group *tg = cgroup_tg(cgrp); 7127 struct task_group *tg = css_tg(css);
7127 7128
7128 sched_destroy_group(tg); 7129 sched_destroy_group(tg);
7129} 7130}
7130 7131
7131static void cpu_cgroup_css_offline(struct cgroup *cgrp) 7132static void cpu_cgroup_css_offline(struct cgroup_subsys_state *css)
7132{ 7133{
7133 struct task_group *tg = cgroup_tg(cgrp); 7134 struct task_group *tg = css_tg(css);
7134 7135
7135 sched_offline_group(tg); 7136 sched_offline_group(tg);
7136} 7137}
7137 7138
7138static int cpu_cgroup_can_attach(struct cgroup *cgrp, 7139static int cpu_cgroup_can_attach(struct cgroup_subsys_state *css,
7139 struct cgroup_taskset *tset) 7140 struct cgroup_taskset *tset)
7140{ 7141{
7141 struct task_struct *task; 7142 struct task_struct *task;
7142 7143
7143 cgroup_taskset_for_each(task, cgrp, tset) { 7144 cgroup_taskset_for_each(task, css->cgroup, tset) {
7144#ifdef CONFIG_RT_GROUP_SCHED 7145#ifdef CONFIG_RT_GROUP_SCHED
7145 if (!sched_rt_can_attach(cgroup_tg(cgrp), task)) 7146 if (!sched_rt_can_attach(css_tg(css), task))
7146 return -EINVAL; 7147 return -EINVAL;
7147#else 7148#else
7148 /* We don't support RT-tasks being in separate groups */ 7149 /* We don't support RT-tasks being in separate groups */
@@ -7153,18 +7154,18 @@ static int cpu_cgroup_can_attach(struct cgroup *cgrp,
7153 return 0; 7154 return 0;
7154} 7155}
7155 7156
7156static void cpu_cgroup_attach(struct cgroup *cgrp, 7157static void cpu_cgroup_attach(struct cgroup_subsys_state *css,
7157 struct cgroup_taskset *tset) 7158 struct cgroup_taskset *tset)
7158{ 7159{
7159 struct task_struct *task; 7160 struct task_struct *task;
7160 7161
7161 cgroup_taskset_for_each(task, cgrp, tset) 7162 cgroup_taskset_for_each(task, css->cgroup, tset)
7162 sched_move_task(task); 7163 sched_move_task(task);
7163} 7164}
7164 7165
7165static void 7166static void cpu_cgroup_exit(struct cgroup_subsys_state *css,
7166cpu_cgroup_exit(struct cgroup *cgrp, struct cgroup *old_cgrp, 7167 struct cgroup_subsys_state *old_css,
7167 struct task_struct *task) 7168 struct task_struct *task)
7168{ 7169{
7169 /* 7170 /*
7170 * cgroup_exit() is called in the copy_process() failure path. 7171 * cgroup_exit() is called in the copy_process() failure path.
diff --git a/kernel/sched/cpuacct.c b/kernel/sched/cpuacct.c
index f6926a149a71..1b784d9b3630 100644
--- a/kernel/sched/cpuacct.c
+++ b/kernel/sched/cpuacct.c
@@ -62,11 +62,12 @@ static struct cpuacct root_cpuacct = {
62}; 62};
63 63
64/* create a new cpu accounting group */ 64/* create a new cpu accounting group */
65static struct cgroup_subsys_state *cpuacct_css_alloc(struct cgroup *cgrp) 65static struct cgroup_subsys_state *
66cpuacct_css_alloc(struct cgroup_subsys_state *parent_css)
66{ 67{
67 struct cpuacct *ca; 68 struct cpuacct *ca;
68 69
69 if (!cgrp->parent) 70 if (!parent_css)
70 return &root_cpuacct.css; 71 return &root_cpuacct.css;
71 72
72 ca = kzalloc(sizeof(*ca), GFP_KERNEL); 73 ca = kzalloc(sizeof(*ca), GFP_KERNEL);
@@ -92,9 +93,9 @@ out:
92} 93}
93 94
94/* destroy an existing cpu accounting group */ 95/* destroy an existing cpu accounting group */
95static void cpuacct_css_free(struct cgroup *cgrp) 96static void cpuacct_css_free(struct cgroup_subsys_state *css)
96{ 97{
97 struct cpuacct *ca = cgroup_ca(cgrp); 98 struct cpuacct *ca = css_ca(css);
98 99
99 free_percpu(ca->cpustat); 100 free_percpu(ca->cpustat);
100 free_percpu(ca->cpuusage); 101 free_percpu(ca->cpuusage);
diff --git a/mm/hugetlb_cgroup.c b/mm/hugetlb_cgroup.c
index 57ecb5d2513f..e2132435060f 100644
--- a/mm/hugetlb_cgroup.c
+++ b/mm/hugetlb_cgroup.c
@@ -73,19 +73,18 @@ static inline bool hugetlb_cgroup_have_usage(struct hugetlb_cgroup *h_cg)
73 return false; 73 return false;
74} 74}
75 75
76static struct cgroup_subsys_state *hugetlb_cgroup_css_alloc(struct cgroup *cgroup) 76static struct cgroup_subsys_state *
77hugetlb_cgroup_css_alloc(struct cgroup_subsys_state *parent_css)
77{ 78{
79 struct hugetlb_cgroup *parent_h_cgroup = hugetlb_cgroup_from_css(parent_css);
80 struct hugetlb_cgroup *h_cgroup;
78 int idx; 81 int idx;
79 struct cgroup *parent_cgroup;
80 struct hugetlb_cgroup *h_cgroup, *parent_h_cgroup;
81 82
82 h_cgroup = kzalloc(sizeof(*h_cgroup), GFP_KERNEL); 83 h_cgroup = kzalloc(sizeof(*h_cgroup), GFP_KERNEL);
83 if (!h_cgroup) 84 if (!h_cgroup)
84 return ERR_PTR(-ENOMEM); 85 return ERR_PTR(-ENOMEM);
85 86
86 parent_cgroup = cgroup->parent; 87 if (parent_h_cgroup) {
87 if (parent_cgroup) {
88 parent_h_cgroup = hugetlb_cgroup_from_cgroup(parent_cgroup);
89 for (idx = 0; idx < HUGE_MAX_HSTATE; idx++) 88 for (idx = 0; idx < HUGE_MAX_HSTATE; idx++)
90 res_counter_init(&h_cgroup->hugepage[idx], 89 res_counter_init(&h_cgroup->hugepage[idx],
91 &parent_h_cgroup->hugepage[idx]); 90 &parent_h_cgroup->hugepage[idx]);
@@ -97,11 +96,11 @@ static struct cgroup_subsys_state *hugetlb_cgroup_css_alloc(struct cgroup *cgrou
97 return &h_cgroup->css; 96 return &h_cgroup->css;
98} 97}
99 98
100static void hugetlb_cgroup_css_free(struct cgroup *cgroup) 99static void hugetlb_cgroup_css_free(struct cgroup_subsys_state *css)
101{ 100{
102 struct hugetlb_cgroup *h_cgroup; 101 struct hugetlb_cgroup *h_cgroup;
103 102
104 h_cgroup = hugetlb_cgroup_from_cgroup(cgroup); 103 h_cgroup = hugetlb_cgroup_from_css(css);
105 kfree(h_cgroup); 104 kfree(h_cgroup);
106} 105}
107 106
@@ -150,9 +149,9 @@ out:
150 * Force the hugetlb cgroup to empty the hugetlb resources by moving them to 149 * Force the hugetlb cgroup to empty the hugetlb resources by moving them to
151 * the parent cgroup. 150 * the parent cgroup.
152 */ 151 */
153static void hugetlb_cgroup_css_offline(struct cgroup *cgroup) 152static void hugetlb_cgroup_css_offline(struct cgroup_subsys_state *css)
154{ 153{
155 struct hugetlb_cgroup *h_cg = hugetlb_cgroup_from_cgroup(cgroup); 154 struct hugetlb_cgroup *h_cg = hugetlb_cgroup_from_css(css);
156 struct hstate *h; 155 struct hstate *h;
157 struct page *page; 156 struct page *page;
158 int idx = 0; 157 int idx = 0;
diff --git a/mm/memcontrol.c b/mm/memcontrol.c
index 69b3e520f921..32cca0f0af0d 100644
--- a/mm/memcontrol.c
+++ b/mm/memcontrol.c
@@ -6211,7 +6211,7 @@ static void __init mem_cgroup_soft_limit_tree_init(void)
6211} 6211}
6212 6212
6213static struct cgroup_subsys_state * __ref 6213static struct cgroup_subsys_state * __ref
6214mem_cgroup_css_alloc(struct cgroup *cont) 6214mem_cgroup_css_alloc(struct cgroup_subsys_state *parent_css)
6215{ 6215{
6216 struct mem_cgroup *memcg; 6216 struct mem_cgroup *memcg;
6217 long error = -ENOMEM; 6217 long error = -ENOMEM;
@@ -6226,7 +6226,7 @@ mem_cgroup_css_alloc(struct cgroup *cont)
6226 goto free_out; 6226 goto free_out;
6227 6227
6228 /* root ? */ 6228 /* root ? */
6229 if (cont->parent == NULL) { 6229 if (parent_css == NULL) {
6230 root_mem_cgroup = memcg; 6230 root_mem_cgroup = memcg;
6231 res_counter_init(&memcg->res, NULL); 6231 res_counter_init(&memcg->res, NULL);
6232 res_counter_init(&memcg->memsw, NULL); 6232 res_counter_init(&memcg->memsw, NULL);
@@ -6248,10 +6248,10 @@ free_out:
6248} 6248}
6249 6249
6250static int 6250static int
6251mem_cgroup_css_online(struct cgroup *cont) 6251mem_cgroup_css_online(struct cgroup_subsys_state *css)
6252{ 6252{
6253 struct mem_cgroup *memcg = mem_cgroup_from_cont(cont); 6253 struct mem_cgroup *memcg = mem_cgroup_from_css(css);
6254 struct mem_cgroup *parent = mem_cgroup_from_css(css_parent(&memcg->css)); 6254 struct mem_cgroup *parent = mem_cgroup_from_css(css_parent(css));
6255 int error = 0; 6255 int error = 0;
6256 6256
6257 if (!parent) 6257 if (!parent)
@@ -6308,9 +6308,9 @@ static void mem_cgroup_invalidate_reclaim_iterators(struct mem_cgroup *memcg)
6308 mem_cgroup_iter_invalidate(root_mem_cgroup); 6308 mem_cgroup_iter_invalidate(root_mem_cgroup);
6309} 6309}
6310 6310
6311static void mem_cgroup_css_offline(struct cgroup *cont) 6311static void mem_cgroup_css_offline(struct cgroup_subsys_state *css)
6312{ 6312{
6313 struct mem_cgroup *memcg = mem_cgroup_from_cont(cont); 6313 struct mem_cgroup *memcg = mem_cgroup_from_css(css);
6314 6314
6315 kmem_cgroup_css_offline(memcg); 6315 kmem_cgroup_css_offline(memcg);
6316 6316
@@ -6319,9 +6319,9 @@ static void mem_cgroup_css_offline(struct cgroup *cont)
6319 mem_cgroup_destroy_all_caches(memcg); 6319 mem_cgroup_destroy_all_caches(memcg);
6320} 6320}
6321 6321
6322static void mem_cgroup_css_free(struct cgroup *cont) 6322static void mem_cgroup_css_free(struct cgroup_subsys_state *css)
6323{ 6323{
6324 struct mem_cgroup *memcg = mem_cgroup_from_cont(cont); 6324 struct mem_cgroup *memcg = mem_cgroup_from_css(css);
6325 6325
6326 memcg_destroy_kmem(memcg); 6326 memcg_destroy_kmem(memcg);
6327 __mem_cgroup_free(memcg); 6327 __mem_cgroup_free(memcg);
@@ -6691,12 +6691,12 @@ static void mem_cgroup_clear_mc(void)
6691 mem_cgroup_end_move(from); 6691 mem_cgroup_end_move(from);
6692} 6692}
6693 6693
6694static int mem_cgroup_can_attach(struct cgroup *cgroup, 6694static int mem_cgroup_can_attach(struct cgroup_subsys_state *css,
6695 struct cgroup_taskset *tset) 6695 struct cgroup_taskset *tset)
6696{ 6696{
6697 struct task_struct *p = cgroup_taskset_first(tset); 6697 struct task_struct *p = cgroup_taskset_first(tset);
6698 int ret = 0; 6698 int ret = 0;
6699 struct mem_cgroup *memcg = mem_cgroup_from_cont(cgroup); 6699 struct mem_cgroup *memcg = mem_cgroup_from_css(css);
6700 unsigned long move_charge_at_immigrate; 6700 unsigned long move_charge_at_immigrate;
6701 6701
6702 /* 6702 /*
@@ -6738,7 +6738,7 @@ static int mem_cgroup_can_attach(struct cgroup *cgroup,
6738 return ret; 6738 return ret;
6739} 6739}
6740 6740
6741static void mem_cgroup_cancel_attach(struct cgroup *cgroup, 6741static void mem_cgroup_cancel_attach(struct cgroup_subsys_state *css,
6742 struct cgroup_taskset *tset) 6742 struct cgroup_taskset *tset)
6743{ 6743{
6744 mem_cgroup_clear_mc(); 6744 mem_cgroup_clear_mc();
@@ -6886,7 +6886,7 @@ retry:
6886 up_read(&mm->mmap_sem); 6886 up_read(&mm->mmap_sem);
6887} 6887}
6888 6888
6889static void mem_cgroup_move_task(struct cgroup *cont, 6889static void mem_cgroup_move_task(struct cgroup_subsys_state *css,
6890 struct cgroup_taskset *tset) 6890 struct cgroup_taskset *tset)
6891{ 6891{
6892 struct task_struct *p = cgroup_taskset_first(tset); 6892 struct task_struct *p = cgroup_taskset_first(tset);
@@ -6901,16 +6901,16 @@ static void mem_cgroup_move_task(struct cgroup *cont,
6901 mem_cgroup_clear_mc(); 6901 mem_cgroup_clear_mc();
6902} 6902}
6903#else /* !CONFIG_MMU */ 6903#else /* !CONFIG_MMU */
6904static int mem_cgroup_can_attach(struct cgroup *cgroup, 6904static int mem_cgroup_can_attach(struct cgroup_subsys_state *css,
6905 struct cgroup_taskset *tset) 6905 struct cgroup_taskset *tset)
6906{ 6906{
6907 return 0; 6907 return 0;
6908} 6908}
6909static void mem_cgroup_cancel_attach(struct cgroup *cgroup, 6909static void mem_cgroup_cancel_attach(struct cgroup_subsys_state *css,
6910 struct cgroup_taskset *tset) 6910 struct cgroup_taskset *tset)
6911{ 6911{
6912} 6912}
6913static void mem_cgroup_move_task(struct cgroup *cont, 6913static void mem_cgroup_move_task(struct cgroup_subsys_state *css,
6914 struct cgroup_taskset *tset) 6914 struct cgroup_taskset *tset)
6915{ 6915{
6916} 6916}
@@ -6920,15 +6920,15 @@ static void mem_cgroup_move_task(struct cgroup *cont,
6920 * Cgroup retains root cgroups across [un]mount cycles making it necessary 6920 * Cgroup retains root cgroups across [un]mount cycles making it necessary
6921 * to verify sane_behavior flag on each mount attempt. 6921 * to verify sane_behavior flag on each mount attempt.
6922 */ 6922 */
6923static void mem_cgroup_bind(struct cgroup *root) 6923static void mem_cgroup_bind(struct cgroup_subsys_state *root_css)
6924{ 6924{
6925 /* 6925 /*
6926 * use_hierarchy is forced with sane_behavior. cgroup core 6926 * use_hierarchy is forced with sane_behavior. cgroup core
6927 * guarantees that @root doesn't have any children, so turning it 6927 * guarantees that @root doesn't have any children, so turning it
6928 * on for the root memcg is enough. 6928 * on for the root memcg is enough.
6929 */ 6929 */
6930 if (cgroup_sane_behavior(root)) 6930 if (cgroup_sane_behavior(root_css->cgroup))
6931 mem_cgroup_from_cont(root)->use_hierarchy = true; 6931 mem_cgroup_from_css(root_css)->use_hierarchy = true;
6932} 6932}
6933 6933
6934struct cgroup_subsys mem_cgroup_subsys = { 6934struct cgroup_subsys mem_cgroup_subsys = {
diff --git a/net/core/netprio_cgroup.c b/net/core/netprio_cgroup.c
index 5dfac8886e12..8d095b4c2f6f 100644
--- a/net/core/netprio_cgroup.c
+++ b/net/core/netprio_cgroup.c
@@ -126,7 +126,8 @@ static int netprio_set_prio(struct cgroup_subsys_state *css,
126 return 0; 126 return 0;
127} 127}
128 128
129static struct cgroup_subsys_state *cgrp_css_alloc(struct cgroup *cgrp) 129static struct cgroup_subsys_state *
130cgrp_css_alloc(struct cgroup_subsys_state *parent_css)
130{ 131{
131 struct cgroup_subsys_state *css; 132 struct cgroup_subsys_state *css;
132 133
@@ -137,16 +138,14 @@ static struct cgroup_subsys_state *cgrp_css_alloc(struct cgroup *cgrp)
137 return css; 138 return css;
138} 139}
139 140
140static int cgrp_css_online(struct cgroup *cgrp) 141static int cgrp_css_online(struct cgroup_subsys_state *css)
141{ 142{
142 struct cgroup_subsys_state *css = cgroup_css(cgrp, net_prio_subsys_id); 143 struct cgroup_subsys_state *parent_css = css_parent(css);
143 struct cgroup_subsys_state *parent_css;
144 struct net_device *dev; 144 struct net_device *dev;
145 int ret = 0; 145 int ret = 0;
146 146
147 if (!cgrp->parent) 147 if (!parent_css)
148 return 0; 148 return 0;
149 parent_css = cgroup_css(cgrp->parent, net_prio_subsys_id);
150 149
151 rtnl_lock(); 150 rtnl_lock();
152 /* 151 /*
@@ -164,9 +163,9 @@ static int cgrp_css_online(struct cgroup *cgrp)
164 return ret; 163 return ret;
165} 164}
166 165
167static void cgrp_css_free(struct cgroup *cgrp) 166static void cgrp_css_free(struct cgroup_subsys_state *css)
168{ 167{
169 kfree(cgroup_css(cgrp, net_prio_subsys_id)); 168 kfree(css);
170} 169}
171 170
172static u64 read_prioidx(struct cgroup *cgrp, struct cftype *cft) 171static u64 read_prioidx(struct cgroup *cgrp, struct cftype *cft)
@@ -221,12 +220,13 @@ static int update_netprio(const void *v, struct file *file, unsigned n)
221 return 0; 220 return 0;
222} 221}
223 222
224static void net_prio_attach(struct cgroup *cgrp, struct cgroup_taskset *tset) 223static void net_prio_attach(struct cgroup_subsys_state *css,
224 struct cgroup_taskset *tset)
225{ 225{
226 struct task_struct *p; 226 struct task_struct *p;
227 void *v; 227 void *v;
228 228
229 cgroup_taskset_for_each(p, cgrp, tset) { 229 cgroup_taskset_for_each(p, css->cgroup, tset) {
230 task_lock(p); 230 task_lock(p);
231 v = (void *)(unsigned long)task_netprioidx(p); 231 v = (void *)(unsigned long)task_netprioidx(p);
232 iterate_fd(p->files, 0, update_netprio, v); 232 iterate_fd(p->files, 0, update_netprio, v);
diff --git a/net/sched/cls_cgroup.c b/net/sched/cls_cgroup.c
index 9e6b75e5efce..dc3983835893 100644
--- a/net/sched/cls_cgroup.c
+++ b/net/sched/cls_cgroup.c
@@ -38,7 +38,8 @@ static inline struct cgroup_cls_state *task_cls_state(struct task_struct *p)
38 return css_cls_state(task_css(p, net_cls_subsys_id)); 38 return css_cls_state(task_css(p, net_cls_subsys_id));
39} 39}
40 40
41static struct cgroup_subsys_state *cgrp_css_alloc(struct cgroup *cgrp) 41static struct cgroup_subsys_state *
42cgrp_css_alloc(struct cgroup_subsys_state *parent_css)
42{ 43{
43 struct cgroup_cls_state *cs; 44 struct cgroup_cls_state *cs;
44 45
@@ -48,19 +49,19 @@ static struct cgroup_subsys_state *cgrp_css_alloc(struct cgroup *cgrp)
48 return &cs->css; 49 return &cs->css;
49} 50}
50 51
51static int cgrp_css_online(struct cgroup *cgrp) 52static int cgrp_css_online(struct cgroup_subsys_state *css)
52{ 53{
53 struct cgroup_cls_state *cs = cgrp_cls_state(cgrp); 54 struct cgroup_cls_state *cs = css_cls_state(css);
54 struct cgroup_cls_state *parent = css_cls_state(css_parent(&cs->css)); 55 struct cgroup_cls_state *parent = css_cls_state(css_parent(css));
55 56
56 if (parent) 57 if (parent)
57 cs->classid = parent->classid; 58 cs->classid = parent->classid;
58 return 0; 59 return 0;
59} 60}
60 61
61static void cgrp_css_free(struct cgroup *cgrp) 62static void cgrp_css_free(struct cgroup_subsys_state *css)
62{ 63{
63 kfree(cgrp_cls_state(cgrp)); 64 kfree(css_cls_state(css));
64} 65}
65 66
66static int update_classid(const void *v, struct file *file, unsigned n) 67static int update_classid(const void *v, struct file *file, unsigned n)
@@ -72,12 +73,13 @@ static int update_classid(const void *v, struct file *file, unsigned n)
72 return 0; 73 return 0;
73} 74}
74 75
75static void cgrp_attach(struct cgroup *cgrp, struct cgroup_taskset *tset) 76static void cgrp_attach(struct cgroup_subsys_state *css,
77 struct cgroup_taskset *tset)
76{ 78{
77 struct task_struct *p; 79 struct task_struct *p;
78 void *v; 80 void *v;
79 81
80 cgroup_taskset_for_each(p, cgrp, tset) { 82 cgroup_taskset_for_each(p, css->cgroup, tset) {
81 task_lock(p); 83 task_lock(p);
82 v = (void *)(unsigned long)task_cls_classid(p); 84 v = (void *)(unsigned long)task_cls_classid(p);
83 iterate_fd(p->files, 0, update_classid, v); 85 iterate_fd(p->files, 0, update_classid, v);
diff --git a/security/device_cgroup.c b/security/device_cgroup.c
index 635a49db005d..7293ac49ba7b 100644
--- a/security/device_cgroup.c
+++ b/security/device_cgroup.c
@@ -68,7 +68,7 @@ static inline struct dev_cgroup *task_devcgroup(struct task_struct *task)
68 68
69struct cgroup_subsys devices_subsys; 69struct cgroup_subsys devices_subsys;
70 70
71static int devcgroup_can_attach(struct cgroup *new_cgrp, 71static int devcgroup_can_attach(struct cgroup_subsys_state *new_css,
72 struct cgroup_taskset *set) 72 struct cgroup_taskset *set)
73{ 73{
74 struct task_struct *task = cgroup_taskset_first(set); 74 struct task_struct *task = cgroup_taskset_first(set);
@@ -193,13 +193,13 @@ static inline bool is_devcg_online(const struct dev_cgroup *devcg)
193/** 193/**
194 * devcgroup_online - initializes devcgroup's behavior and exceptions based on 194 * devcgroup_online - initializes devcgroup's behavior and exceptions based on
195 * parent's 195 * parent's
196 * @cgroup: cgroup getting online 196 * @css: css getting online
197 * returns 0 in case of success, error code otherwise 197 * returns 0 in case of success, error code otherwise
198 */ 198 */
199static int devcgroup_online(struct cgroup *cgroup) 199static int devcgroup_online(struct cgroup_subsys_state *css)
200{ 200{
201 struct dev_cgroup *dev_cgroup = cgroup_to_devcgroup(cgroup); 201 struct dev_cgroup *dev_cgroup = css_to_devcgroup(css);
202 struct dev_cgroup *parent_dev_cgroup = css_to_devcgroup(css_parent(&dev_cgroup->css)); 202 struct dev_cgroup *parent_dev_cgroup = css_to_devcgroup(css_parent(css));
203 int ret = 0; 203 int ret = 0;
204 204
205 mutex_lock(&devcgroup_mutex); 205 mutex_lock(&devcgroup_mutex);
@@ -217,9 +217,9 @@ static int devcgroup_online(struct cgroup *cgroup)
217 return ret; 217 return ret;
218} 218}
219 219
220static void devcgroup_offline(struct cgroup *cgroup) 220static void devcgroup_offline(struct cgroup_subsys_state *css)
221{ 221{
222 struct dev_cgroup *dev_cgroup = cgroup_to_devcgroup(cgroup); 222 struct dev_cgroup *dev_cgroup = css_to_devcgroup(css);
223 223
224 mutex_lock(&devcgroup_mutex); 224 mutex_lock(&devcgroup_mutex);
225 dev_cgroup->behavior = DEVCG_DEFAULT_NONE; 225 dev_cgroup->behavior = DEVCG_DEFAULT_NONE;
@@ -229,7 +229,8 @@ static void devcgroup_offline(struct cgroup *cgroup)
229/* 229/*
230 * called from kernel/cgroup.c with cgroup_lock() held. 230 * called from kernel/cgroup.c with cgroup_lock() held.
231 */ 231 */
232static struct cgroup_subsys_state *devcgroup_css_alloc(struct cgroup *cgroup) 232static struct cgroup_subsys_state *
233devcgroup_css_alloc(struct cgroup_subsys_state *parent_css)
233{ 234{
234 struct dev_cgroup *dev_cgroup; 235 struct dev_cgroup *dev_cgroup;
235 236
@@ -242,11 +243,10 @@ static struct cgroup_subsys_state *devcgroup_css_alloc(struct cgroup *cgroup)
242 return &dev_cgroup->css; 243 return &dev_cgroup->css;
243} 244}
244 245
245static void devcgroup_css_free(struct cgroup *cgroup) 246static void devcgroup_css_free(struct cgroup_subsys_state *css)
246{ 247{
247 struct dev_cgroup *dev_cgroup; 248 struct dev_cgroup *dev_cgroup = css_to_devcgroup(css);
248 249
249 dev_cgroup = cgroup_to_devcgroup(cgroup);
250 __dev_exception_clean(dev_cgroup); 250 __dev_exception_clean(dev_cgroup);
251 kfree(dev_cgroup); 251 kfree(dev_cgroup);
252} 252}