Commit ba9897b1 authored by Andrew Morton's avatar Andrew Morton Committed by Linus Torvalds

[PATCH] disable PF_MEMALLOC for interrupt allocations

If a task is running in state PF_MEMALLOC and is interrupted, the page
allocator will treat allocations by the interrupt handler as
PF_MEMALLOC as well.

Detect that, and stop it.  Also tidies things up a little in there.
parent 55ad55f1
......@@ -461,7 +461,7 @@ __alloc_pages(unsigned int gfp_mask, unsigned int order,
/* here we're in the low on memory slow path */
rebalance:
if (current->flags & (PF_MEMALLOC | PF_MEMDIE)) {
if ((current->flags & (PF_MEMALLOC | PF_MEMDIE)) && !in_interrupt()) {
/* go through the zonelist yet again, ignoring mins */
for (i = 0; zones[i] != NULL; i++) {
struct zone *z = zones[i];
......@@ -470,13 +470,6 @@ __alloc_pages(unsigned int gfp_mask, unsigned int order,
if (page)
return page;
}
nopage:
if (!(current->flags & PF_NOWARN)) {
printk("%s: page allocation failure."
" order:%d, mode:0x%x\n",
current->comm, order, gfp_mask);
}
return NULL;
}
/* Atomic allocations - we can't balance anything */
......@@ -502,13 +495,21 @@ __alloc_pages(unsigned int gfp_mask, unsigned int order,
}
}
/* Don't let big-order allocations loop */
if (order > 3)
goto nopage;
/*
* Don't let big-order allocations loop. Yield for kswapd, try again.
*/
if (order <= 3) {
yield();
goto rebalance;
}
/* Yield for kswapd, and try again */
yield();
goto rebalance;
nopage:
if (!(current->flags & PF_NOWARN)) {
printk("%s: page allocation failure."
" order:%d, mode:0x%x\n",
current->comm, order, gfp_mask);
}
return NULL;
}
/*
......
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