From: Benjamin LaHaise Date: Thu, 23 Jun 2005 07:10:01 +0000 (-0700) Subject: [PATCH] mempool - only init waitqueue in slow path X-Git-Tag: v2.6.13-rc1~68^2~415 X-Git-Url: https://err.no/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=01890a4c120f68366441bf5e193d1b9dd543d4d0;p=linux-2.6 [PATCH] mempool - only init waitqueue in slow path 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 Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds --- diff --git a/mm/mempool.c b/mm/mempool.c index 920c8c3ab1..9a72f7d918 100644 --- a/mm/mempool.c +++ b/mm/mempool.c @@ -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); @@ -235,6 +235,7 @@ repeat_alloc: /* 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)