[Devel] [patch rh7 2/3] cgroups: Drop @self_destruction

Vladimir Davydov vdavydov at parallels.com
Tue May 5 03:39:12 PDT 2015


On Wed, Apr 29, 2015 at 02:56:25PM +0300, Cyrill Gorcunov wrote:
> It was introduced for cgroups management simplification, assuming
> that it's up to the kernel to create and autodestory cgroup. With
> time it evolves that it's up to userspace tools to create and destory
> cgroups, thus @self_destruction no longer needed and we drop it off.

It does not seem you reverted it completely. E.g. cgroup_is_disposable
is still there and cgroup_is_releasable does not look exactly as it used
to. Please check out commit 38f039db6e023ac14517219ad6f674633c4e99ca
("MS/CGROUP: self-destruction (without userspace helpers)") and fix the
patch accordingly.

> 
> Signed-off-by: Cyrill Gorcunov <gorcunov at odin.com>
> CC: Vladimir Davydov <vdavydov at odin.com>
> CC: Konstantin Khorenko <khorenko at odin.com>
> CC: Pavel Emelyanov <xemul at odin.com>
> CC: Andrey Vagin <avagin at odin.com>
> ---
>  include/linux/cgroup.h  |    2 -
>  kernel/bc/beancounter.c |   11 +++-------
>  kernel/cgroup.c         |   49 +-----------------------------------------------
>  kernel/ve/vecalls.c     |    6 +----
>  4 files changed, 8 insertions(+), 60 deletions(-)
> 
> Index: linux-pcs7.git/include/linux/cgroup.h
> ===================================================================
> --- linux-pcs7.git.orig/include/linux/cgroup.h
> +++ linux-pcs7.git/include/linux/cgroup.h
> @@ -46,7 +46,6 @@ struct cgroup_sb_opts {
>  enum cgroup_open_flags {
>  	CGRP_CREAT	= 0x0001,	/* create if not found */
>  	CGRP_EXCL	= 0x0002,	/* fail if already exist */
> -	CGRP_WEAK	= 0x0004,	/* arm cgroup self-destruction */
>  };
>  
>  struct vfsmount *cgroup_kernel_mount(struct cgroup_sb_opts *opts);
> @@ -190,7 +189,6 @@ enum {
>  	CGRP_CPUSET_CLONE_CHILDREN,
>  	/* see the comment above CGRP_ROOT_SANE_BEHAVIOR for details */
>  	CGRP_SANE_BEHAVIOR,
> -	CGRP_SELF_DESTRUCTION,
>  };
>  
>  struct cgroup_name {
> Index: linux-pcs7.git/kernel/bc/beancounter.c
> ===================================================================
> --- linux-pcs7.git.orig/kernel/bc/beancounter.c
> +++ linux-pcs7.git/kernel/bc/beancounter.c
> @@ -109,8 +109,7 @@ static int ub_mem_cgroup_attach_task(str
>  	struct cgroup *cg;
>  	int ret;
>  
> -	cg = cgroup_kernel_open(mem_cgroup_root,
> -				CGRP_CREAT|CGRP_WEAK, ub->ub_name);
> +	cg = cgroup_kernel_open(mem_cgroup_root, CGRP_CREAT, ub->ub_name);
>  	if (IS_ERR(cg))
>  		return PTR_ERR(cg);
>  
> @@ -134,8 +133,7 @@ static int ub_blkio_cgroup_attach_task(s
>  	if (!ubc_ioprio)
>  		return 0;
>  
> -	cg = cgroup_kernel_open(blkio_cgroup_root,
> -				CGRP_CREAT|CGRP_WEAK, ub->ub_name);
> +	cg = cgroup_kernel_open(blkio_cgroup_root, CGRP_CREAT, ub->ub_name);
>  	if (IS_ERR(cg))
>  		return PTR_ERR(cg);
>  
> @@ -152,8 +150,7 @@ static int ub_cgroup_attach_task(struct
>  	int ret;
>  
>  	if (ub != get_ub0()) {
> -		cg = cgroup_kernel_open(ub_cgroup_root,
> -					CGRP_CREAT|CGRP_WEAK, ub->ub_name);
> +		cg = cgroup_kernel_open(ub_cgroup_root, CGRP_CREAT, ub->ub_name);
>  		if (IS_ERR(cg))
>  			return PTR_ERR(cg);
>  	} else
> @@ -404,7 +401,7 @@ struct user_beancounter *get_beancounter
>  		if (IS_ERR(cg))
>  			return NULL;
>  		if (!cg) {
> -			cg = cgroup_kernel_open(ub_cgroup_root, CGRP_CREAT|CGRP_WEAK, name);
> +			cg = cgroup_kernel_open(ub_cgroup_root, CGRP_CREAT, name);
>  			if (IS_ERR_OR_NULL(cg))
>  				return NULL;
>  			pr_warn_once("Allocating UB with syslimits is deprecated!\n");
> Index: linux-pcs7.git/kernel/cgroup.c
> ===================================================================
> --- linux-pcs7.git.orig/kernel/cgroup.c
> +++ linux-pcs7.git/kernel/cgroup.c
> @@ -258,16 +258,14 @@ EXPORT_SYMBOL_GPL(cgroup_is_descendant);
>  
>  static int cgroup_is_disposable(const struct cgroup *cgrp)
>  {
> -	return (cgrp->flags & ((1 << CGRP_NOTIFY_ON_RELEASE) |
> -				(1 << CGRP_SELF_DESTRUCTION))) > 0;
> +	return (cgrp->flags & ((1 << CGRP_NOTIFY_ON_RELEASE))) > 0;
>  }
>  
>  static int cgroup_is_releasable(const struct cgroup *cgrp)
>  {
>  	const int bits =
>  		(1 << CGRP_RELEASABLE) |
> -		(1 << CGRP_NOTIFY_ON_RELEASE) |
> -		(1 << CGRP_SELF_DESTRUCTION);
> +		(1 << CGRP_NOTIFY_ON_RELEASE);
>  	return (cgrp->flags & bits) > (1 << CGRP_RELEASABLE);
>  }
>  
> @@ -4010,23 +4008,6 @@ static int cgroup_clone_children_write(s
>  	return 0;
>  }
>  
> -static u64 cgroup_read_self_destruction(struct cgroup *cgrp,
> -		struct cftype *cft)
> -{
> -	return test_bit(CGRP_SELF_DESTRUCTION, &cgrp->flags);
> -}
> -
> -static int cgroup_write_self_destruction(struct cgroup *cgrp,
> -		struct cftype *cft, u64 val)
> -{
> -	clear_bit(CGRP_RELEASABLE, &cgrp->flags);
> -	if (val)
> -		set_bit(CGRP_SELF_DESTRUCTION, &cgrp->flags);
> -	else
> -		clear_bit(CGRP_SELF_DESTRUCTION, &cgrp->flags);
> -	return 0;
> -}
> -
>  /*
>   * for the common functions, 'private' gives the type of file
>   */
> @@ -4075,11 +4056,6 @@ static struct cftype files[] = {
>  		.write_string = cgroup_release_agent_write,
>  		.max_write_len = PATH_MAX,
>  	},
> -	{
> -		.name = "self_destruction",
> -		.read_u64 = cgroup_read_self_destruction,
> -		.write_u64 = cgroup_write_self_destruction,
> -	},
>  	{ }	/* terminate */
>  };
>  
> @@ -4255,9 +4231,6 @@ static long cgroup_create(struct cgroup
>  	if (test_bit(CGRP_CPUSET_CLONE_CHILDREN, &parent->flags))
>  		set_bit(CGRP_CPUSET_CLONE_CHILDREN, &cgrp->flags);
>  
> -	if (test_bit(CGRP_SELF_DESTRUCTION, &parent->flags))
> -		set_bit(CGRP_SELF_DESTRUCTION, &cgrp->flags);
> -
>  	for_each_subsys(root, ss) {
>  		struct cgroup_subsys_state *css;
>  
> @@ -5155,19 +5128,6 @@ static void cgroup_release_agent(struct
>  		list_del_init(&cgrp->release_list);
>  		raw_spin_unlock(&release_list_lock);
>  
> -		if (test_bit(CGRP_SELF_DESTRUCTION, &cgrp->flags)) {
> -			struct inode *parent = cgrp->dentry->d_parent->d_inode;
> -
> -			dget(cgrp->dentry);
> -			mutex_unlock(&cgroup_mutex);
> -			mutex_lock_nested(&parent->i_mutex, I_MUTEX_PARENT);
> -			vfs_rmdir(parent, cgrp->dentry);
> -			mutex_unlock(&parent->i_mutex);
> -			dput(cgrp->dentry);
> -			mutex_lock(&cgroup_mutex);
> -			goto continue_free;
> -		}
> -
>  		pathbuf = kmalloc(PAGE_SIZE, GFP_KERNEL);
>  		if (!pathbuf)
>  			goto continue_free;
> @@ -5635,14 +5595,10 @@ struct cgroup *cgroup_kernel_open(struct
>  			ret = -EEXIST;
>  		else if (!dentry->d_inode)
>  			ret = vfs_mkdir(parent->dentry->d_inode, dentry, 0755);
> -		else
> -			flags &= ~CGRP_WEAK;
>  	}
>  	if (!ret && dentry->d_inode) {
>  		cgrp = __d_cgrp(dentry);
>  		atomic_inc(&cgrp->count);
> -		if (flags & CGRP_WEAK)
> -			set_bit(CGRP_SELF_DESTRUCTION, &cgrp->flags);
>  	} else
>  		cgrp = ret ? ERR_PTR(ret) : NULL;
>  	dput(dentry);
> @@ -5696,7 +5652,6 @@ EXPORT_SYMBOL(cgroup_kernel_close);
>  
>  void cgroup_kernel_destroy(struct cgroup *cgrp)
>  {
> -	set_bit(CGRP_SELF_DESTRUCTION, &cgrp->flags);
>  	set_bit(CGRP_RELEASABLE, &cgrp->flags);
>  	check_for_release(cgrp);
>  }
> Index: linux-pcs7.git/kernel/ve/vecalls.c
> ===================================================================
> --- linux-pcs7.git.orig/kernel/ve/vecalls.c
> +++ linux-pcs7.git/kernel/ve/vecalls.c
> @@ -441,14 +441,12 @@ static int do_env_create(envid_t veid, u
>  
>  	legacy_veid_to_name(veid, ve_name);
>  
> -	ve_cgroup = ve_cgroup_open(ve0.css.cgroup,
> -			CGRP_CREAT|CGRP_WEAK|CGRP_EXCL, veid);
> +	ve_cgroup = ve_cgroup_open(ve0.css.cgroup, CGRP_CREAT|CGRP_EXCL, veid);
>  	err = PTR_ERR(ve_cgroup);
>  	if (IS_ERR(ve_cgroup))
>  		goto err_ve_cgroup;
>  
> -	dev_cgroup = ve_cgroup_open(devices_root,
> -		CGRP_CREAT|CGRP_WEAK, veid);
> +	dev_cgroup = ve_cgroup_open(devices_root, CGRP_CREAT, veid);
>  	err = PTR_ERR(dev_cgroup);
>  	if (IS_ERR(dev_cgroup))
>  		goto err_dev_cgroup;
> 



More information about the Devel mailing list