From mboxrd@z Thu Jan 1 00:00:00 1970 From: Li Zefan Subject: Re: [PATCH] cgroups: remove redundant get/put of css_set from css_set_check_fetched() Date: Fri, 16 Dec 2011 10:30:29 +0800 Message-ID: <4EEAAD45.5030407@cn.fujitsu.com> References: <1323987686-17968-1-git-send-email-msb@chromium.org> Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Return-path: In-Reply-To: <1323987686-17968-1-git-send-email-msb-F7+t8E8rja9g9hUCZPvPmw@public.gmane.org> List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: containers-bounces-cunTk1MwBs9QetFLy7KEm3xJsTq8ys+cHZ5vskTnxNA@public.gmane.org Errors-To: containers-bounces-cunTk1MwBs9QetFLy7KEm3xJsTq8ys+cHZ5vskTnxNA@public.gmane.org To: Mandeep Singh Baines Cc: Tejun Heo , cgroups-u79uwXL29TY76Z2rM5mHXA@public.gmane.org, containers-cunTk1MwBs9QetFLy7KEm3xJsTq8ys+cHZ5vskTnxNA@public.gmane.org, linux-kernel-u79uwXL29TY76Z2rM5mHXA@public.gmane.org, Paul Menage Mandeep Singh Baines wrote: > We already have a reference to all elements in newcg_list. > Indeed. The patch looks good to me. Reviewed-by: Li Zefan > Signed-off-by: Mandeep Singh Baines > Cc: Tejun Heo > Cc: Li Zefan > Cc: containers-cunTk1MwBs9QetFLy7KEm3xJsTq8ys+cHZ5vskTnxNA@public.gmane.org > Cc: cgroups-u79uwXL29TY76Z2rM5mHXA@public.gmane.org > Cc: Paul Menage > --- > kernel/cgroup.c | 10 ++-------- > 1 files changed, 2 insertions(+), 8 deletions(-) > > diff --git a/kernel/cgroup.c b/kernel/cgroup.c > index d9d5648..a7e00b9 100644 > --- a/kernel/cgroup.c > +++ b/kernel/cgroup.c > @@ -1935,23 +1935,17 @@ static bool css_set_check_fetched(struct cgroup *cgrp, > > read_lock(&css_set_lock); > newcg = find_existing_css_set(cg, cgrp, template); > - if (newcg) > - get_css_set(newcg); > read_unlock(&css_set_lock); > > /* doesn't exist at all? */ > if (!newcg) > return false; > /* see if it's already in the list */ > - list_for_each_entry(cg_entry, newcg_list, links) { > - if (cg_entry->cg == newcg) { > - put_css_set(newcg); > + list_for_each_entry(cg_entry, newcg_list, links) > + if (cg_entry->cg == newcg) > return true; > - } > - } > > /* not found */ > - put_css_set(newcg); > return false; > } >