public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Andrew Morton <akpm@linux-foundation.org>
To: Cyrill Gorcunov <gorcunov@gmail.com>
Cc: cl@linux.com, mingo@elte.hu, mel@csn.ul.ie,
	linux-kernel@vger.kernel.org, penberg@cs.helsinki.fi,
	riel@redhat.com, rientjes@google.com, xemul@openvz.org
Subject: Re: [PATCH -tip] mm: introduce __GFP_PANIC modifier
Date: Mon, 4 May 2009 12:34:53 -0700	[thread overview]
Message-ID: <20090504123453.d130a6cf.akpm@linux-foundation.org> (raw)
In-Reply-To: <20090504192117.GB31176@lenovo>

On Mon, 4 May 2009 23:21:17 +0400
Cyrill Gorcunov <gorcunov@gmail.com> wrote:

> [Andrew Morton - Mon, May 04, 2009 at 11:53:35AM -0700]
> | On Mon, 4 May 2009 09:47:45 -0400 (EDT)
> | Christoph Lameter <cl@linux.com> wrote:
> | 
> | > 
> | > 
> | > Could you try to avoid consuming another GFP flag? __GFP_BITS_SHIFT is
> | > used elsewhere to figure out where to put miscellanous flags into the gfp
> | > mask. This is pretty limited right now and so the patch does work.
> | 
> | hm, yes, there are seven bits left.
> | 
> | afaict bit 3 (0x08) is unused?
> | 
> | Is __GFP_PANIC very useful?  I expect it will permit a very small code
> | saving at a relatively small number of callsites, all of which are
> | __init anyway?
> | 
> 
> Actually the issue with possible NULL deref already fixed in -tip
> tree commit 9a8709d. There was rather an idea on what will be more
> convenient -- call for __GFP_NOFAIL or use BUG_ON on allocation
> failure or call kmalloc with __GFP_PANIC and forget about if it could
> fail :). Since Christoph said that it's discommended to introduce
> new flag -- I'm fine with that.
> 

Well.  Allowing the caller to dereference the NULL pointer is a good
solution.  It gives us the runtime behaviour we want, and requires no
new code at all.  Usages of this technique should be commented so that
people don't "fix" it.


An alternative to __GFP_PANIC might be:

-	foo = kmalloc(size, GFP_KERNEL);
+	foo = panic_if_null(kmalloc(size, GFP_KERNEL));

void *panic_if_null(void *p)
{
	if (unlikely(p == NULL))
		panic("NULL pointer panic");
	return p;
}

  reply	other threads:[~2009-05-04 19:43 UTC|newest]

Thread overview: 28+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-05-04 12:27 [PATCH -tip] mm: introduce __GFP_PANIC modifier Cyrill Gorcunov
2009-05-04 13:13 ` Ingo Molnar
2009-05-04 13:16   ` Cyrill Gorcunov
2009-05-04 13:47     ` Christoph Lameter
2009-05-04 14:12       ` Cyrill Gorcunov
2009-05-04 14:13         ` Christoph Lameter
2009-05-04 14:29           ` Cyrill Gorcunov
2009-05-04 15:20             ` Cyrill Gorcunov
2009-05-04 15:54               ` Christoph Lameter
2009-05-04 16:11                 ` Cyrill Gorcunov
2009-05-04 19:11                 ` Cyrill Gorcunov
2009-05-04 18:53       ` Andrew Morton
2009-05-04 19:21         ` Cyrill Gorcunov
2009-05-04 19:34           ` Andrew Morton [this message]
2009-05-04 20:09             ` Cyrill Gorcunov
2009-05-08 12:57               ` [RFC/PATCH v2] mm: Introduce GFP_PANIC for non-failing allocations Pekka Enberg
2009-05-08 13:37                 ` Cyrill Gorcunov
2009-05-08 13:50                   ` Pekka Enberg
2009-05-08 14:17                     ` Christoph Lameter
2009-05-08 14:20                 ` Christoph Lameter
2009-05-08 14:23                   ` Pekka Enberg
2009-05-08 14:29                     ` Christoph Lameter
2009-05-08 14:34                       ` Pekka Enberg
2009-05-08 14:37                         ` Rik van Riel
2009-05-08 14:39                           ` Pekka Enberg
2009-05-08 14:43                         ` Christoph Lameter
2009-05-04 19:23 ` [PATCH -tip] mm: introduce __GFP_PANIC modifier Mel Gorman
2009-05-04 19:35   ` Cyrill Gorcunov

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=20090504123453.d130a6cf.akpm@linux-foundation.org \
    --to=akpm@linux-foundation.org \
    --cc=cl@linux.com \
    --cc=gorcunov@gmail.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mel@csn.ul.ie \
    --cc=mingo@elte.hu \
    --cc=penberg@cs.helsinki.fi \
    --cc=riel@redhat.com \
    --cc=rientjes@google.com \
    --cc=xemul@openvz.org \
    /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