Skip to contentSkip to conversation

mempool - only init waitqueue in slow path

DISCUSSION Benjamin LaHaise 2 participants 2 messages May 13, 2005 – May 14, 2005 Memory management

lore
Share & tools
lore
#0 lore raw

Hello,

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

Signature · 28 lines
"Time is what keeps everything from happening all at once." -- John Wheeler

Signed-off-by: Benjamin LaHaise <[email protected]>
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();
 	if (!pool->curr_nr)
--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to [email protected].  For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"[email protected]"> [email protected] </a>
#1 lore raw
Quoted 20 lines · Benjamin LaHaise

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

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;

Quoted 8 lines

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 [email protected]. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"[email protected]"> [email protected] </a>