Skip to content

Commit

Permalink
[PATCH] mempool - only init waitqueue in slow path
Browse files Browse the repository at this point in the history
Here's a small patch to improve the performance of mempool_alloc by only
initializing the wait queue when we're about to wait.

Signed-off-by: Benjamin LaHaise <[email protected]>
Signed-off-by: Andrew Morton <[email protected]>
Signed-off-by: Linus Torvalds <[email protected]>
  • Loading branch information
bcrl authored and Linus Torvalds committed Jun 23, 2005
1 parent 8476994 commit 01890a4
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion mm/mempool.c
Original file line number Diff line number Diff line change
Expand Up @@ -204,7 +204,7 @@ void * mempool_alloc(mempool_t *pool, unsigned int __nocast gfp_mask)
{
void *element;
unsigned long flags;
DEFINE_WAIT(wait);
wait_queue_t wait;
int gfp_temp;

might_sleep_if(gfp_mask & __GFP_WAIT);
Expand Down Expand Up @@ -235,6 +235,7 @@ void * mempool_alloc(mempool_t *pool, unsigned int __nocast gfp_mask)

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

0 comments on commit 01890a4

Please sign in to comment.