From: "Paul Menage" <menage@google.com>
To: "Li Zefan" <lizf@cn.fujitsu.com>
Cc: "Andrew Morton" <akpm@linux-foundation.org>,
LKML <linux-kernel@vger.kernel.org>,
"Linux Containers" <containers@lists.linux-foundation.org>
Subject: Re: [PATCH] cgroup: remove duplicate code in allocate_cg_link()
Date: Wed, 30 Jul 2008 01:15:03 -0700 [thread overview]
Message-ID: <6599ad830807300115w5e6a620cw18b63fbcf60fb778@mail.gmail.com> (raw)
In-Reply-To: <488D2D0A.7050006@cn.fujitsu.com>
On Sun, Jul 27, 2008 at 7:20 PM, Li Zefan <lizf@cn.fujitsu.com> wrote:
> - just call free_cg_links() in allocate_cg_links()
> - the list will get initialized in allocate_cg_links(), so don't init
> it twice
>
> Signed-off-by: Li Zefan <lizf@cn.fujitsu.com>
(Belatedly) Acked-by: Paul Menage <menage@google.com>
Thanks, looks like a good cleanup.
> ---
> kernel/cgroup.c | 30 ++++++++++++------------------
> 1 files changed, 12 insertions(+), 18 deletions(-)
>
> diff --git a/kernel/cgroup.c b/kernel/cgroup.c
> index 28debe4..249a517 100644
> --- a/kernel/cgroup.c
> +++ b/kernel/cgroup.c
> @@ -355,6 +355,17 @@ static struct css_set *find_existing_css_set(
> return NULL;
> }
>
> +static void free_cg_links(struct list_head *tmp)
> +{
> + struct cg_cgroup_link *link;
> + struct cg_cgroup_link *saved_link;
> +
> + list_for_each_entry_safe(link, saved_link, tmp, cgrp_link_list) {
> + list_del(&link->cgrp_link_list);
> + kfree(link);
> + }
> +}
> +
> /*
> * allocate_cg_links() allocates "count" cg_cgroup_link structures
> * and chains them on tmp through their cgrp_link_list fields. Returns 0 on
> @@ -363,17 +374,12 @@ static struct css_set *find_existing_css_set(
> static int allocate_cg_links(int count, struct list_head *tmp)
> {
> struct cg_cgroup_link *link;
> - struct cg_cgroup_link *saved_link;
> int i;
> INIT_LIST_HEAD(tmp);
> for (i = 0; i < count; i++) {
> link = kmalloc(sizeof(*link), GFP_KERNEL);
> if (!link) {
> - list_for_each_entry_safe(link, saved_link, tmp,
> - cgrp_link_list) {
> - list_del(&link->cgrp_link_list);
> - kfree(link);
> - }
> + free_cg_links(tmp);
> return -ENOMEM;
> }
> list_add(&link->cgrp_link_list, tmp);
> @@ -381,17 +387,6 @@ static int allocate_cg_links(int count, struct list_head *tmp)
> return 0;
> }
>
> -static void free_cg_links(struct list_head *tmp)
> -{
> - struct cg_cgroup_link *link;
> - struct cg_cgroup_link *saved_link;
> -
> - list_for_each_entry_safe(link, saved_link, tmp, cgrp_link_list) {
> - list_del(&link->cgrp_link_list);
> - kfree(link);
> - }
> -}
> -
> /*
> * find_css_set() takes an existing cgroup group and a
> * cgroup object, and returns a css_set object that's
> @@ -956,7 +951,6 @@ static int cgroup_get_sb(struct file_system_type *fs_type,
> struct super_block *sb;
> struct cgroupfs_root *root;
> struct list_head tmp_cg_links;
> - INIT_LIST_HEAD(&tmp_cg_links);
>
> /* First find the desired set of subsystems */
> ret = parse_cgroupfs_options(data, &opts);
> --
> 1.5.4.rc3
>
>
prev parent reply other threads:[~2008-07-30 8:15 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2008-07-28 2:20 Li Zefan
2008-07-30 8:15 ` Paul Menage [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=6599ad830807300115w5e6a620cw18b63fbcf60fb778@mail.gmail.com \
--to=menage@google.com \
--cc=akpm@linux-foundation.org \
--cc=containers@lists.linux-foundation.org \
--cc=linux-kernel@vger.kernel.org \
--cc=lizf@cn.fujitsu.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®