Commit 29d15009 authored by Andrew Morton's avatar Andrew Morton Committed by Linus Torvalds

[PATCH] alloc_pages priority tuning

Fix up the logic which decides when the caller can dip into page reserves.

- If the caller has realtime scheduling policy, or if the caller cannot run
  direct reclaim, then allow the caller to use up to a quarter of the page
  reserves.

- If the caller has __GFP_HIGH then allow the caller to use up to half of
  the page reserves.

- If the caller has PF_MEMALLOC then the caller can use 100% of the page
  reserves.
Signed-off-by: default avatarAndrew Morton <akpm@osdl.org>
Signed-off-by: default avatarLinus Torvalds <torvalds@osdl.org>
parent ac12db05
......@@ -607,9 +607,17 @@ __alloc_pages(unsigned int gfp_mask, unsigned int order,
int i;
int alloc_type;
int do_retry;
int can_try_harder;
might_sleep_if(wait);
/*
* The caller may dip into page reserves a bit more if the caller
* cannot run direct reclaim, or is the caller has realtime scheduling
* policy
*/
can_try_harder = (unlikely(rt_task(p)) && !in_interrupt()) || !wait;
zones = zonelist->zones; /* the list of zones suitable for gfp_mask */
if (unlikely(zones[0] == NULL)) {
......@@ -641,9 +649,9 @@ __alloc_pages(unsigned int gfp_mask, unsigned int order,
for (i = 0; (z = zones[i]) != NULL; i++) {
min = z->pages_min;
if (gfp_mask & __GFP_HIGH)
min -= min>>1;
if (unlikely(rt_task(p)) && !in_interrupt())
min -= min>>2;
min /= 2;
if (can_try_harder)
min -= min / 4;
min += (1<<order) + z->protection[alloc_type];
if (z->free_pages < min)
......@@ -684,9 +692,9 @@ __alloc_pages(unsigned int gfp_mask, unsigned int order,
for (i = 0; (z = zones[i]) != NULL; i++) {
min = z->pages_min;
if (gfp_mask & __GFP_HIGH)
min -= min>>1;
if (unlikely(rt_task(p)) && !in_interrupt())
min -= min>>2;
min /= 2;
if (can_try_harder)
min -= min / 4;
min += (1<<order) + z->protection[alloc_type];
if (z->free_pages < min)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment