Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 627
b: refs/heads/master
c: 20a7777
h: refs/heads/master
i:
  625: 73de519
  623: 4506dff
v: v3
  • Loading branch information
Nick Piggin authored and Linus Torvalds committed May 1, 2005
1 parent d174a5a commit e2a1300
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 22 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: b84a35be0285229b0a8a5e2e04d79360c5b75562
refs/heads/master: 20a77776c24800d1e40a73f520cfcb32239568a9
30 changes: 9 additions & 21 deletions trunk/mm/mempool.c
Original file line number Diff line number Diff line change
Expand Up @@ -198,36 +198,22 @@ void * mempool_alloc(mempool_t *pool, unsigned int __nocast gfp_mask)
void *element;
unsigned long flags;
DEFINE_WAIT(wait);
int gfp_nowait;
int gfp_temp;

might_sleep_if(gfp_mask & __GFP_WAIT);

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);
gfp_temp = gfp_mask & ~(__GFP_WAIT|__GFP_IO);

repeat_alloc:
element = pool->alloc(gfp_nowait, pool->pool_data);

element = pool->alloc(gfp_temp, pool->pool_data);
if (likely(element != NULL))
return element;

/*
* If the pool is less than 50% full and we can perform effective
* page reclaim then try harder to allocate an element.
*/
mb();
if ((gfp_mask & __GFP_FS) && (gfp_mask != gfp_nowait) &&
(pool->curr_nr <= pool->min_nr/2)) {
element = pool->alloc(gfp_mask, pool->pool_data);
if (likely(element != NULL))
return element;
}

/*
* Kick the VM at this point.
*/
wakeup_bdflush(0);

spin_lock_irqsave(&pool->lock, flags);
if (likely(pool->curr_nr)) {
element = remove_element(pool);
Expand All @@ -240,6 +226,8 @@ void * mempool_alloc(mempool_t *pool, unsigned int __nocast gfp_mask)
if (!(gfp_mask & __GFP_WAIT))
return NULL;

/* Now start performing page reclaim */
gfp_temp = gfp_mask;
prepare_to_wait(&pool->wait, &wait, TASK_UNINTERRUPTIBLE);
mb();
if (!pool->curr_nr)
Expand Down

0 comments on commit e2a1300

Please sign in to comment.