From mboxrd@z Thu Jan 1 00:00:00 1970 Date: Fri, 13 May 2005 23:26:21 -0700 From: Andrew Morton Subject: Re: mempool - only init waitqueue in slow path Message-Id: <20050513232621.75f8a4e7.akpm@osdl.org> In-Reply-To: <20050513155054.GB4750@kvack.org> References: <20050513155054.GB4750@kvack.org> Mime-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Sender: owner-linux-mm@kvack.org Return-Path: To: Benjamin LaHaise Cc: linux-mm@kvack.org List-ID: Benjamin LaHaise wrote: > > Here's a small patch to improve the performance of mempool_alloc by only > initializing the wait queue when we're about to wait. > > -ben > -- > "Time is what keeps everything from happening all at once." -- John Wheeler > > Signed-off-by: Benjamin LaHaise > diff -purN v2.6.12-rc4/mm/mempool.c mempool-rc4/mm/mempool.c > --- v2.6.12-rc4/mm/mempool.c 2005-05-09 15:47:01.000000000 -0400 > +++ mempool-rc4/mm/mempool.c 2005-05-13 10:04:54.000000000 -0400 > @@ -197,7 +197,7 @@ void * mempool_alloc(mempool_t *pool, un > { > void *element; > unsigned long flags; > - DEFINE_WAIT(wait); > + wait_queue_t wait; > int gfp_temp; > > might_sleep_if(gfp_mask & __GFP_WAIT); > @@ -228,6 +228,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(); hmm, I'd have thought that gcc was smart enough to defer the initialisations until the thing-which-is-being-initialised is about to be used. But with gcc-3.4 this patch changes the generated asm in large ways. Odd. -- To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to majordomo@kvack.org. For more info on Linux MM, see: http://www.linux-mm.org/ . Don't email: aart@kvack.org