Re: [PATCH v2 1/8] cgroup: convert cgroup_ida to cgroup_idr

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Wed 24-07-13 17:59:12, Li Zefan wrote:
> This enables us to lookup a cgroup by its id.
> 
> Signed-off-by: Li Zefan <lizefan@xxxxxxxxxx>

Reviewed-by: Michal Hocko <mhocko@xxxxxxx>

One nit/question bellow
[...]
> @@ -4268,15 +4271,19 @@ static long cgroup_create(struct cgroup *parent, struct dentry *dentry,
>  	if (!cgrp)
>  		return -ENOMEM;
>  
> +	/*
> +	 * Temporarily set the pointer to NULL, so idr_find() won't return
> +	 * a half-baked cgroup.
> +	 */
> +	cgrp->id = idr_alloc(&root->cgroup_idr, NULL, 1, 0, GFP_KERNEL);
> +	if (cgrp->id < 0)
> +		goto err_free_cgrp;
> +
>  	name = cgroup_alloc_name(dentry);
>  	if (!name)
> -		goto err_free_cgrp;
> +		goto err_free_id;
>  	rcu_assign_pointer(cgrp->name, name);
>  
> -	cgrp->id = ida_simple_get(&root->cgroup_ida, 1, 0, GFP_KERNEL);
> -	if (cgrp->id < 0)
> -		goto err_free_name;
> -

Is the move necessary? You would safe few lines in the patch if you kept
the ordering.

>  	/*
>  	 * Only live parents can have children.  Note that the liveliness
>  	 * check isn't strictly necessary because cgroup_mkdir() and
> @@ -4286,7 +4293,7 @@ static long cgroup_create(struct cgroup *parent, struct dentry *dentry,
>  	 */
>  	if (!cgroup_lock_live_group(parent)) {
>  		err = -ENODEV;
> -		goto err_free_id;
> +		goto err_free_name;
>  	}
>  
>  	/* Grab a reference on the superblock so the hierarchy doesn't
> @@ -4371,6 +4378,8 @@ static long cgroup_create(struct cgroup *parent, struct dentry *dentry,
>  		}
>  	}
>  
> +	idr_replace(&root->cgroup_idr, cgrp, cgrp->id);
> +
>  	err = cgroup_addrm_files(cgrp, NULL, cgroup_base_files, true);
>  	if (err)
>  		goto err_destroy;
> @@ -4396,10 +4405,10 @@ err_free_all:
>  	mutex_unlock(&cgroup_mutex);
>  	/* Release the reference count that we took on the superblock */
>  	deactivate_super(sb);
> -err_free_id:
> -	ida_simple_remove(&root->cgroup_ida, cgrp->id);
>  err_free_name:
>  	kfree(rcu_dereference_raw(cgrp->name));
> +err_free_id:
> +	idr_remove(&root->cgroup_idr, cgrp->id);
>  err_free_cgrp:
>  	kfree(cgrp);
>  	return err;
[...]
-- 
Michal Hocko
SUSE Labs

--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to majordomo@xxxxxxxxx.  For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"dont@xxxxxxxxx";> email@xxxxxxxxx </a>




[Index of Archives]     [Linux ARM Kernel]     [Linux ARM]     [Linux Omap]     [Fedora ARM]     [IETF Annouce]     [Bugtraq]     [Linux]     [Linux OMAP]     [Linux MIPS]     [ECOS]     [Asterisk Internet PBX]     [Linux API]