Re: [PATCH 1/3] cgroup: convert open-codedmutex_lock(&cgroup_mutex) calls into cgroup_lock() calls

From: Ingo Molnar
Date: Sun Jan 18 2009 - 04:11:27 EST



* Lai Jiangshan <laijs@xxxxxxxxxxxxxx> wrote:

> Convert open-coded mutex_lock(&cgroup_mutex) calls into cgroup_lock()
> calls and convert mutex_unlock(&cgroup_mutex) calls into cgroup_unlock()
> calls.
>
> Signed-off-by: Lai Jiangshan <laijs@xxxxxxxxxxxxxx>
> Cc: Max Krasnyansky <maxk@xxxxxxxxxxxx>
> Cc: Miao Xie <miaox@xxxxxxxxxxxxxx>
> ---

(please include diffstat output in patches, so that the general source
code impact can be seen at a glance.)

> diff --git a/kernel/cgroup.c b/kernel/cgroup.c
> index c298310..75a352b 100644
> --- a/kernel/cgroup.c
> +++ b/kernel/cgroup.c
> @@ -616,7 +688,7 @@ static void cgroup_diput(struct dentry *dentry, struct inode *inode)
> * agent */
> synchronize_rcu();
>
> - mutex_lock(&cgroup_mutex);
> + cgroup_lock();

this just changes over a clean mutex call to a wrapped lock/unlock
sequence that has higher overhead in the common case.

We should do the exact opposite, we should change this opaque API:

void cgroup_lock(void)
{
mutex_lock(&cgroup_mutex);
}

To something more explicit (and more maintainable) like:

cgroup_mutex_lock(&cgroup_mutex);
cgroup_mutex_unlock(&cgroup_mutex);

Which is a NOP in the !CGROUPS case and maps to mutex_lock/unlock in the
CGROUPS=y case.

Ingo
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/