All of lore.kernel.org
 help / color / mirror / Atom feed
From: Andreas Dilger <adilger@sun.com>
To: Manish Katiyar <mkatiyar@gmail.com>
Cc: ext4 <linux-ext4@vger.kernel.org>
Subject: Re: Checking of NULL with __GFP_NOFAIL in kzalloc()
Date: Mon, 02 Mar 2009 00:35:21 -0700	[thread overview]
Message-ID: <20090302073521.GI3199@webber.adilger.int> (raw)
In-Reply-To: <ea11fea30903012208k6992a019h9683b95379314b55@mail.gmail.com>

On Mar 02, 2009  11:38 +0530, Manish Katiyar wrote:
> On Sun, Mar 1, 2009 at 11:35 AM, Manish Katiyar <mkatiyar@gmail.com> wrote:
> > While going through jbd code, I was wondering why do we need to check
> > new_transaction for NULL, if we are passing __GFP_NOFAIL ?
> > Last code change around this code was when Ted converted kmalloc to
> > kzalloc, but since he also didn't remove it I am guessing there would
> > be some good reason for it. Can someone enlighten me ?
> 
> I didn't receive any response to this. So probably removing the NULL
> check is harmless. Or should I remove the __GFP_NOFAIL flag and keep
> the error handling ?

Neither, please.  The NULL check is harmless, and static code checkers
will complain about k[zm]alloc() without a corresponding NULL check.
Branch prediction will get this right, so the overhead is miniscule.

> > start_this_handle() {
> > ..........
> >        ..........
> >        new_transaction = kzalloc(sizeof(*new_transaction),
> >                        GFP_NOFS|__GFP_NOFAIL);
> >        if (!new_transaction) {
> >                ret = -ENOMEM;
> >                goto out;
> >        }
> >        ..........
> > }

Cheers, Andreas
--
Andreas Dilger
Sr. Staff Engineer, Lustre Group
Sun Microsystems of Canada, Inc.

--
To unsubscribe from this list: send the line "unsubscribe linux-ext4" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

  reply	other threads:[~2009-03-02  7:35 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-03-01  6:05 Checking of NULL with __GFP_NOFAIL in kzalloc() Manish Katiyar
2009-03-02  6:08 ` Manish Katiyar
2009-03-02  7:35   ` Andreas Dilger [this message]
2009-03-02  8:15     ` Manish Katiyar
2009-03-02 13:44   ` Theodore Tso

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=20090302073521.GI3199@webber.adilger.int \
    --to=adilger@sun.com \
    --cc=linux-ext4@vger.kernel.org \
    --cc=mkatiyar@gmail.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.