[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20130226022703.GA13837@htj.dyndns.org>
Date: Mon, 25 Feb 2013 18:27:03 -0800
From: Tejun Heo <tj@...nel.org>
To: Li Zefan <lizefan@...wei.com>
Cc: Al Viro <viro@...IV.linux.org.uk>,
LKML <linux-kernel@...r.kernel.org>,
Cgroups <cgroups@...r.kernel.org>
Subject: Re: [PATCH 2/3] cgroup: add cgroup_name() API
On Mon, Feb 25, 2013 at 02:17:49PM +0800, Li Zefan wrote:
> cgroup_name() returns the name of a cgroup and it must be called with
> rcu_read_lock() held.
>
> This will be used by cpuset.
>
> Signed-off-by: Li Zefan <lizefan@...wei.com>
...
> /**
> + * cgroup_name - get the name of a cgroup
> + * @cgrp: the cgroup in question
> + *
> + * Must be called with rcu_read_lock() held.
> + */
> +char *cgroup_name(const struct cgroup *cgrp)
> +{
> + if (!cgrp->parent)
> + return "/";
> + else
> + return rcu_dereference(cgrp->name)->name;
> +}
Can't we initialize ->name of root cgroup to "/" and lose the
conditional? We can lose the wrapper altogether but if you're worried
that sparse check isn't enough, we can have trivial inline wrapper,
but in that case it probably would help to rename cgrp->name to, say,
cgrp->__name and put a comment directing people to the accessing
wrapper which should probably return const char *.
Thanks.
--
tejun
--
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