lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Date:	Wed, 24 Jul 2013 16:07:02 +0200
From:	Michal Hocko <mhocko@...e.cz>
To:	Li Zefan <lizefan@...wei.com>
Cc:	Tejun Heo <tj@...nel.org>,
	Andrew Morton <akpm@...ux-foundation.org>,
	Glauber Costa <glommer@...allels.com>,
	KAMEZAWA Hiroyuki <kamezawa.hiroyu@...fujitsu.com>,
	Johannes Weiner <hannes@...xchg.org>,
	LKML <linux-kernel@...r.kernel.org>,
	Cgroups <cgroups@...r.kernel.org>, linux-mm@...ck.org
Subject: Re: [PATCH v2 1/8] cgroup: convert cgroup_ida to cgroup_idr

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@...wei.com>

Reviewed-by: Michal Hocko <mhocko@...e.cz>

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 from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ