cgroups: clean up cgroup_pidlist_find() a bit

Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]
From: Linux Kernel Mailing List
Date: Friday, March 12, 2010 - 6:00 pm

Gitweb:     http://git.kernel.org/linus/b70cc5fdb445a6929a01e9c406593265b136c99d
Commit:     b70cc5fdb445a6929a01e9c406593265b136c99d
Parent:     67523c48aa74d5637848edeccf285af1c60bf14a
Author:     Li Zefan <lizf@cn.fujitsu.com>
AuthorDate: Wed Mar 10 15:22:12 2010 -0800
Committer:  Linus Torvalds <torvalds@linux-foundation.org>
CommitDate: Fri Mar 12 15:52:36 2010 -0800

    cgroups: clean up cgroup_pidlist_find() a bit
    
    Don't call get_pid_ns() before we locate/alloc the ns.
    
    Signed-off-by: Li Zefan <lizf@cn.fujitsu.com>
    Cc: Serge Hallyn <serue@us.ibm.com>
    Acked-by: Paul Menage <menage@google.com>
    Cc: KAMEZAWA Hiroyuki <kamezawa.hiroyu@jp.fujitsu.com>
    Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
    Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
---
 kernel/cgroup.c |    8 +++-----
 1 files changed, 3 insertions(+), 5 deletions(-)

diff --git a/kernel/cgroup.c b/kernel/cgroup.c
index 521591d..1bf4d6d 100644
--- a/kernel/cgroup.c
+++ b/kernel/cgroup.c
@@ -2597,7 +2597,8 @@ static struct cgroup_pidlist *cgroup_pidlist_find(struct cgroup *cgrp,
 {
 	struct cgroup_pidlist *l;
 	/* don't need task_nsproxy() if we're looking at ourself */
-	struct pid_namespace *ns = get_pid_ns(current->nsproxy->pid_ns);
+	struct pid_namespace *ns = current->nsproxy->pid_ns;
+
 	/*
 	 * We can't drop the pidlist_mutex before taking the l->mutex in case
 	 * the last ref-holder is trying to remove l from the list at the same
@@ -2607,8 +2608,6 @@ static struct cgroup_pidlist *cgroup_pidlist_find(struct cgroup *cgrp,
 	mutex_lock(&cgrp->pidlist_mutex);
 	list_for_each_entry(l, &cgrp->pidlists, links) {
 		if (l->key.type == type && l->key.ns == ns) {
-			/* found a matching list - drop the extra refcount */
-			put_pid_ns(ns);
 			/* make sure l doesn't vanish out from under us */
 			down_write(&l->mutex);
 			mutex_unlock(&cgrp->pidlist_mutex);
@@ -2619,13 +2618,12 @@ static struct cgroup_pidlist *cgroup_pidlist_find(struct cgroup *cgrp,
 	l = kmalloc(sizeof(struct cgroup_pidlist), GFP_KERNEL);
 	if (!l) {
 		mutex_unlock(&cgrp->pidlist_mutex);
-		put_pid_ns(ns);
 		return l;
 	}
 	init_rwsem(&l->mutex);
 	down_write(&l->mutex);
 	l->key.type = type;
-	l->key.ns = ns;
+	l->key.ns = get_pid_ns(ns);
 	l->use_count = 0; /* don't increment here */
 	l->list = NULL;
 	l->owner = cgrp;
--
To unsubscribe from this list: send the line "unsubscribe git-commits-head" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]

Messages in current thread:
cgroups: clean up cgroup_pidlist_find() a bit, Linux Kernel Mailing ..., (Fri Mar 12, 6:00 pm)