From: Christoph Lameter Subject: Re: [patch 1/5] mm: add nofail variants of kmalloc kcalloc and kzalloc Date: Wed, 25 Aug 2010 16:35:04 -0500 (CDT) Message-ID: References: <1282656558.2605.2742.camel@laptop> <4C73CA24.3060707@fusionio.com> <20100825112433.GB4453@thunk.org> <1282736132.2605.3563.camel@laptop> <20100825115709.GD4453@thunk.org> <1282740516.2605.3644.camel@laptop> <20100825132417.GQ31488@dastard> <1282743342.2605.3707.camel@laptop> Mime-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII Cc: Peter Zijlstra , Dave Chinner , Ted Ts'o , Jens Axboe , Andrew Morton , Neil Brown , Alasdair G Kergon , Chris Mason , Steven Whitehouse , Jan Kara , Frederic Weisbecker , "linux-raid@vger.kernel.org" , "linux-btrfs@vger.kernel.org" , "cluster-devel@redhat.com" , "linux-ext4@vger.kernel.org" , "reiserfs-devel@vger.kernel.org" , "linux-kernel@vger.kernel.org" To: David Rientjes Return-path: In-Reply-To: Sender: linux-btrfs-owner@vger.kernel.org List-Id: linux-ext4.vger.kernel.org On Wed, 25 Aug 2010, David Rientjes wrote: > It all depends on what flags are passed to kmalloc(), slab nor slub > enforce __GFP_NOFAIL behavior themselves. In slab, cache_grow() will > return NULL depending on whether the page allocator returns NULL, and that > would only happen for __GFP_NORETRY or > cachep->gfp->gfporder >= PAGE_ALLOC_COSTLY_ORDER. In slub, the default > order is tried with __GFP_NORETRY and if it returns NULL, the higher order > alloc will fail under the same circumstances. So the nofail behavior for > slab depends only on the flags passed from the caller. If the higher order fails in slub then an order 0 alloc is attempted without __GFP_NORETRY. In both cases the nofail behavior of the page allocator determines the outcode. True if the caller mixes in __GFP_NORETRY then you may still get NULL. But that is an issue that can be resolved by the caller.