mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Paul Menage <menage@google.com>
To: Jesper Juhl <jj@chaosbits.net>
Cc: linux-kernel@vger.kernel.org,
	Stephen Hemminger <shemminger@linux-foundation.org>,
	Paul Jackson <pj@sgi.com>, Simon Derr <simon.derr@bull.net>
Subject: Re: [PATCH] Remove some pointless conditionals before kfree() in  kernel/cgroup.c
Date: Mon, 23 Feb 2009 00:12:51 -0800	[thread overview]
Message-ID: <6599ad830902230012x170e2183q1540670d761ef80e@mail.gmail.com> (raw)
In-Reply-To: <alpine.LNX.2.00.0902222254350.1236@swampdragon.chaosbits.net>

On Sun, Feb 22, 2009 at 2:05 PM, Jesper Juhl <jj@chaosbits.net> wrote:
> Hi,
>
> Here's a small patch for kernel/cgroup.c
>
> Removes a few pointless tests of pointer == 0 before kfree() in
> kernel/cgroup.c.
> If the pointer we hand to kfree() is 0, then kfree() is a noop, so there
> is no need to test.
>
> Reduces object file size a bit :
>
> Before:
> $ size kernel/cgroup.o
>   text    data     bss     dec     hex filename
>  21593    7804    4924   34321    8611 kernel/cgroup.o
> After:
> $ size kernel/cgroup.o
>   text    data     bss     dec     hex filename
>  21537    7744    4924   34205    859d kernel/cgroup.o

Thanks. I'm a bit surprised that it also shrunk the data segment size
(and in fact, by more than the text segment size). Any idea how that
came about?

>
> Signed-off-by: Jesper Juhl <jj@chaosbits.net>

Acked-by: Paul Menage <menage@google.com>

Paul

> ---
>
> diff --git a/kernel/cgroup.c b/kernel/cgroup.c
> index 9edb5c4..1c0a9b5 100644
> --- a/kernel/cgroup.c
> +++ b/kernel/cgroup.c
> @@ -865,8 +865,7 @@ static int cgroup_remount(struct super_block *sb, int *flags, char *data)
>        if (opts.release_agent)
>                strcpy(root->release_agent_path, opts.release_agent);
>  out_unlock:
> -       if (opts.release_agent)
> -               kfree(opts.release_agent);
> +       kfree(opts.release_agent);
>        mutex_unlock(&cgroup_mutex);
>        mutex_unlock(&cgrp->dentry->d_inode->i_mutex);
>        return ret;
> @@ -969,15 +968,13 @@ static int cgroup_get_sb(struct file_system_type *fs_type,
>        /* First find the desired set of subsystems */
>        ret = parse_cgroupfs_options(data, &opts);
>        if (ret) {
> -               if (opts.release_agent)
> -                       kfree(opts.release_agent);
> +               kfree(opts.release_agent);
>                return ret;
>        }
>
>        root = kzalloc(sizeof(*root), GFP_KERNEL);
>        if (!root) {
> -               if (opts.release_agent)
> -                       kfree(opts.release_agent);
> +               kfree(opts.release_agent);
>                return -ENOMEM;
>        }
>
>
>
> --
> Jesper Juhl <jj@chaosbits.net>             http://www.chaosbits.net/
> Plain text mails only, please      http://www.expita.com/nomime.html
> Don't top-post  http://www.catb.org/~esr/jargon/html/T/top-post.html
>
>

  reply	other threads:[~2009-02-23  8:13 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-02-22 22:05 Jesper Juhl
2009-02-23  8:12 ` Paul Menage [this message]
2009-02-23  8:17   ` Cyrill Gorcunov
2009-02-23  8:19     ` Cyrill Gorcunov
2009-02-23  8:30   ` Li Zefan
2009-02-23 21:46   ` Jesper Juhl
2009-02-23  8:32 ` Li Zefan

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=6599ad830902230012x170e2183q1540670d761ef80e@mail.gmail.com \
    --to=menage@google.com \
    --cc=jj@chaosbits.net \
    --cc=linux-kernel@vger.kernel.org \
    --cc=pj@sgi.com \
    --cc=shemminger@linux-foundation.org \
    --cc=simon.derr@bull.net \
    /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®