提交 3148890b 编写于 作者: N Nick Piggin 提交者: Linus Torvalds

[PATCH] mm: __alloc_pages cleanup fix

I believe this patch is required to fix breakage in the asynch reclaim
watermark logic introduced by this patch:

http://www.kernel.org/git/?p=linux/kernel/git/torvalds/linux-2.6.git;a=commitdiff;h=7fb1d9fca5c6e3b06773b69165a73f3fb786b8ee

Just some background of the watermark logic in case it isn't clear...
Basically what we have is this:

 ---  pages_high
   |
   | (a)
   |
 ---  pages_low
   |
   | (b)
   |
 ---  pages_min
   |
   | (c)
   |
 ---  0

Now when pages_low is reached, we want to kick asynch reclaim, which gives us
an interval of "b" before we must start synch reclaim, and gives kswapd an
interval of "a" before it need go back to sleep.

When pages_min is reached, normal allocators must enter synch reclaim, but
PF_MEMALLOC, ALLOC_HARDER, and ALLOC_HIGH (ie.  atomic allocations, recursive
allocations, etc.) get access to varying amounts of the reserve "c".
Signed-off-by: NNick Piggin <npiggin@suse.de>
Cc: "Seth, Rohit" <rohit.seth@intel.com>
Signed-off-by: NAndrew Morton <akpm@osdl.org>
Signed-off-by: NLinus Torvalds <torvalds@osdl.org>
上级 aa877b3d
...@@ -773,9 +773,12 @@ buffered_rmqueue(struct zone *zone, int order, gfp_t gfp_flags) ...@@ -773,9 +773,12 @@ buffered_rmqueue(struct zone *zone, int order, gfp_t gfp_flags)
} }
#define ALLOC_NO_WATERMARKS 0x01 /* don't check watermarks at all */ #define ALLOC_NO_WATERMARKS 0x01 /* don't check watermarks at all */
#define ALLOC_HARDER 0x02 /* try to alloc harder */ #define ALLOC_WMARK_MIN 0x02 /* use pages_min watermark */
#define ALLOC_HIGH 0x04 /* __GFP_HIGH set */ #define ALLOC_WMARK_LOW 0x04 /* use pages_low watermark */
#define ALLOC_CPUSET 0x08 /* check for correct cpuset */ #define ALLOC_WMARK_HIGH 0x08 /* use pages_high watermark */
#define ALLOC_HARDER 0x10 /* try to alloc harder */
#define ALLOC_HIGH 0x20 /* __GFP_HIGH set */
#define ALLOC_CPUSET 0x40 /* check for correct cpuset */
/* /*
* Return 1 if free pages are above 'mark'. This takes into account the order * Return 1 if free pages are above 'mark'. This takes into account the order
...@@ -830,7 +833,14 @@ get_page_from_freelist(gfp_t gfp_mask, unsigned int order, ...@@ -830,7 +833,14 @@ get_page_from_freelist(gfp_t gfp_mask, unsigned int order,
continue; continue;
if (!(alloc_flags & ALLOC_NO_WATERMARKS)) { if (!(alloc_flags & ALLOC_NO_WATERMARKS)) {
if (!zone_watermark_ok(*z, order, (*z)->pages_low, unsigned long mark;
if (alloc_flags & ALLOC_WMARK_MIN)
mark = (*z)->pages_min;
else if (alloc_flags & ALLOC_WMARK_LOW)
mark = (*z)->pages_low;
else
mark = (*z)->pages_high;
if (!zone_watermark_ok(*z, order, mark,
classzone_idx, alloc_flags)) classzone_idx, alloc_flags))
continue; continue;
} }
...@@ -871,7 +881,7 @@ __alloc_pages(gfp_t gfp_mask, unsigned int order, ...@@ -871,7 +881,7 @@ __alloc_pages(gfp_t gfp_mask, unsigned int order,
} }
page = get_page_from_freelist(gfp_mask|__GFP_HARDWALL, order, page = get_page_from_freelist(gfp_mask|__GFP_HARDWALL, order,
zonelist, ALLOC_CPUSET); zonelist, ALLOC_WMARK_LOW|ALLOC_CPUSET);
if (page) if (page)
goto got_pg; goto got_pg;
...@@ -888,7 +898,7 @@ __alloc_pages(gfp_t gfp_mask, unsigned int order, ...@@ -888,7 +898,7 @@ __alloc_pages(gfp_t gfp_mask, unsigned int order,
* cannot run direct reclaim, or if the caller has realtime scheduling * cannot run direct reclaim, or if the caller has realtime scheduling
* policy. * policy.
*/ */
alloc_flags = 0; alloc_flags = ALLOC_WMARK_MIN;
if ((unlikely(rt_task(p)) && !in_interrupt()) || !wait) if ((unlikely(rt_task(p)) && !in_interrupt()) || !wait)
alloc_flags |= ALLOC_HARDER; alloc_flags |= ALLOC_HARDER;
if (gfp_mask & __GFP_HIGH) if (gfp_mask & __GFP_HIGH)
...@@ -959,7 +969,7 @@ __alloc_pages(gfp_t gfp_mask, unsigned int order, ...@@ -959,7 +969,7 @@ __alloc_pages(gfp_t gfp_mask, unsigned int order,
* under heavy pressure. * under heavy pressure.
*/ */
page = get_page_from_freelist(gfp_mask|__GFP_HARDWALL, order, page = get_page_from_freelist(gfp_mask|__GFP_HARDWALL, order,
zonelist, ALLOC_CPUSET); zonelist, ALLOC_WMARK_HIGH|ALLOC_CPUSET);
if (page) if (page)
goto got_pg; goto got_pg;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册