[PATCH] mempool: NOMEMALLOC and NORETRY
Mempools have 2 problems. The first is that mempool_alloc can possibly get stuck in __alloc_pages when they should opt to fail, and take an element from their reserved pool. The second is that it will happily eat emergency PF_MEMALLOC reserves instead of going to their reserved pools. Fix the first by passing __GFP_NORETRY in the allocation calls in mempool_alloc. Fix the second by introducing a __GFP_MEMPOOL flag which directs the page allocator not to allocate from the reserve pool. Signed-off-by: Andrew Morton <akpm@osdl.org> Signed-off-by: Linus Torvalds <torvalds@osdl.org>
This commit is contained in:
committed by
Linus Torvalds
parent
8e30f272a9
commit
b84a35be02
@ -198,11 +198,16 @@ void * mempool_alloc(mempool_t *pool, unsigned int __nocast gfp_mask)
|
||||
void *element;
|
||||
unsigned long flags;
|
||||
DEFINE_WAIT(wait);
|
||||
int gfp_nowait = gfp_mask & ~(__GFP_WAIT | __GFP_IO);
|
||||
int gfp_nowait;
|
||||
|
||||
gfp_mask |= __GFP_NOMEMALLOC; /* don't allocate emergency reserves */
|
||||
gfp_mask |= __GFP_NORETRY; /* don't loop in __alloc_pages */
|
||||
gfp_mask |= __GFP_NOWARN; /* failures are OK */
|
||||
gfp_nowait = gfp_mask & ~(__GFP_WAIT | __GFP_IO);
|
||||
|
||||
might_sleep_if(gfp_mask & __GFP_WAIT);
|
||||
repeat_alloc:
|
||||
element = pool->alloc(gfp_nowait|__GFP_NOWARN, pool->pool_data);
|
||||
element = pool->alloc(gfp_nowait, pool->pool_data);
|
||||
if (likely(element != NULL))
|
||||
return element;
|
||||
|
||||
|
Reference in New Issue
Block a user