aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--Documentation/cgroups/cgroups.txt49
-rw-r--r--block/blk-cgroup.c14
-rw-r--r--include/linux/cgroup.h35
-rw-r--r--kernel/cgroup.c51
-rw-r--r--kernel/cgroup_freezer.c20
-rw-r--r--kernel/cpuset.c10
-rw-r--r--kernel/events/core.c8
-rw-r--r--kernel/sched/core.c16
-rw-r--r--mm/hugetlb_cgroup.c14
-rw-r--r--mm/memcontrol.c12
-rw-r--r--net/core/netprio_cgroup.c8
-rw-r--r--net/sched/cls_cgroup.c8
-rw-r--r--security/device_cgroup.c8
13 files changed, 132 insertions, 121 deletions
diff --git a/Documentation/cgroups/cgroups.txt b/Documentation/cgroups/cgroups.txt
index 9e04196c4d78..b06eea217403 100644
--- a/Documentation/cgroups/cgroups.txt
+++ b/Documentation/cgroups/cgroups.txt
@@ -553,16 +553,16 @@ call to cgroup_unload_subsys(). It should also set its_subsys.module =
553THIS_MODULE in its .c file. 553THIS_MODULE in its .c file.
554 554
555Each subsystem may export the following methods. The only mandatory 555Each subsystem may export the following methods. The only mandatory
556methods are create/destroy. Any others that are null are presumed to 556methods are css_alloc/free. Any others that are null are presumed to
557be successful no-ops. 557be successful no-ops.
558 558
559struct cgroup_subsys_state *create(struct cgroup *cgrp) 559struct cgroup_subsys_state *css_alloc(struct cgroup *cgrp)
560(cgroup_mutex held by caller) 560(cgroup_mutex held by caller)
561 561
562Called to create a subsystem state object for a cgroup. The 562Called to allocate a subsystem state object for a cgroup. The
563subsystem should allocate its subsystem state object for the passed 563subsystem should allocate its subsystem state object for the passed
564cgroup, returning a pointer to the new object on success or a 564cgroup, returning a pointer to the new object on success or a
565negative error code. On success, the subsystem pointer should point to 565ERR_PTR() value. On success, the subsystem pointer should point to
566a structure of type cgroup_subsys_state (typically embedded in a 566a structure of type cgroup_subsys_state (typically embedded in a
567larger subsystem-specific object), which will be initialized by the 567larger subsystem-specific object), which will be initialized by the
568cgroup system. Note that this will be called at initialization to 568cgroup system. Note that this will be called at initialization to
@@ -571,24 +571,33 @@ identified by the passed cgroup object having a NULL parent (since
571it's the root of the hierarchy) and may be an appropriate place for 571it's the root of the hierarchy) and may be an appropriate place for
572initialization code. 572initialization code.
573 573
574void destroy(struct cgroup *cgrp) 574int css_online(struct cgroup *cgrp)
575(cgroup_mutex held by caller) 575(cgroup_mutex held by caller)
576 576
577The cgroup system is about to destroy the passed cgroup; the subsystem 577Called after @cgrp successfully completed all allocations and made
578should do any necessary cleanup and free its subsystem state 578visible to cgroup_for_each_child/descendant_*() iterators. The
579object. By the time this method is called, the cgroup has already been 579subsystem may choose to fail creation by returning -errno. This
580unlinked from the file system and from the child list of its parent; 580callback can be used to implement reliable state sharing and
581cgroup->parent is still valid. (Note - can also be called for a 581propagation along the hierarchy. See the comment on
582newly-created cgroup if an error occurs after this subsystem's 582cgroup_for_each_descendant_pre() for details.
583create() method has been called for the new cgroup). 583
584 584void css_offline(struct cgroup *cgrp);
585int pre_destroy(struct cgroup *cgrp); 585
586 586This is the counterpart of css_online() and called iff css_online()
587Called before checking the reference count on each subsystem. This may 587has succeeded on @cgrp. This signifies the beginning of the end of
588be useful for subsystems which have some extra references even if 588@cgrp. @cgrp is being removed and the subsystem should start dropping
589there are not tasks in the cgroup. If pre_destroy() returns error code, 589all references it's holding on @cgrp. When all references are dropped,
590rmdir() will fail with it. From this behavior, pre_destroy() can be 590cgroup removal will proceed to the next step - css_free(). After this
591called multiple times against a cgroup. 591callback, @cgrp should be considered dead to the subsystem.
592
593void css_free(struct cgroup *cgrp)
594(cgroup_mutex held by caller)
595
596The cgroup system is about to free @cgrp; the subsystem should free
597its subsystem state object. By the time this method is called, @cgrp
598is completely unused; @cgrp->parent is still valid. (Note - can also
599be called for a newly-created cgroup if an error occurs after this
600subsystem's create() method has been called for the new cgroup).
592 601
593int can_attach(struct cgroup *cgrp, struct cgroup_taskset *tset) 602int can_attach(struct cgroup *cgrp, struct cgroup_taskset *tset)
594(cgroup_mutex held by caller) 603(cgroup_mutex held by caller)
diff --git a/block/blk-cgroup.c b/block/blk-cgroup.c
index 3dc60fc441cb..3f6d39d23bb6 100644
--- a/block/blk-cgroup.c
+++ b/block/blk-cgroup.c
@@ -600,7 +600,7 @@ struct cftype blkcg_files[] = {
600}; 600};
601 601
602/** 602/**
603 * blkcg_pre_destroy - cgroup pre_destroy callback 603 * blkcg_css_offline - cgroup css_offline callback
604 * @cgroup: cgroup of interest 604 * @cgroup: cgroup of interest
605 * 605 *
606 * This function is called when @cgroup is about to go away and responsible 606 * This function is called when @cgroup is about to go away and responsible
@@ -610,7 +610,7 @@ struct cftype blkcg_files[] = {
610 * 610 *
611 * This is the blkcg counterpart of ioc_release_fn(). 611 * This is the blkcg counterpart of ioc_release_fn().
612 */ 612 */
613static void blkcg_pre_destroy(struct cgroup *cgroup) 613static void blkcg_css_offline(struct cgroup *cgroup)
614{ 614{
615 struct blkcg *blkcg = cgroup_to_blkcg(cgroup); 615 struct blkcg *blkcg = cgroup_to_blkcg(cgroup);
616 616
@@ -634,7 +634,7 @@ static void blkcg_pre_destroy(struct cgroup *cgroup)
634 spin_unlock_irq(&blkcg->lock); 634 spin_unlock_irq(&blkcg->lock);
635} 635}
636 636
637static void blkcg_destroy(struct cgroup *cgroup) 637static void blkcg_css_free(struct cgroup *cgroup)
638{ 638{
639 struct blkcg *blkcg = cgroup_to_blkcg(cgroup); 639 struct blkcg *blkcg = cgroup_to_blkcg(cgroup);
640 640
@@ -642,7 +642,7 @@ static void blkcg_destroy(struct cgroup *cgroup)
642 kfree(blkcg); 642 kfree(blkcg);
643} 643}
644 644
645static struct cgroup_subsys_state *blkcg_create(struct cgroup *cgroup) 645static struct cgroup_subsys_state *blkcg_css_alloc(struct cgroup *cgroup)
646{ 646{
647 static atomic64_t id_seq = ATOMIC64_INIT(0); 647 static atomic64_t id_seq = ATOMIC64_INIT(0);
648 struct blkcg *blkcg; 648 struct blkcg *blkcg;
@@ -739,10 +739,10 @@ static int blkcg_can_attach(struct cgroup *cgrp, struct cgroup_taskset *tset)
739 739
740struct cgroup_subsys blkio_subsys = { 740struct cgroup_subsys blkio_subsys = {
741 .name = "blkio", 741 .name = "blkio",
742 .create = blkcg_create, 742 .css_alloc = blkcg_css_alloc,
743 .css_offline = blkcg_css_offline,
744 .css_free = blkcg_css_free,
743 .can_attach = blkcg_can_attach, 745 .can_attach = blkcg_can_attach,
744 .pre_destroy = blkcg_pre_destroy,
745 .destroy = blkcg_destroy,
746 .subsys_id = blkio_subsys_id, 746 .subsys_id = blkio_subsys_id,
747 .base_cftypes = blkcg_files, 747 .base_cftypes = blkcg_files,
748 .module = THIS_MODULE, 748 .module = THIS_MODULE,
diff --git a/include/linux/cgroup.h b/include/linux/cgroup.h
index 03d8a92786da..7a2189ca8327 100644
--- a/include/linux/cgroup.h
+++ b/include/linux/cgroup.h
@@ -82,7 +82,7 @@ struct cgroup_subsys_state {
82/* bits in struct cgroup_subsys_state flags field */ 82/* bits in struct cgroup_subsys_state flags field */
83enum { 83enum {
84 CSS_ROOT = (1 << 0), /* this CSS is the root of the subsystem */ 84 CSS_ROOT = (1 << 0), /* this CSS is the root of the subsystem */
85 CSS_ONLINE = (1 << 1), /* between ->post_create() and ->pre_destroy() */ 85 CSS_ONLINE = (1 << 1), /* between ->css_online() and ->css_offline() */
86}; 86};
87 87
88/* Caller must verify that the css is not for root cgroup */ 88/* Caller must verify that the css is not for root cgroup */
@@ -439,10 +439,11 @@ int cgroup_taskset_size(struct cgroup_taskset *tset);
439 */ 439 */
440 440
441struct cgroup_subsys { 441struct cgroup_subsys {
442 struct cgroup_subsys_state *(*create)(struct cgroup *cgrp); 442 struct cgroup_subsys_state *(*css_alloc)(struct cgroup *cgrp);
443 int (*post_create)(struct cgroup *cgrp); 443 int (*css_online)(struct cgroup *cgrp);
444 void (*pre_destroy)(struct cgroup *cgrp); 444 void (*css_offline)(struct cgroup *cgrp);
445 void (*destroy)(struct cgroup *cgrp); 445 void (*css_free)(struct cgroup *cgrp);
446
446 int (*can_attach)(struct cgroup *cgrp, struct cgroup_taskset *tset); 447 int (*can_attach)(struct cgroup *cgrp, struct cgroup_taskset *tset);
447 void (*cancel_attach)(struct cgroup *cgrp, struct cgroup_taskset *tset); 448 void (*cancel_attach)(struct cgroup *cgrp, struct cgroup_taskset *tset);
448 void (*attach)(struct cgroup *cgrp, struct cgroup_taskset *tset); 449 void (*attach)(struct cgroup *cgrp, struct cgroup_taskset *tset);
@@ -541,13 +542,13 @@ static inline struct cgroup* task_cgroup(struct task_struct *task,
541 * @cgroup: cgroup whose children to walk 542 * @cgroup: cgroup whose children to walk
542 * 543 *
543 * Walk @cgroup's children. Must be called under rcu_read_lock(). A child 544 * Walk @cgroup's children. Must be called under rcu_read_lock(). A child
544 * cgroup which hasn't finished ->post_create() or already has finished 545 * cgroup which hasn't finished ->css_online() or already has finished
545 * ->pre_destroy() may show up during traversal and it's each subsystem's 546 * ->css_offline() may show up during traversal and it's each subsystem's
546 * responsibility to verify that each @pos is alive. 547 * responsibility to verify that each @pos is alive.
547 * 548 *
548 * If a subsystem synchronizes against the parent in its ->post_create() 549 * If a subsystem synchronizes against the parent in its ->css_online() and
549 * and before starting iterating, a cgroup which finished ->post_create() 550 * before starting iterating, a cgroup which finished ->css_online() is
550 * is guaranteed to be visible in the future iterations. 551 * guaranteed to be visible in the future iterations.
551 */ 552 */
552#define cgroup_for_each_child(pos, cgroup) \ 553#define cgroup_for_each_child(pos, cgroup) \
553 list_for_each_entry_rcu(pos, &(cgroup)->children, sibling) 554 list_for_each_entry_rcu(pos, &(cgroup)->children, sibling)
@@ -561,19 +562,19 @@ struct cgroup *cgroup_next_descendant_pre(struct cgroup *pos,
561 * @cgroup: cgroup whose descendants to walk 562 * @cgroup: cgroup whose descendants to walk
562 * 563 *
563 * Walk @cgroup's descendants. Must be called under rcu_read_lock(). A 564 * Walk @cgroup's descendants. Must be called under rcu_read_lock(). A
564 * descendant cgroup which hasn't finished ->post_create() or already has 565 * descendant cgroup which hasn't finished ->css_online() or already has
565 * finished ->pre_destroy() may show up during traversal and it's each 566 * finished ->css_offline() may show up during traversal and it's each
566 * subsystem's responsibility to verify that each @pos is alive. 567 * subsystem's responsibility to verify that each @pos is alive.
567 * 568 *
568 * If a subsystem synchronizes against the parent in its ->post_create() 569 * If a subsystem synchronizes against the parent in its ->css_online() and
569 * and before starting iterating, and synchronizes against @pos on each 570 * before starting iterating, and synchronizes against @pos on each
570 * iteration, any descendant cgroup which finished ->post_create() is 571 * iteration, any descendant cgroup which finished ->css_offline() is
571 * guaranteed to be visible in the future iterations. 572 * guaranteed to be visible in the future iterations.
572 * 573 *
573 * In other words, the following guarantees that a descendant can't escape 574 * In other words, the following guarantees that a descendant can't escape
574 * state updates of its ancestors. 575 * state updates of its ancestors.
575 * 576 *
576 * my_post_create(@cgrp) 577 * my_online(@cgrp)
577 * { 578 * {
578 * Lock @cgrp->parent and @cgrp; 579 * Lock @cgrp->parent and @cgrp;
579 * Inherit state from @cgrp->parent; 580 * Inherit state from @cgrp->parent;
@@ -606,7 +607,7 @@ struct cgroup *cgroup_next_descendant_pre(struct cgroup *pos,
606 * iteration should lock and unlock both @pos->parent and @pos. 607 * iteration should lock and unlock both @pos->parent and @pos.
607 * 608 *
608 * Alternatively, a subsystem may choose to use a single global lock to 609 * Alternatively, a subsystem may choose to use a single global lock to
609 * synchronize ->post_create() and ->pre_destroy() against tree-walking 610 * synchronize ->css_online() and ->css_offline() against tree-walking
610 * operations. 611 * operations.
611 */ 612 */
612#define cgroup_for_each_descendant_pre(pos, cgroup) \ 613#define cgroup_for_each_descendant_pre(pos, cgroup) \
diff --git a/kernel/cgroup.c b/kernel/cgroup.c
index c389f4258681..d35463bab487 100644
--- a/kernel/cgroup.c
+++ b/kernel/cgroup.c
@@ -876,7 +876,7 @@ static void cgroup_diput(struct dentry *dentry, struct inode *inode)
876 * Release the subsystem state objects. 876 * Release the subsystem state objects.
877 */ 877 */
878 for_each_subsys(cgrp->root, ss) 878 for_each_subsys(cgrp->root, ss)
879 ss->destroy(cgrp); 879 ss->css_free(cgrp);
880 880
881 cgrp->root->number_of_cgroups--; 881 cgrp->root->number_of_cgroups--;
882 mutex_unlock(&cgroup_mutex); 882 mutex_unlock(&cgroup_mutex);
@@ -4048,8 +4048,8 @@ static int online_css(struct cgroup_subsys *ss, struct cgroup *cgrp)
4048 4048
4049 lockdep_assert_held(&cgroup_mutex); 4049 lockdep_assert_held(&cgroup_mutex);
4050 4050
4051 if (ss->post_create) 4051 if (ss->css_online)
4052 ret = ss->post_create(cgrp); 4052 ret = ss->css_online(cgrp);
4053 if (!ret) 4053 if (!ret)
4054 cgrp->subsys[ss->subsys_id]->flags |= CSS_ONLINE; 4054 cgrp->subsys[ss->subsys_id]->flags |= CSS_ONLINE;
4055 return ret; 4055 return ret;
@@ -4067,14 +4067,14 @@ static void offline_css(struct cgroup_subsys *ss, struct cgroup *cgrp)
4067 return; 4067 return;
4068 4068
4069 /* 4069 /*
4070 * pre_destroy() should be called with cgroup_mutex unlocked. See 4070 * css_offline() should be called with cgroup_mutex unlocked. See
4071 * 3fa59dfbc3 ("cgroup: fix potential deadlock in pre_destroy") for 4071 * 3fa59dfbc3 ("cgroup: fix potential deadlock in pre_destroy") for
4072 * details. This temporary unlocking should go away once 4072 * details. This temporary unlocking should go away once
4073 * cgroup_mutex is unexported from controllers. 4073 * cgroup_mutex is unexported from controllers.
4074 */ 4074 */
4075 if (ss->pre_destroy) { 4075 if (ss->css_offline) {
4076 mutex_unlock(&cgroup_mutex); 4076 mutex_unlock(&cgroup_mutex);
4077 ss->pre_destroy(cgrp); 4077 ss->css_offline(cgrp);
4078 mutex_lock(&cgroup_mutex); 4078 mutex_lock(&cgroup_mutex);
4079 } 4079 }
4080 4080
@@ -4136,7 +4136,7 @@ static long cgroup_create(struct cgroup *parent, struct dentry *dentry,
4136 for_each_subsys(root, ss) { 4136 for_each_subsys(root, ss) {
4137 struct cgroup_subsys_state *css; 4137 struct cgroup_subsys_state *css;
4138 4138
4139 css = ss->create(cgrp); 4139 css = ss->css_alloc(cgrp);
4140 if (IS_ERR(css)) { 4140 if (IS_ERR(css)) {
4141 err = PTR_ERR(css); 4141 err = PTR_ERR(css);
4142 goto err_free_all; 4142 goto err_free_all;
@@ -4147,7 +4147,7 @@ static long cgroup_create(struct cgroup *parent, struct dentry *dentry,
4147 if (err) 4147 if (err)
4148 goto err_free_all; 4148 goto err_free_all;
4149 } 4149 }
4150 /* At error, ->destroy() callback has to free assigned ID. */ 4150 /* At error, ->css_free() callback has to free assigned ID. */
4151 if (clone_children(parent) && ss->post_clone) 4151 if (clone_children(parent) && ss->post_clone)
4152 ss->post_clone(cgrp); 4152 ss->post_clone(cgrp);
4153 4153
@@ -4201,7 +4201,7 @@ static long cgroup_create(struct cgroup *parent, struct dentry *dentry,
4201err_free_all: 4201err_free_all:
4202 for_each_subsys(root, ss) { 4202 for_each_subsys(root, ss) {
4203 if (cgrp->subsys[ss->subsys_id]) 4203 if (cgrp->subsys[ss->subsys_id])
4204 ss->destroy(cgrp); 4204 ss->css_free(cgrp);
4205 } 4205 }
4206 mutex_unlock(&cgroup_mutex); 4206 mutex_unlock(&cgroup_mutex);
4207 /* Release the reference count that we took on the superblock */ 4207 /* Release the reference count that we took on the superblock */
@@ -4381,7 +4381,7 @@ static void __init cgroup_init_subsys(struct cgroup_subsys *ss)
4381 /* Create the top cgroup state for this subsystem */ 4381 /* Create the top cgroup state for this subsystem */
4382 list_add(&ss->sibling, &rootnode.subsys_list); 4382 list_add(&ss->sibling, &rootnode.subsys_list);
4383 ss->root = &rootnode; 4383 ss->root = &rootnode;
4384 css = ss->create(dummytop); 4384 css = ss->css_alloc(dummytop);
4385 /* We don't handle early failures gracefully */ 4385 /* We don't handle early failures gracefully */
4386 BUG_ON(IS_ERR(css)); 4386 BUG_ON(IS_ERR(css));
4387 init_cgroup_css(css, ss, dummytop); 4387 init_cgroup_css(css, ss, dummytop);
@@ -4425,7 +4425,7 @@ int __init_or_module cgroup_load_subsys(struct cgroup_subsys *ss)
4425 4425
4426 /* check name and function validity */ 4426 /* check name and function validity */
4427 if (ss->name == NULL || strlen(ss->name) > MAX_CGROUP_TYPE_NAMELEN || 4427 if (ss->name == NULL || strlen(ss->name) > MAX_CGROUP_TYPE_NAMELEN ||
4428 ss->create == NULL || ss->destroy == NULL) 4428 ss->css_alloc == NULL || ss->css_free == NULL)
4429 return -EINVAL; 4429 return -EINVAL;
4430 4430
4431 /* 4431 /*
@@ -4454,10 +4454,11 @@ int __init_or_module cgroup_load_subsys(struct cgroup_subsys *ss)
4454 subsys[ss->subsys_id] = ss; 4454 subsys[ss->subsys_id] = ss;
4455 4455
4456 /* 4456 /*
4457 * no ss->create seems to need anything important in the ss struct, so 4457 * no ss->css_alloc seems to need anything important in the ss
4458 * this can happen first (i.e. before the rootnode attachment). 4458 * struct, so this can happen first (i.e. before the rootnode
4459 * attachment).
4459 */ 4460 */
4460 css = ss->create(dummytop); 4461 css = ss->css_alloc(dummytop);
4461 if (IS_ERR(css)) { 4462 if (IS_ERR(css)) {
4462 /* failure case - need to deassign the subsys[] slot. */ 4463 /* failure case - need to deassign the subsys[] slot. */
4463 subsys[ss->subsys_id] = NULL; 4464 subsys[ss->subsys_id] = NULL;
@@ -4577,12 +4578,12 @@ void cgroup_unload_subsys(struct cgroup_subsys *ss)
4577 write_unlock(&css_set_lock); 4578 write_unlock(&css_set_lock);
4578 4579
4579 /* 4580 /*
4580 * remove subsystem's css from the dummytop and free it - need to free 4581 * remove subsystem's css from the dummytop and free it - need to
4581 * before marking as null because ss->destroy needs the cgrp->subsys 4582 * free before marking as null because ss->css_free needs the
4582 * pointer to find their state. note that this also takes care of 4583 * cgrp->subsys pointer to find their state. note that this also
4583 * freeing the css_id. 4584 * takes care of freeing the css_id.
4584 */ 4585 */
4585 ss->destroy(dummytop); 4586 ss->css_free(dummytop);
4586 dummytop->subsys[ss->subsys_id] = NULL; 4587 dummytop->subsys[ss->subsys_id] = NULL;
4587 4588
4588 mutex_unlock(&cgroup_mutex); 4589 mutex_unlock(&cgroup_mutex);
@@ -4626,8 +4627,8 @@ int __init cgroup_init_early(void)
4626 4627
4627 BUG_ON(!ss->name); 4628 BUG_ON(!ss->name);
4628 BUG_ON(strlen(ss->name) > MAX_CGROUP_TYPE_NAMELEN); 4629 BUG_ON(strlen(ss->name) > MAX_CGROUP_TYPE_NAMELEN);
4629 BUG_ON(!ss->create); 4630 BUG_ON(!ss->css_alloc);
4630 BUG_ON(!ss->destroy); 4631 BUG_ON(!ss->css_free);
4631 if (ss->subsys_id != i) { 4632 if (ss->subsys_id != i) {
4632 printk(KERN_ERR "cgroup: Subsys %s id == %d\n", 4633 printk(KERN_ERR "cgroup: Subsys %s id == %d\n",
4633 ss->name, ss->subsys_id); 4634 ss->name, ss->subsys_id);
@@ -5439,7 +5440,7 @@ struct cgroup_subsys_state *cgroup_css_from_dir(struct file *f, int id)
5439} 5440}
5440 5441
5441#ifdef CONFIG_CGROUP_DEBUG 5442#ifdef CONFIG_CGROUP_DEBUG
5442static struct cgroup_subsys_state *debug_create(struct cgroup *cont) 5443static struct cgroup_subsys_state *debug_css_alloc(struct cgroup *cont)
5443{ 5444{
5444 struct cgroup_subsys_state *css = kzalloc(sizeof(*css), GFP_KERNEL); 5445 struct cgroup_subsys_state *css = kzalloc(sizeof(*css), GFP_KERNEL);
5445 5446
@@ -5449,7 +5450,7 @@ static struct cgroup_subsys_state *debug_create(struct cgroup *cont)
5449 return css; 5450 return css;
5450} 5451}
5451 5452
5452static void debug_destroy(struct cgroup *cont) 5453static void debug_css_free(struct cgroup *cont)
5453{ 5454{
5454 kfree(cont->subsys[debug_subsys_id]); 5455 kfree(cont->subsys[debug_subsys_id]);
5455} 5456}
@@ -5578,8 +5579,8 @@ static struct cftype debug_files[] = {
5578 5579
5579struct cgroup_subsys debug_subsys = { 5580struct cgroup_subsys debug_subsys = {
5580 .name = "debug", 5581 .name = "debug",
5581 .create = debug_create, 5582 .css_alloc = debug_css_alloc,
5582 .destroy = debug_destroy, 5583 .css_free = debug_css_free,
5583 .subsys_id = debug_subsys_id, 5584 .subsys_id = debug_subsys_id,
5584 .base_cftypes = debug_files, 5585 .base_cftypes = debug_files,
5585}; 5586};
diff --git a/kernel/cgroup_freezer.c b/kernel/cgroup_freezer.c
index ee8bb671688c..75dda1ea5026 100644
--- a/kernel/cgroup_freezer.c
+++ b/kernel/cgroup_freezer.c
@@ -92,7 +92,7 @@ static const char *freezer_state_strs(unsigned int state)
92 92
93struct cgroup_subsys freezer_subsys; 93struct cgroup_subsys freezer_subsys;
94 94
95static struct cgroup_subsys_state *freezer_create(struct cgroup *cgroup) 95static struct cgroup_subsys_state *freezer_css_alloc(struct cgroup *cgroup)
96{ 96{
97 struct freezer *freezer; 97 struct freezer *freezer;
98 98
@@ -105,14 +105,14 @@ static struct cgroup_subsys_state *freezer_create(struct cgroup *cgroup)
105} 105}
106 106
107/** 107/**
108 * freezer_post_create - commit creation of a freezer cgroup 108 * freezer_css_online - commit creation of a freezer cgroup
109 * @cgroup: cgroup being created 109 * @cgroup: cgroup being created
110 * 110 *
111 * We're committing to creation of @cgroup. Mark it online and inherit 111 * We're committing to creation of @cgroup. Mark it online and inherit
112 * parent's freezing state while holding both parent's and our 112 * parent's freezing state while holding both parent's and our
113 * freezer->lock. 113 * freezer->lock.
114 */ 114 */
115static int freezer_post_create(struct cgroup *cgroup) 115static int freezer_css_online(struct cgroup *cgroup)
116{ 116{
117 struct freezer *freezer = cgroup_freezer(cgroup); 117 struct freezer *freezer = cgroup_freezer(cgroup);
118 struct freezer *parent = parent_freezer(freezer); 118 struct freezer *parent = parent_freezer(freezer);
@@ -141,13 +141,13 @@ static int freezer_post_create(struct cgroup *cgroup)
141} 141}
142 142
143/** 143/**
144 * freezer_pre_destroy - initiate destruction of @cgroup 144 * freezer_css_offline - initiate destruction of @cgroup
145 * @cgroup: cgroup being destroyed 145 * @cgroup: cgroup being destroyed
146 * 146 *
147 * @cgroup is going away. Mark it dead and decrement system_freezing_count 147 * @cgroup is going away. Mark it dead and decrement system_freezing_count
148 * if it was holding one. 148 * if it was holding one.
149 */ 149 */
150static void freezer_pre_destroy(struct cgroup *cgroup) 150static void freezer_css_offline(struct cgroup *cgroup)
151{ 151{
152 struct freezer *freezer = cgroup_freezer(cgroup); 152 struct freezer *freezer = cgroup_freezer(cgroup);
153 153
@@ -161,7 +161,7 @@ static void freezer_pre_destroy(struct cgroup *cgroup)
161 spin_unlock_irq(&freezer->lock); 161 spin_unlock_irq(&freezer->lock);
162} 162}
163 163
164static void freezer_destroy(struct cgroup *cgroup) 164static void freezer_css_free(struct cgroup *cgroup)
165{ 165{
166 kfree(cgroup_freezer(cgroup)); 166 kfree(cgroup_freezer(cgroup));
167} 167}
@@ -477,10 +477,10 @@ static struct cftype files[] = {
477 477
478struct cgroup_subsys freezer_subsys = { 478struct cgroup_subsys freezer_subsys = {
479 .name = "freezer", 479 .name = "freezer",
480 .create = freezer_create, 480 .css_alloc = freezer_css_alloc,
481 .post_create = freezer_post_create, 481 .css_online = freezer_css_online,
482 .pre_destroy = freezer_pre_destroy, 482 .css_offline = freezer_css_offline,
483 .destroy = freezer_destroy, 483 .css_free = freezer_css_free,
484 .subsys_id = freezer_subsys_id, 484 .subsys_id = freezer_subsys_id,
485 .attach = freezer_attach, 485 .attach = freezer_attach,
486 .fork = freezer_fork, 486 .fork = freezer_fork,
diff --git a/kernel/cpuset.c b/kernel/cpuset.c
index f33c7153b6d7..06931337c4e5 100644
--- a/kernel/cpuset.c
+++ b/kernel/cpuset.c
@@ -1821,11 +1821,11 @@ static void cpuset_post_clone(struct cgroup *cgroup)
1821} 1821}
1822 1822
1823/* 1823/*
1824 * cpuset_create - create a cpuset 1824 * cpuset_css_alloc - allocate a cpuset css
1825 * cont: control group that the new cpuset will be part of 1825 * cont: control group that the new cpuset will be part of
1826 */ 1826 */
1827 1827
1828static struct cgroup_subsys_state *cpuset_create(struct cgroup *cont) 1828static struct cgroup_subsys_state *cpuset_css_alloc(struct cgroup *cont)
1829{ 1829{
1830 struct cpuset *cs; 1830 struct cpuset *cs;
1831 struct cpuset *parent; 1831 struct cpuset *parent;
@@ -1864,7 +1864,7 @@ static struct cgroup_subsys_state *cpuset_create(struct cgroup *cont)
1864 * will call async_rebuild_sched_domains(). 1864 * will call async_rebuild_sched_domains().
1865 */ 1865 */
1866 1866
1867static void cpuset_destroy(struct cgroup *cont) 1867static void cpuset_css_free(struct cgroup *cont)
1868{ 1868{
1869 struct cpuset *cs = cgroup_cs(cont); 1869 struct cpuset *cs = cgroup_cs(cont);
1870 1870
@@ -1878,8 +1878,8 @@ static void cpuset_destroy(struct cgroup *cont)
1878 1878
1879struct cgroup_subsys cpuset_subsys = { 1879struct cgroup_subsys cpuset_subsys = {
1880 .name = "cpuset", 1880 .name = "cpuset",
1881 .create = cpuset_create, 1881 .css_alloc = cpuset_css_alloc,
1882 .destroy = cpuset_destroy, 1882 .css_free = cpuset_css_free,
1883 .can_attach = cpuset_can_attach, 1883 .can_attach = cpuset_can_attach,
1884 .attach = cpuset_attach, 1884 .attach = cpuset_attach,
1885 .post_clone = cpuset_post_clone, 1885 .post_clone = cpuset_post_clone,
diff --git a/kernel/events/core.c b/kernel/events/core.c
index dbccf83c134d..f9ff5493171d 100644
--- a/kernel/events/core.c
+++ b/kernel/events/core.c
@@ -7434,7 +7434,7 @@ unlock:
7434device_initcall(perf_event_sysfs_init); 7434device_initcall(perf_event_sysfs_init);
7435 7435
7436#ifdef CONFIG_CGROUP_PERF 7436#ifdef CONFIG_CGROUP_PERF
7437static struct cgroup_subsys_state *perf_cgroup_create(struct cgroup *cont) 7437static struct cgroup_subsys_state *perf_cgroup_css_alloc(struct cgroup *cont)
7438{ 7438{
7439 struct perf_cgroup *jc; 7439 struct perf_cgroup *jc;
7440 7440
@@ -7451,7 +7451,7 @@ static struct cgroup_subsys_state *perf_cgroup_create(struct cgroup *cont)
7451 return &jc->css; 7451 return &jc->css;
7452} 7452}
7453 7453
7454static void perf_cgroup_destroy(struct cgroup *cont) 7454static void perf_cgroup_css_free(struct cgroup *cont)
7455{ 7455{
7456 struct perf_cgroup *jc; 7456 struct perf_cgroup *jc;
7457 jc = container_of(cgroup_subsys_state(cont, perf_subsys_id), 7457 jc = container_of(cgroup_subsys_state(cont, perf_subsys_id),
@@ -7492,8 +7492,8 @@ static void perf_cgroup_exit(struct cgroup *cgrp, struct cgroup *old_cgrp,
7492struct cgroup_subsys perf_subsys = { 7492struct cgroup_subsys perf_subsys = {
7493 .name = "perf_event", 7493 .name = "perf_event",
7494 .subsys_id = perf_subsys_id, 7494 .subsys_id = perf_subsys_id,
7495 .create = perf_cgroup_create, 7495 .css_alloc = perf_cgroup_css_alloc,
7496 .destroy = perf_cgroup_destroy, 7496 .css_free = perf_cgroup_css_free,
7497 .exit = perf_cgroup_exit, 7497 .exit = perf_cgroup_exit,
7498 .attach = perf_cgroup_attach, 7498 .attach = perf_cgroup_attach,
7499 7499
diff --git a/kernel/sched/core.c b/kernel/sched/core.c
index 2d8927fda712..6f20c8fb2326 100644
--- a/kernel/sched/core.c
+++ b/kernel/sched/core.c
@@ -7468,7 +7468,7 @@ static inline struct task_group *cgroup_tg(struct cgroup *cgrp)
7468 struct task_group, css); 7468 struct task_group, css);
7469} 7469}
7470 7470
7471static struct cgroup_subsys_state *cpu_cgroup_create(struct cgroup *cgrp) 7471static struct cgroup_subsys_state *cpu_cgroup_css_alloc(struct cgroup *cgrp)
7472{ 7472{
7473 struct task_group *tg, *parent; 7473 struct task_group *tg, *parent;
7474 7474
@@ -7485,7 +7485,7 @@ static struct cgroup_subsys_state *cpu_cgroup_create(struct cgroup *cgrp)
7485 return &tg->css; 7485 return &tg->css;
7486} 7486}
7487 7487
7488static void cpu_cgroup_destroy(struct cgroup *cgrp) 7488static void cpu_cgroup_css_free(struct cgroup *cgrp)
7489{ 7489{
7490 struct task_group *tg = cgroup_tg(cgrp); 7490 struct task_group *tg = cgroup_tg(cgrp);
7491 7491
@@ -7845,8 +7845,8 @@ static struct cftype cpu_files[] = {
7845 7845
7846struct cgroup_subsys cpu_cgroup_subsys = { 7846struct cgroup_subsys cpu_cgroup_subsys = {
7847 .name = "cpu", 7847 .name = "cpu",
7848 .create = cpu_cgroup_create, 7848 .css_alloc = cpu_cgroup_css_alloc,
7849 .destroy = cpu_cgroup_destroy, 7849 .css_free = cpu_cgroup_css_free,
7850 .can_attach = cpu_cgroup_can_attach, 7850 .can_attach = cpu_cgroup_can_attach,
7851 .attach = cpu_cgroup_attach, 7851 .attach = cpu_cgroup_attach,
7852 .exit = cpu_cgroup_exit, 7852 .exit = cpu_cgroup_exit,
@@ -7869,7 +7869,7 @@ struct cgroup_subsys cpu_cgroup_subsys = {
7869struct cpuacct root_cpuacct; 7869struct cpuacct root_cpuacct;
7870 7870
7871/* create a new cpu accounting group */ 7871/* create a new cpu accounting group */
7872static struct cgroup_subsys_state *cpuacct_create(struct cgroup *cgrp) 7872static struct cgroup_subsys_state *cpuacct_css_alloc(struct cgroup *cgrp)
7873{ 7873{
7874 struct cpuacct *ca; 7874 struct cpuacct *ca;
7875 7875
@@ -7899,7 +7899,7 @@ out:
7899} 7899}
7900 7900
7901/* destroy an existing cpu accounting group */ 7901/* destroy an existing cpu accounting group */
7902static void cpuacct_destroy(struct cgroup *cgrp) 7902static void cpuacct_css_free(struct cgroup *cgrp)
7903{ 7903{
7904 struct cpuacct *ca = cgroup_ca(cgrp); 7904 struct cpuacct *ca = cgroup_ca(cgrp);
7905 7905
@@ -8070,8 +8070,8 @@ void cpuacct_charge(struct task_struct *tsk, u64 cputime)
8070 8070
8071struct cgroup_subsys cpuacct_subsys = { 8071struct cgroup_subsys cpuacct_subsys = {
8072 .name = "cpuacct", 8072 .name = "cpuacct",
8073 .create = cpuacct_create, 8073 .css_alloc = cpuacct_css_alloc,
8074 .destroy = cpuacct_destroy, 8074 .css_free = cpuacct_css_free,
8075 .subsys_id = cpuacct_subsys_id, 8075 .subsys_id = cpuacct_subsys_id,
8076 .base_cftypes = files, 8076 .base_cftypes = files,
8077}; 8077};
diff --git a/mm/hugetlb_cgroup.c b/mm/hugetlb_cgroup.c
index 0d3a1a317731..b5bde7a5c017 100644
--- a/mm/hugetlb_cgroup.c
+++ b/mm/hugetlb_cgroup.c
@@ -77,7 +77,7 @@ static inline bool hugetlb_cgroup_have_usage(struct cgroup *cg)
77 return false; 77 return false;
78} 78}
79 79
80static struct cgroup_subsys_state *hugetlb_cgroup_create(struct cgroup *cgroup) 80static struct cgroup_subsys_state *hugetlb_cgroup_css_alloc(struct cgroup *cgroup)
81{ 81{
82 int idx; 82 int idx;
83 struct cgroup *parent_cgroup; 83 struct cgroup *parent_cgroup;
@@ -101,7 +101,7 @@ static struct cgroup_subsys_state *hugetlb_cgroup_create(struct cgroup *cgroup)
101 return &h_cgroup->css; 101 return &h_cgroup->css;
102} 102}
103 103
104static void hugetlb_cgroup_destroy(struct cgroup *cgroup) 104static void hugetlb_cgroup_css_free(struct cgroup *cgroup)
105{ 105{
106 struct hugetlb_cgroup *h_cgroup; 106 struct hugetlb_cgroup *h_cgroup;
107 107
@@ -155,7 +155,7 @@ out:
155 * Force the hugetlb cgroup to empty the hugetlb resources by moving them to 155 * Force the hugetlb cgroup to empty the hugetlb resources by moving them to
156 * the parent cgroup. 156 * the parent cgroup.
157 */ 157 */
158static void hugetlb_cgroup_pre_destroy(struct cgroup *cgroup) 158static void hugetlb_cgroup_css_offline(struct cgroup *cgroup)
159{ 159{
160 struct hstate *h; 160 struct hstate *h;
161 struct page *page; 161 struct page *page;
@@ -404,8 +404,8 @@ void hugetlb_cgroup_migrate(struct page *oldhpage, struct page *newhpage)
404 404
405struct cgroup_subsys hugetlb_subsys = { 405struct cgroup_subsys hugetlb_subsys = {
406 .name = "hugetlb", 406 .name = "hugetlb",
407 .create = hugetlb_cgroup_create, 407 .css_alloc = hugetlb_cgroup_css_alloc,
408 .pre_destroy = hugetlb_cgroup_pre_destroy, 408 .css_offline = hugetlb_cgroup_css_offline,
409 .destroy = hugetlb_cgroup_destroy, 409 .css_free = hugetlb_cgroup_css_free,
410 .subsys_id = hugetlb_subsys_id, 410 .subsys_id = hugetlb_subsys_id,
411}; 411};
diff --git a/mm/memcontrol.c b/mm/memcontrol.c
index 08adaaae6fcc..8b0b2b028e23 100644
--- a/mm/memcontrol.c
+++ b/mm/memcontrol.c
@@ -4922,7 +4922,7 @@ err_cleanup:
4922} 4922}
4923 4923
4924static struct cgroup_subsys_state * __ref 4924static struct cgroup_subsys_state * __ref
4925mem_cgroup_create(struct cgroup *cont) 4925mem_cgroup_css_alloc(struct cgroup *cont)
4926{ 4926{
4927 struct mem_cgroup *memcg, *parent; 4927 struct mem_cgroup *memcg, *parent;
4928 long error = -ENOMEM; 4928 long error = -ENOMEM;
@@ -5003,14 +5003,14 @@ free_out:
5003 return ERR_PTR(error); 5003 return ERR_PTR(error);
5004} 5004}
5005 5005
5006static void mem_cgroup_pre_destroy(struct cgroup *cont) 5006static void mem_cgroup_css_offline(struct cgroup *cont)
5007{ 5007{
5008 struct mem_cgroup *memcg = mem_cgroup_from_cont(cont); 5008 struct mem_cgroup *memcg = mem_cgroup_from_cont(cont);
5009 5009
5010 mem_cgroup_reparent_charges(memcg); 5010 mem_cgroup_reparent_charges(memcg);
5011} 5011}
5012 5012
5013static void mem_cgroup_destroy(struct cgroup *cont) 5013static void mem_cgroup_css_free(struct cgroup *cont)
5014{ 5014{
5015 struct mem_cgroup *memcg = mem_cgroup_from_cont(cont); 5015 struct mem_cgroup *memcg = mem_cgroup_from_cont(cont);
5016 5016
@@ -5600,9 +5600,9 @@ static void mem_cgroup_move_task(struct cgroup *cont,
5600struct cgroup_subsys mem_cgroup_subsys = { 5600struct cgroup_subsys mem_cgroup_subsys = {
5601 .name = "memory", 5601 .name = "memory",
5602 .subsys_id = mem_cgroup_subsys_id, 5602 .subsys_id = mem_cgroup_subsys_id,
5603 .create = mem_cgroup_create, 5603 .css_alloc = mem_cgroup_css_alloc,
5604 .pre_destroy = mem_cgroup_pre_destroy, 5604 .css_offline = mem_cgroup_css_offline,
5605 .destroy = mem_cgroup_destroy, 5605 .css_free = mem_cgroup_css_free,
5606 .can_attach = mem_cgroup_can_attach, 5606 .can_attach = mem_cgroup_can_attach,
5607 .cancel_attach = mem_cgroup_cancel_attach, 5607 .cancel_attach = mem_cgroup_cancel_attach,
5608 .attach = mem_cgroup_move_task, 5608 .attach = mem_cgroup_move_task,
diff --git a/net/core/netprio_cgroup.c b/net/core/netprio_cgroup.c
index 79285a36035f..f0b6b0d572c1 100644
--- a/net/core/netprio_cgroup.c
+++ b/net/core/netprio_cgroup.c
@@ -108,7 +108,7 @@ static int write_update_netdev_table(struct net_device *dev)
108 return ret; 108 return ret;
109} 109}
110 110
111static struct cgroup_subsys_state *cgrp_create(struct cgroup *cgrp) 111static struct cgroup_subsys_state *cgrp_css_alloc(struct cgroup *cgrp)
112{ 112{
113 struct cgroup_netprio_state *cs; 113 struct cgroup_netprio_state *cs;
114 int ret = -EINVAL; 114 int ret = -EINVAL;
@@ -132,7 +132,7 @@ out:
132 return ERR_PTR(ret); 132 return ERR_PTR(ret);
133} 133}
134 134
135static void cgrp_destroy(struct cgroup *cgrp) 135static void cgrp_css_free(struct cgroup *cgrp)
136{ 136{
137 struct cgroup_netprio_state *cs; 137 struct cgroup_netprio_state *cs;
138 struct net_device *dev; 138 struct net_device *dev;
@@ -276,8 +276,8 @@ static struct cftype ss_files[] = {
276 276
277struct cgroup_subsys net_prio_subsys = { 277struct cgroup_subsys net_prio_subsys = {
278 .name = "net_prio", 278 .name = "net_prio",
279 .create = cgrp_create, 279 .css_alloc = cgrp_css_alloc,
280 .destroy = cgrp_destroy, 280 .css_free = cgrp_css_free,
281 .attach = net_prio_attach, 281 .attach = net_prio_attach,
282 .subsys_id = net_prio_subsys_id, 282 .subsys_id = net_prio_subsys_id,
283 .base_cftypes = ss_files, 283 .base_cftypes = ss_files,
diff --git a/net/sched/cls_cgroup.c b/net/sched/cls_cgroup.c
index 2ecde225ae60..8cdc18e075fb 100644
--- a/net/sched/cls_cgroup.c
+++ b/net/sched/cls_cgroup.c
@@ -34,7 +34,7 @@ static inline struct cgroup_cls_state *task_cls_state(struct task_struct *p)
34 struct cgroup_cls_state, css); 34 struct cgroup_cls_state, css);
35} 35}
36 36
37static struct cgroup_subsys_state *cgrp_create(struct cgroup *cgrp) 37static struct cgroup_subsys_state *cgrp_css_alloc(struct cgroup *cgrp)
38{ 38{
39 struct cgroup_cls_state *cs; 39 struct cgroup_cls_state *cs;
40 40
@@ -48,7 +48,7 @@ static struct cgroup_subsys_state *cgrp_create(struct cgroup *cgrp)
48 return &cs->css; 48 return &cs->css;
49} 49}
50 50
51static void cgrp_destroy(struct cgroup *cgrp) 51static void cgrp_css_free(struct cgroup *cgrp)
52{ 52{
53 kfree(cgrp_cls_state(cgrp)); 53 kfree(cgrp_cls_state(cgrp));
54} 54}
@@ -75,8 +75,8 @@ static struct cftype ss_files[] = {
75 75
76struct cgroup_subsys net_cls_subsys = { 76struct cgroup_subsys net_cls_subsys = {
77 .name = "net_cls", 77 .name = "net_cls",
78 .create = cgrp_create, 78 .css_alloc = cgrp_css_alloc,
79 .destroy = cgrp_destroy, 79 .css_free = cgrp_css_free,
80 .subsys_id = net_cls_subsys_id, 80 .subsys_id = net_cls_subsys_id,
81 .base_cftypes = ss_files, 81 .base_cftypes = ss_files,
82 .module = THIS_MODULE, 82 .module = THIS_MODULE,
diff --git a/security/device_cgroup.c b/security/device_cgroup.c
index 78a16f5b7275..19ecc8de9e6b 100644
--- a/security/device_cgroup.c
+++ b/security/device_cgroup.c
@@ -180,7 +180,7 @@ static void dev_exception_clean(struct dev_cgroup *dev_cgroup)
180/* 180/*
181 * called from kernel/cgroup.c with cgroup_lock() held. 181 * called from kernel/cgroup.c with cgroup_lock() held.
182 */ 182 */
183static struct cgroup_subsys_state *devcgroup_create(struct cgroup *cgroup) 183static struct cgroup_subsys_state *devcgroup_css_alloc(struct cgroup *cgroup)
184{ 184{
185 struct dev_cgroup *dev_cgroup, *parent_dev_cgroup; 185 struct dev_cgroup *dev_cgroup, *parent_dev_cgroup;
186 struct cgroup *parent_cgroup; 186 struct cgroup *parent_cgroup;
@@ -210,7 +210,7 @@ static struct cgroup_subsys_state *devcgroup_create(struct cgroup *cgroup)
210 return &dev_cgroup->css; 210 return &dev_cgroup->css;
211} 211}
212 212
213static void devcgroup_destroy(struct cgroup *cgroup) 213static void devcgroup_css_free(struct cgroup *cgroup)
214{ 214{
215 struct dev_cgroup *dev_cgroup; 215 struct dev_cgroup *dev_cgroup;
216 216
@@ -564,8 +564,8 @@ static struct cftype dev_cgroup_files[] = {
564struct cgroup_subsys devices_subsys = { 564struct cgroup_subsys devices_subsys = {
565 .name = "devices", 565 .name = "devices",
566 .can_attach = devcgroup_can_attach, 566 .can_attach = devcgroup_can_attach,
567 .create = devcgroup_create, 567 .css_alloc = devcgroup_css_alloc,
568 .destroy = devcgroup_destroy, 568 .css_free = devcgroup_css_free,
569 .subsys_id = devices_subsys_id, 569 .subsys_id = devices_subsys_id,
570 .base_cftypes = dev_cgroup_files, 570 .base_cftypes = dev_cgroup_files,
571 571