From: Pekka Enberg <penberg@cs.helsinki.fi>
To: akpm@linux-foundation.org
Cc: gorcunov@openvz.org, kosaki.motohiro@jp.fujitsu.com,
mel@csn.ul.ie, cl@linux-foundation.org, riel@redhat.com,
linux-kernel@vger.kernel.org, mingo@elte.hu, rientjes@google.com
Subject: [PATCH 1/2] mm: Introduce GFP_PANIC for early-boot allocations
Date: Fri, 08 May 2009 18:10:28 +0300 [thread overview]
Message-ID: <1241795428.28600.60.camel@penberg-laptop> (raw)
From: Pekka Enberg <penberg@cs.helsinki.fi>
This patch introduces a GFP_PANIC flag that can be used as an annotation
that an early-boot call to kmalloc() or alloc_pages() is expected to
never fail.
To save one GFP flag bit, use a combination of __GFP_NOFAIL and
__GFP_NOREPEAT to make sure we always end up in the "nopage" path of the
page allocator if an allocation fails.
[ gorcunov@openvz.org: initial version of the patch ]
Cc: Christoph Lameter <cl@linux-foundation.org>
Cc: David Rientjes <rientjes@google.com>
Cc: KOSAKI Motohiro <kosaki.motohiro@jp.fujitsu.com>
Cc: Mel Gorman <mel@csn.ul.ie>
Cc: Rik van Riel <riel@redhat.com>
Signed-off-by: Pekka Enberg <penberg@cs.helsinki.fi>
---
Andrew, this one is rebased on top of -mm.
include/linux/gfp.h | 1 +
mm/page_alloc.c | 12 ++++++++++--
2 files changed, 11 insertions(+), 2 deletions(-)
diff --git a/include/linux/gfp.h b/include/linux/gfp.h
index c7429b8..2e76e7b 100644
--- a/include/linux/gfp.h
+++ b/include/linux/gfp.h
@@ -71,6 +71,7 @@ struct vm_area_struct;
#define GFP_HIGHUSER_MOVABLE (__GFP_WAIT | __GFP_IO | __GFP_FS | \
__GFP_HARDWALL | __GFP_HIGHMEM | \
__GFP_MOVABLE)
+#define GFP_PANIC (__GFP_NOFAIL | __GFP_NORETRY)
#ifdef CONFIG_NUMA
#define GFP_THISNODE (__GFP_THISNODE | __GFP_NOWARN | __GFP_NORETRY)
diff --git a/mm/page_alloc.c b/mm/page_alloc.c
index be0ed90..eb8d953 100644
--- a/mm/page_alloc.c
+++ b/mm/page_alloc.c
@@ -1516,8 +1516,11 @@ static inline int
should_alloc_retry(gfp_t gfp_mask, unsigned int order,
unsigned long pages_reclaimed)
{
- /* Do not loop if specifically requested */
- if (gfp_mask & __GFP_NORETRY)
+ /*
+ * Do not loop if specifically requested. Note: GFP_PANIC sets both
+ * flags.
+ */
+ if ((gfp_mask & __GFP_NORETRY) && !(gfp_mask & __GFP_NOFAIL))
return 0;
/*
@@ -1813,6 +1816,11 @@ rebalance:
}
nopage:
+ if (unlikely((gfp_mask & GFP_PANIC) == GFP_PANIC)) {
+ show_mem();
+ panic("Out of memory: %s order: %d, gfp_mask:0x%x\n",
+ p->comm, order, gfp_mask);
+ }
if (!(gfp_mask & __GFP_NOWARN) && printk_ratelimit()) {
printk(KERN_WARNING "%s: page allocation failure."
" order:%d, mode:0x%x\n",
--
1.5.6.3
next reply other threads:[~2009-05-08 15:10 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2009-05-08 15:10 Pekka Enberg [this message]
2009-05-08 15:29 ` Christoph Lameter
2009-05-08 15:41 ` Pekka Enberg
2009-05-09 8:31 ` Ingo Molnar
2009-05-08 20:56 ` Andrew Morton
2009-05-09 8:39 ` Pekka Enberg
2009-05-09 9:19 ` Ingo Molnar
2009-05-09 9:19 ` Pekka Enberg
2009-05-09 9:31 ` Ingo Molnar
2009-05-09 9:32 ` Ingo Molnar
2009-05-10 3:34 ` Andrew Morton
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=1241795428.28600.60.camel@penberg-laptop \
--to=penberg@cs.helsinki.fi \
--cc=akpm@linux-foundation.org \
--cc=cl@linux-foundation.org \
--cc=gorcunov@openvz.org \
--cc=kosaki.motohiro@jp.fujitsu.com \
--cc=linux-kernel@vger.kernel.org \
--cc=mel@csn.ul.ie \
--cc=mingo@elte.hu \
--cc=riel@redhat.com \
--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
all inboxes | Powered by JetHome®