linux-raid.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Neil Brown <neilb@suse.de>
To: Jan Kara <jack@suse.cz>
Cc: cluster-devel@redhat.com, linux-ext4@vger.kernel.org,
	Jiri Slaby <jirislaby@gmail.com>,
	Jens Axboe <jaxboe@fusionio.com>,
	reiserfs-devel@vger.kernel.org, linux-kernel@vger.kernel.org,
	linux-raid@vger.kernel.org, David Rientjes <rientjes@google.com>,
	Andrew Morton <akpm@linux-foundation.org>,
	linux-btrfs@vger.kernel.org,
	Frederic Weisbecker <fweisbec@gmail.com>,
	Chris Mason <chris.mason@oracle.com>
Subject: Re: [patch v2 1/5] mm: add nofail variants of kmalloc kcalloc and kzalloc
Date: Fri, 3 Sep 2010 07:15:06 +1000	[thread overview]
Message-ID: <20100903071506.6e6b4d63@notabene> (raw)
In-Reply-To: <20100902145141.GA3273@quack.suse.cz>

On Thu, 2 Sep 2010 16:51:41 +0200
Jan Kara <jack@suse.cz> wrote:

> On Thu 02-09-10 09:59:13, Jiri Slaby wrote:
> > On 09/02/2010 03:02 AM, David Rientjes wrote:
> > > --- a/include/linux/slab.h +++ b/include/linux/slab.h @@ -334,6 +334,57
> > > @@ static inline void *kzalloc_node(size_t size, gfp_t flags, int node)
> > > return kmalloc_node(size, flags | __GFP_ZERO, node); }
> > >  
> > > +/** + * kmalloc_nofail - infinitely loop until kmalloc() succeeds.  +
> > > * @size: how many bytes of memory are required.  + * @flags: the type
> > > of memory to allocate (see kmalloc).  + * + * NOTE: no new callers of
> > > this function should be implemented!  + * All memory allocations should
> > > be failable whenever possible.  + */ +static inline void
> > > *kmalloc_nofail(size_t size, gfp_t flags) +{ +	void *ret; + +	for
> > > (;;) { +		ret = kmalloc(size, flags); +		if (ret) +
> > > return ret; +		WARN_ON_ONCE(get_order(size) >
> > > PAGE_ALLOC_COSTLY_ORDER);
> > 
> > This doesn't work as you expect. kmalloc will warn every time it fails.
> > __GFP_NOFAIL used to disable the warning. Actually what's wrong with
> > __GFP_NOFAIL? I cannot find a reason in the changelogs why the patches
> > are needed.
>   David should probably add the reasoning to the changelogs so that he
> doesn't have to explain again and again ;). But if I understood it
> correctly, the concern is that the looping checks slightly impact fast path
> of the callers which do not need it. Generally, also looping for a long
> time inside allocator isn't a nice thing but some callers aren't able to do
> better for now to the patch is imperfect in this sence...
>

I'm actually a bit confused about this too.
I thought David said he was removing a branch on the *slow* path - which make
sense as you wouldn't even test NOFAIL until you had a failure.
Why are branches on the slow-path an issue??
This is an important question to me because I still hope to see the
swap-over-nfs patches merged eventually and they add a branch on the slow
path (if I remember correctly).

NeilBrown

  reply	other threads:[~2010-09-02 21:15 UTC|newest]

Thread overview: 53+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-08-24 10:50 [patch 1/5] mm: add nofail variants of kmalloc kcalloc and kzalloc David Rientjes
2010-08-24 12:15 ` Jan Kara
2010-08-24 13:29 ` Peter Zijlstra
2010-08-24 13:33   ` Jens Axboe
2010-08-24 20:11     ` David Rientjes
2010-08-25 11:24       ` Ted Ts'o
2010-08-25 11:35         ` Peter Zijlstra
2010-08-25 11:57           ` Ted Ts'o
2010-08-25 12:48             ` Peter Zijlstra
2010-08-25 12:52               ` Peter Zijlstra
2010-08-25 13:20                 ` Theodore Tso
2010-08-25 13:31                   ` Peter Zijlstra
2010-08-25 20:43                     ` David Rientjes
2010-08-25 20:55                       ` Peter Zijlstra
2010-08-25 21:11                         ` David Rientjes
2010-08-25 21:27                           ` Peter Zijlstra
2010-08-25 23:11                             ` David Rientjes
2010-08-26  0:19                               ` Ted Ts'o
2010-08-26  0:30                                 ` David Rientjes
2010-08-26  1:48                                   ` Ted Ts'o
2010-08-26  3:09                                     ` David Rientjes
2010-08-26  6:38                                     ` Dave Chinner
     [not found]                                     ` <alpine.DEB.2.00.1008251951230.7034@chino.kir.corp.google.com>
2010-08-26  7:06                                       ` Dave Chinner
2010-08-26  8:29                                       ` Peter Zijlstra
2010-08-25 13:34                   ` Peter Zijlstra
2010-08-25 13:24               ` Dave Chinner
2010-08-25 13:35                 ` Peter Zijlstra
2010-08-25 20:53                   ` Ted Ts'o
2010-08-25 20:59                     ` David Rientjes
2010-08-25 21:35                     ` Peter Zijlstra
2010-08-25 20:58                   ` David Rientjes
2010-08-25 21:11                     ` Christoph Lameter
2010-08-25 21:21                       ` Peter Zijlstra
2010-08-25 21:23                       ` David Rientjes
2010-08-25 21:35                         ` Christoph Lameter
2010-08-25 23:05                           ` David Rientjes
2010-08-26  1:30                             ` Christoph Lameter
2010-08-26  3:12                               ` David Rientjes
2010-08-26 14:16                                 ` Christoph Lameter
2010-08-26 22:31                                   ` David Rientjes
2010-08-26  0:09                   ` Dave Chinner
2010-08-25 14:13         ` Peter Zijlstra
2010-08-24 13:55   ` Dave Chinner
2010-08-24 14:03     ` Peter Zijlstra
2010-08-24 20:12     ` David Rientjes
2010-08-24 20:08   ` David Rientjes
2010-09-02  1:02 ` [patch v2 " David Rientjes
2010-09-02  7:59   ` Jiri Slaby
2010-09-02 14:51     ` Jan Kara
2010-09-02 21:15       ` Neil Brown [this message]
2010-09-05 23:03         ` David Rientjes
2010-09-05 23:01     ` David Rientjes
2010-09-06  9:05   ` David Rientjes

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=20100903071506.6e6b4d63@notabene \
    --to=neilb@suse.de \
    --cc=akpm@linux-foundation.org \
    --cc=chris.mason@oracle.com \
    --cc=cluster-devel@redhat.com \
    --cc=fweisbec@gmail.com \
    --cc=jack@suse.cz \
    --cc=jaxboe@fusionio.com \
    --cc=jirislaby@gmail.com \
    --cc=linux-btrfs@vger.kernel.org \
    --cc=linux-ext4@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-raid@vger.kernel.org \
    --cc=reiserfs-devel@vger.kernel.org \
    --cc=rientjes@google.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;
as well as URLs for NNTP newsgroup(s).