[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <1241797279.28600.65.camel@penberg-laptop>
Date: Fri, 08 May 2009 18:41:19 +0300
From: Pekka Enberg <penberg@...helsinki.fi>
To: Christoph Lameter <cl@...ux-foundation.org>
Cc: akpm@...ux-foundation.org, gorcunov@...nvz.org,
kosaki.motohiro@...fujitsu.com, mel@....ul.ie, riel@...hat.com,
linux-kernel@...r.kernel.org, mingo@...e.hu, rientjes@...gle.com
Subject: Re: [PATCH 1/2] mm: Introduce GFP_PANIC for early-boot allocations
On Fri, 2009-05-08 at 11:29 -0400, Christoph Lameter wrote:
> On Fri, 8 May 2009, Pekka Enberg wrote:
>
> > From: Pekka Enberg <penberg@...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.
>
> I think the early-boot requirement needs to be dropped. Make this safe to
> be used at anytime.
OK, here's an updated patch description:
Subject: [PATCH 1/2] mm: Introduce GFP_PANIC
From: Pekka Enberg <penberg@...helsinki.fi>
This patch introduces a GFP_PANIC flag that can be used as an annotation
that a kmalloc() or alloc_pages() call is expected to never fail which is
useful for early-boot code, for example.
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@...nvz.org: initial version of the patch ]
Cc: Christoph Lameter <cl@...ux-foundation.org>
Cc: David Rientjes <rientjes@...gle.com>
Cc: KOSAKI Motohiro <kosaki.motohiro@...fujitsu.com>
Cc: Mel Gorman <mel@....ul.ie>
Cc: Rik van Riel <riel@...hat.com>
Signed-off-by: Pekka Enberg <penberg@...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
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
Powered by blists - more mailing lists