Skip to contentSkip to conversation

generic pool allocator: allow all chunks to be allocated.

PATCH In review Duck 2 participants 2 messages Apr 16, 2008 Library code

lore
Share & tools
lore

Duck

author
#0 lore raw

PATCH 1/1 generic pool allocator: allow all chunks to be allocated.

From: Bruce Schmid <[email protected]>

gen_pool_alloc() doesn't allocate the last chunk in a pool. This patch fixes that problem by correcting the calculation of the number of the last bit in the bitmap.

---
 lib/genalloc.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)
lib/genalloc.c +1 -1
index f6d276d..ac00492 100644
@@ -127,7 +127,7 @@ unsigned long gen_pool_alloc(struct gen_pool *pool, size_t size)
 		chunk = list_entry(_chunk, struct gen_pool_chunk, next_chunk);
 
 		end_bit = (chunk->end_addr - chunk->start_addr) >> order;
-		end_bit -= nbits + 1;
+		end_bit -= (nbits - 1);
 
 		spin_lock_irqsave(&chunk->lock, flags);
 		bit = -1;
Signature · 1 line
1.5.4
Acked-by on v1 1/1
#1 lore raw
Quoted 5 lines · Duck

From: Bruce Schmid <[email protected]>

gen_pool_alloc() doesn't allocate the last chunk in a pool. This patch fixes that problem by correcting the calculation of the number of the last bit in the bitmap.

Indeed it doesn't allocate the last bit. I ran a quick test with and without your patch and your patch does fix the problem.