public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH] generic pool allocator: allow all chunks to be allocated.
@ 2008-04-16 12:33 Duck
  2008-04-16 14:34 ` Dean Nelson
  0 siblings, 1 reply; 2+ messages in thread
From: Duck @ 2008-04-16 12:33 UTC (permalink / raw)
  To: linux-kernel; +Cc: Bruce Schmid, Dean Nelson

From: Bruce Schmid <duck@freescale.com>


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.

Cc: Dean Nelson <dcn@sgi.com>
Signed-off-by: Bruce Schmid <duck@freescale.com>
---
 lib/genalloc.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/lib/genalloc.c b/lib/genalloc.c
index f6d276d..ac00492 100644
--- a/lib/genalloc.c
+++ b/lib/genalloc.c
@@ -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;
-- 
1.5.4


^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH] generic pool allocator: allow all chunks to be allocated.
  2008-04-16 12:33 [PATCH] generic pool allocator: allow all chunks to be allocated Duck
@ 2008-04-16 14:34 ` Dean Nelson
  0 siblings, 0 replies; 2+ messages in thread
From: Dean Nelson @ 2008-04-16 14:34 UTC (permalink / raw)
  To: Duck; +Cc: linux-kernel

On Wed, Apr 16, 2008 at 06:33:10AM -0600, Duck wrote:
> From: Bruce Schmid <duck@freescale.com>
> 
> 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.

Acked-by: Dean Nelson <dcn@sgi.com>


^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2008-04-16 14:34 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2008-04-16 12:33 [PATCH] generic pool allocator: allow all chunks to be allocated Duck
2008-04-16 14:34 ` Dean Nelson

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox