From: Dean Nelson Cc: Andrey Volkov Cc: Jes Sorensen Cc: "Luck, Tony" Signed-off-by: Andrew Morton --- include/linux/genalloc.h | 3 --- lib/genalloc.c | 25 +++++++------------------ 2 files changed, 7 insertions(+), 21 deletions(-) diff -puN include/linux/genalloc.h~change-gen_pool-allocator-to-not-touch-managed-memory-update include/linux/genalloc.h --- 25/include/linux/genalloc.h~change-gen_pool-allocator-to-not-touch-managed-memory-update Wed Apr 26 14:19:24 2006 +++ 25-akpm/include/linux/genalloc.h Wed Apr 26 14:19:24 2006 @@ -9,9 +9,6 @@ */ -#define GENALLOC_NID_NONE -1 - - /* * General purpose special memory pool descriptor. */ diff -puN lib/genalloc.c~change-gen_pool-allocator-to-not-touch-managed-memory-update lib/genalloc.c --- 25/lib/genalloc.c~change-gen_pool-allocator-to-not-touch-managed-memory-update Wed Apr 26 14:19:24 2006 +++ 25-akpm/lib/genalloc.c Wed Apr 26 14:19:24 2006 @@ -20,17 +20,12 @@ * * @min_alloc_order: log base 2 of number of bytes each bitmap bit represents * @nid: node id of the node the pool structure should be allocated on - * (if set to GENALLOC_NID_NONE, allocation will occur wherever) */ struct gen_pool *gen_pool_create(int min_alloc_order, int nid) { struct gen_pool *pool; - if (nid == GENALLOC_NID_NONE) - pool = kmalloc(sizeof(struct gen_pool), GFP_KERNEL); - else - pool = kmalloc_node(sizeof(struct gen_pool), GFP_KERNEL, nid); - + pool = kmalloc_node(sizeof(struct gen_pool), GFP_KERNEL, nid); if (pool != NULL) { rwlock_init(&pool->lock); INIT_LIST_HEAD(&pool->chunks); @@ -48,35 +43,29 @@ EXPORT_SYMBOL(gen_pool_create); * @addr: starting address of memory chunk to add to pool * @size: size in bytes of the memory chunk to add to pool * @nid: node id of the node the chunk structure and bitmap should be - * allocated on (if set to GENALLOC_NID_NONE, allocation will occur - * wherever) + * allocated on */ int gen_pool_add(struct gen_pool *pool, unsigned long addr, size_t size, int nid) { struct gen_pool_chunk *chunk; int nbits = size >> pool->min_alloc_order; - int nbytes = sizeof(struct gen_pool_chunk) + nbits / 8; + int nbytes = sizeof(struct gen_pool_chunk) + + (nbits + BITS_PER_BYTE - 1) / BITS_PER_BYTE; if (nbytes > PAGE_SIZE) { - if (nid == GENALLOC_NID_NONE) - chunk = vmalloc(nbytes); - else - chunk = vmalloc_node(nbytes, nid); + chunk = vmalloc_node(nbytes, nid); } else { - if (nid == GENALLOC_NID_NONE) - chunk = kmalloc(nbytes, GFP_KERNEL); - else - chunk = kmalloc_node(nbytes, GFP_KERNEL, nid); + chunk = kmalloc_node(nbytes, GFP_KERNEL, nid); } if (unlikely(chunk == NULL)) return -1; + memset(chunk, 0, nbytes); spin_lock_init(&chunk->lock); chunk->start_addr = addr; chunk->end_addr = addr + size; - memset(&chunk->bits[0], 0, nbits / 8); write_lock(&pool->lock); list_add(&chunk->next_chunk, &pool->chunks); _